Re: Where is result image of calculate()?

Posted by Robert Dougherty on
URL: http://imagej.273.s1.nabble.com/Where-is-result-image-of-calculate-tp3701646p3701651.html

John,

I suggest

try {Thread.sleep(200);}
catch(InterruptedException e) {
        IJ.error("Sleep exception "+e);
}
ImagePlus img3 = WindowManager.getCurrentImage();

The first 4 lines are an optional kludge, but they may improve
reliability.   (I'd be interested in learning about a better approach
for making sure that the previous work is done before possibly grabbing
the wrong image.)  You may also find that WindowManager.putBehind() and
WindowManager.getCurrentImage().hide() are handy for controlling
clutter.

Bob

Robert P. Dougherty, Ph.D.
President, OptiNav, Inc.
(425) 467-1118
[hidden email]
http://www.optinav.com


> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
John
> Kim
> Sent: Monday, September 04, 2006 7:10 PM
> To: [hidden email]
> Subject: Where is result image of calculate()?
>
> I'm trying to take the result of a "subtract create" and threshold it
(in
> batch mode). But I don't know how to obtain a reference to the
subtracted

> image. My code looks like this:
>
>     ImageCalculator ic = new ImageCalculator();
>     for (int i=0; i<fileList.length; i++) {
>         ImagePlus img1 = new Opener().openImage(dir1, fileList[i]);
>         ImagePlus img2 = new Opener().openImage(dir1, bkgrdImgFile);
>         ic.calculate("Subtract create", img1, img2);
>         ic.calculate("Threshold",  /* result of subtract? */ );
>     }
>
> As you can see, I need to somehow refer to the resulting image from
the
> first call to calculate(). How do I do that?
>
> Please help! I've spent hours scouring the documentation and email
> archives
> to no avail! Thanks.
>
> John