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

Home » Public Forums » archive » Image subtraction
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: image subtraction [message #29781 is a reply to message #11675] Wed, 13 March 2002 18:48 Go to previous messageGo to previous message
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
"Craig Markwardt" <craigmnet@cow.physics.wisc.edu> wrote in message
news:onbsdsxalv.fsf@cow.physics.wisc.edu...
>
> aburden@mpl.ucsd.edu (Art) writes:
>> Hi,
>>
>> Can anyone come up with an efficient way to subtract a single image
>> from an array of images without using a loop, as in
>>
>> imgArr = imgArr - img1
>>
>> where,
>>
>> imgArr = lonarr(12,512,512)
>>
>> and,
>>
>> img1 = lonarr(512,512)
>>
>> as opposed to
>>
>> For ii=0,11 do imgArr[ii,*,*] = imgArr[ii,*,*] - img1
>
> (a) You can do this:
> imgarr = imgarr - rebin(reform(img1,1,512,512),12,512,512)
>
> This makes IMG1 into a 1x512x512 array, and then uses REBIN to
> expand it to the desired size.
>
> (b) I don't think a FOR loop will be that much slower than the REBIN
> approach, at least for 512x512 arrays.
>
> Good luck,
> Craig

I second Craig's suggestion, and add a small addendum:

The assignment in the FOR loop can be sped up a bit by writing it as:

FOR ii=0,11 DO imgArr[ii,0,0] = imgArr[ii,*,*] - img1
^ ^
The values will be laid in as expected, but this dropped my timing from
1.402 seconds to 1.232 seconds.

Now, having said that, the REBIN method (useful if you have enough memory to
make the second big array) comes in at 0.210 seconds!

Cheers,
--
-Dick

Dick Jackson / dick@d-jackson.com
D-Jackson Software Consulting / http://www.d-jackson.com
Calgary, Alberta, Canada / +1-403-242-7398 / Fax: 241-7392
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: How to retrieve the event structure returned to event function of widget ?
Next Topic: IDL 4.0.1: How to "fill" volume inside isosurface?

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

Current Time: Thu Oct 16 18:43:28 PDT 2025

Total time taken to generate the page: 0.95728 seconds