Image subtraction [message #11675] |
Mon, 18 May 1998 00:00  |
FRANCOIS LAROSE
Messages: 2 Registered: May 1998
|
Junior Member |
|
|
Hi,
I need to do some image subtraction. With IDL, if I only do
Image1 - image2 and I get poor result. Does it have best code to
do image subtraction?
Any help will be appreciated,
Pix
PS If you know a go package of image analisys in IDL, just let me know!
|
|
|
Re: Image subtraction [message #11788 is a reply to message #11675] |
Tue, 26 May 1998 00:00   |
noname
Messages: 5 Registered: May 1998
|
Junior Member |
|
|
Hi,
Yes, NIH Image is now available for PC.
Go there:
http://www.scioncorp.com/index.htm
The name of the pc prog is Scion Image
Skiso
Patrick V. Ford a �crit:
> Try
> tvscl, image1 - A * image2
>
> where A is a correction factor for intensity. One of the problems here is
> how are negative numbers handled, should you change the images to float
> to allow non integer As, and what value should A be, see? (I could not
> resist the pun.)
>
> To set values less than 0 to 0, you could use one of those matrix logical
> something like: img = img * (img GE 0.0)
> (I don't have the ref material handy and unlike many here, I need to
> lookup all but the simplest of stuff.)
>
> For A, there are many ways to determine a value, such as the average of
> the images ratio, max ratio, etc. Or the one I commonly use, trial and
> error.
>
> You could always write(e-mail) the author of NIH Image to find out what he
> is
> doing, whose name escapes me. He
> usually is fairly responsive, or you could examine the sourse code that,
> at least in the past, was available.
>
> BTW, is NIH image still just a Mac program?
>
> Patrick Ford, MD
> Baylor College of Medicine
> pford@bcm.tmc.edu
>
> FRANCOIS LAROSE (aah904@agora.ulaval.ca) wrote:
> : Ok,
>
> : Let me explain, I take two gray scale images and subtract them togethers.
> : Then, I display the result on screen with TVSCL command. When I say, I get
> : poor
> : result, is because I compare the result of this subtraction with the
> : result
> : of a program that make image subtraction (NIH image). The two are very
> : different. So, I suppose I should do something else to get the same
> : result.
>
> : For the package, I working in research so I can't afford a expensive one.
> : Maybe, you can point me some web site...
>
> : Tanks
>
> : Frank
>
> : At 09:59 18/05/98 -0600, you wrote:
> : >you writes:
> : >
> : >> I need to do some image subtraction. With IDL, if I only do
> : >> Image1 - image2 and I get poor result. Does it have best code to
> : >> do image subtraction?
> : >
> : >Poor result how? Can't see it? Doesn't look like what
> : >you expect? Don't believe the results?
> : >
> : >Try this:
> : >
> : > TV, BytScl(image1 - image2, top=!D.N_Colors-1)
> : >
> : >Does that help?
> : >
> : >> PS If you know a good package of image analisys in IDL, just let me
> : know!
> : >
> : >How much would you be willing to pay for this? :-)
> : >
> : >David
> : >
> : >-----------------------------------------------------------
> : >David Fanning, Ph.D.
> : >Fanning Software Consulting
> : >E-Mail: davidf@dfanning.com
> : >Phone: 970-221-0438
> : >Coyote's Guide to IDL Programming: http://www.dfanning.com/
> : >
> : >
|
|
|
Re: image subtraction [message #29746 is a reply to message #11675] |
Mon, 18 March 2002 21:45  |
Dick Jackson
Messages: 347 Registered: August 1998
|
Senior Member |
|
|
"Kenneth Bowman" <k-bowman@null.tamu.edu> wrote in message
news:k-bowman-F0D133.10113317032002@news.tamu.edu...
> In article <MO3k8.1762$HJ.1430@shaw-ty1>,
> "Dick Jackson" <dick@d-jackson.com> wrote:
>
> What's the timing for
>
> imgarr = imgarr - rebin(reform(img1,512,512,1),512,512,12) ?
Good question. I don't know why it would be so, but it's longer:
>>>> > img1 = lonarr(512,512)
>>
>>>> > imgArr = lonarr(12,512,512)
>>
>> Using the methods suggested previously, this is likely to be faster (due
>> to better cache use) if you can dimension this array as
>>
>> imgArr = LONARR(512,512,12)
>
> Good thinking, Ken, if this is an option for Art.
> To round out the timings (YMMV):
>
> FOR ii=0,11 DO imgArr[ii,*,*] = imgArr[ii,*,*] - img1 : 1.402 s
>
> FOR ii=0,11 DO imgArr[ii,0,0] = imgArr[ii,*,*] - img1 : 1.232 s
>
> FOR ii=0,11 DO imgArr[*,*,ii] = imgArr[*,*,ii] - img1 : 0.741 s
>
> FOR ii=0,11 DO imgArr[0,0,ii] = imgArr[0,0,ii] - img1 : 0.301 s
>
> A big win there!
>
> For completeness:
> imgarr = imgarr - rebin(reform(img1,1,512,512),12,512,512) : 0.210 s
For even more completeness:
imgarr = imgarr - rebin(reform(img1,512,512,1),512,512,12) : 0.260 s
Again, this is on IDL 5.5, Win2000.
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
|
|
|
|
Re: image subtraction [message #29775 is a reply to message #11675] |
Thu, 14 March 2002 08:00  |
Dick Jackson
Messages: 347 Registered: August 1998
|
Senior Member |
|
|
"Kenneth P. Bowman" <kpb@null.com> :
>
>>>> imgArr = lonarr(12,512,512)
>
> Using the methods suggested previously, this is likely to be faster (due
> to better cache use) if you can dimension this array as
>
> imgArr = LONARR(512,512,12)
Good thinking, Ken, if this is an option for Art.
To round out the timings (YMMV):
FOR ii=0,11 DO imgArr[ii,*,*] = imgArr[ii,*,*] - img1 : 1.402 s
FOR ii=0,11 DO imgArr[ii,0,0] = imgArr[ii,*,*] - img1 : 1.232 s
FOR ii=0,11 DO imgArr[*,*,ii] = imgArr[*,*,ii] - img1 : 0.741 s
FOR ii=0,11 DO imgArr[0,0,ii] = imgArr[0,0,ii] - img1 : 0.301 s
A big win there!
For completeness:
imgarr = imgarr - rebin(reform(img1,1,512,512),12,512,512) : 0.210 s
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
|
|
|
Re: image subtraction [message #29777 is a reply to message #11675] |
Thu, 14 March 2002 04:55  |
Kenneth P. Bowman
Messages: 585 Registered: May 2000
|
Senior Member |
|
|
In article <qcUj8.884$HJ.1076@shaw-ty1>,
"Dick Jackson" <dick@d-jackson.com> wrote:
>>> imgArr = lonarr(12,512,512)
Using the methods suggested previously, this is likely to be faster (due
to better cache use) if you can dimension this array as
imgArr = LONARR(512,512,12)
Regards, Ken
|
|
|
Re: image subtraction [message #29781 is a reply to message #11675] |
Wed, 13 March 2002 18:48  |
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
|
|
|
Re: image subtraction [message #29782 is a reply to message #11675] |
Wed, 13 March 2002 16:21  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
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
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|