Efficient IDL Programming - RESULTS [message #1588] |
Wed, 08 December 1993 11:23 |
dean
Messages: 55 Registered: March 1993
|
Member |
|
|
I just wanted to share my results with everbody that monitors
comp.lang.idl-pvwave. My first method for reading my (512,64) file and
expanding to (512,512) was using the FOR DO BEGIN loops which took about
30 seconds on a VAXstation 4000 running VMS. I tested three suggestion that
were posted or sent directly to me.
Dr. Marty Ryba suggestion took about 9 secs:
imxgrf = rebin(rotate(imxgrf, 4), 8, isize)
mask = 2b^rebin(bindgen(8), 8, isize)
graphic = (imxgrf AND mask) NE 0
graphic = reform(graphic, ysize, xsize, /overwrite)
Chris Chase suggestion took about 12 seconds:
mask = 2B^indgen(8)
B = bytarr(512,512)
A = transpose(A) ; Put the 64 bytes along the rows.
B(*) = (byte(mask#A(*))/128B)(*)
Eric Deutsch suggestion took about 20 seconds:
input_img=byte(indgen(xsize/8,ysize)) ; sample input image
tmp=lindgen(1.0*ysize*xsize) ; 1.0 to avoid int wrap
tmp2=tmp-(tmp/8)*8 ; create mask input
tmp3=reform(tmp2,xsize,ysize) ; reform to correct dim's
mask=2L^tmp3 ; create bitmask
work=congrid(inimg,xsize,ysize) ; replicate each byte 8 times
outimg=(work and mask) ne 0 ; perform the mask
outimg=byte(outimg)*244b ; enhance value
Thanks again for your suggestions. I approached this problem as FORTRAN
programmer thinking FOR loop, FOR loop, ....., but came away thinking like
an IDL programmer.
Kelly Dean
|
|
|