Posted by
Michael Schmid on
Oct 25, 2018; 5:20pm
URL: http://imagej.273.s1.nabble.com/current-window-when-using-IJ-run-Java-tp5021353p5021356.html
Hi Kenneth,
ImagePlus.show() is only for displaying the image for the first time. If
the image is already visible, it does nothing.
If the window was not visible before, I think that it becomes the
foreground image only after some delay (when it really becomes the
foreground window on the screen; this is asynchronous).
You need either
ImageWindow win = imp.getWindow; // (imp is the ImagePlus)
WindowManager.setCurrentWindow(ImageWindow win);
or one of the IJ.selectWindow methods (e.d. based on image id).
If you don't care whether the window appears as frontmost window on the
screen, simply use
IJ.run(imp, "royal");
Michael
________________________________________________________________
On 25.10.18 18:21, Kenneth Sloan wrote:
> A question about running commands which depend on the current window. Java plugin.
>
> I have a Java plugin which generates several ImagePlus objects, and shows them.
>
> The last one is an 8-bit image to which I want to apply a LUT.
>
> I (naƮvely?) assumed that the last ImagePlus.show() call would make that window the current one, so I tried:
>
>
> ...
> ip1.show();
> ip2.show();
> ip3.show();
> IJ.run("royal");
>
> ip1 is an RGB image.
> ip2 is a 32-bit float image.
> ip3 is an 8-bit byte image.
>
> My expectation was that the LUT would be applied to the 3rd image (the 8-bit byte image). Instead, it was applied to
> the 2nd image (the 32-bit float image).
>
> I suspected some sort of race condition, so I tried this:
> ...
> ip1.show();
> ip2.show();
> ip3.show();
> WindowManager.setWindow(ip3.getWindow());
> IJ.run("royal");
>
> No joy! The LUT is *still* applied to ip2, the 32-bit float image.
>
> What am I doing wrong?
>
> For the time being, I'm leaving out the attempt to apply the LUT and simply telling the customer to use Image->Lookup Tables->royal
> to get the color coding. That has certain advantages, BUT...I'd really like to know how to do this automatically.
>
> Do I need to explicitly load the LUT? If so, what's the path to the pool of already installed LUTs? (needs to work across multiple platforms).
>
> I dimly recall doing this year ago, but have forgotten the details. At the time, I was constructing a custom LUT. This time, I just want to use
> one of the already installed LUT's.
>
> --
> Kenneth Sloan
>
[hidden email]
> Vision is the art of seeing what is invisible to others.
>
>
>
>
>
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html