comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: speed up image processing
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: speed up image processing [message #67418] Fri, 24 July 2009 03:06
Klemen is currently offline  Klemen
Messages: 80
Registered: July 2009
Member
>         image_out1 = min([[[image[ind+vector_index[0]]]], [[image[ind
> +vector_index[1]]]], [[image[ind+vector_index[2]]]]], DIM=3)


Impressive, I will take a look at the proposed solution.
Thank you! Klemen
Re: speed up image processing [message #67420 is a reply to message #67418] Thu, 23 July 2009 20:24 Go to previous message
Jye is currently offline  Jye
Messages: 17
Registered: May 2008
Junior Member
At first glance you could loop through the one dimensional subscripts.

FOR indx = 0, N_ELEMENTS(image)-1 DO image_out[indx] = min(image
[vector_index+indx])

But as is the IDL way try to remove all loops. image_out1 in the below
pro takes 0.21s compared to 2.71 and 3.42 when a for loop is used.



PRO foo

image = DIST(100, 200)

s = SIZE(image, /dim)
ncols = s[0]
nrows = s[1]

vector_index = [1*ncols+1, 2*ncols+2, 3*ncols+3]

ind = INDGEN(s)
t=systime(1)
for k=0,99 do begin

image_out1 = min([[[image[ind+vector_index[0]]]], [[image[ind
+vector_index[1]]]], [[image[ind+vector_index[2]]]]], DIM=3)

endfor
print, systime(1)-t


image_out2 = image
t=systime(1)
for k=0,99 do begin

FOR indx = 0, N_ELEMENTS(image)-1 DO image_out2[indx] = min(image
[vector_index+indx])

endfor
print, systime(1)-t

image_out3 = image
t=systime(1)
for k=0,99 do begin

for j = 0, nrows-1 do begin
for i = 0, ncols-1 do begin
x = image(i, j)
indx = j*ncols + i
image_out3(i, j) = min(image[vector_index+indx])
endfor
endfor

endfor
print, systime(1)-t


window, 0
tvscl, image, 0
tvscl, image_out1, 1
tvscl, image_out2, 2
tvscl, image_out3, 3
tvscl, image_out1 - image_out3, 4
tvscl, image_out2 - image_out3, 5

END
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: fits_help issues again/still
Next Topic: Re: hashmap in idl

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:27:37 PDT 2025

Total time taken to generate the page: 0.00579 seconds