Login  Register

Re: How to update the display after using batchMode

Posted by Michael Schmid on Nov 25, 2014; 9:50am
URL: http://imagej.273.s1.nabble.com/How-to-update-the-display-after-using-batchMode-tp5010591p5010614.html

Hi Avital,

when programming in Java, for most of the functionality you have API calls that work on ImageProcessor level and do not display anything, in contrast to the simple IJ.run(...) method. So, if possible, try to avoid Batchmode in plugins.
Also, using BatchMode in a plugin is a bit dangerous, if you plugin casts an exception and does not exit Batchmode, you may run into trouble.

If avoiding BatchMode is too cumbersome:
If an image has no window yet (because it was created in BatchMode), simply use imp.show() on the ImagePlus. If the image has a roi, you might also need the following after show for the roi to be displayed correctly
        Roi roi = imp.getRoi();
        if (roi!=null) imp.setRoi(roi);

Here you can find the full code how to display any image after BatchMode (no matter whether the image was created in Batchmode or already has a window):
    https://github.com/imagej/imagej1/blob/master/ij/macro/Functions.java#l2812

Michael
________________________________________________________________
On Nov 25, 2014, at 10:23, Avital Steinberg wrote:

> Thanks for your answer - I'm trying to do it in Java. There is no
> setBatchMode function in the Java ImageJ API. However, there is a Batchmode
> variable. I understood that accessing a field variable directly (without
> using a get or set method) is considered a bad coding practice. I saw
> various methods in the java ImageJ API such as addBatchModeImage, but I'm
> not sure what it does,
>
> Avital
>
> On Mon, Nov 24, 2014 at 6:59 PM, Straatman, Kees (Dr.) <[hidden email]
>> wrote:
>
>> Dear Avital,
>>
>> I assume you run a macro so according to
>> http://imagej.nih.gov/ij/developer/macro/functions.html#S you can use
>> either
>>
>> setBatchMode("exit and display"):  Exits batch mode and displays all
>> hidden images.
>>
>> or
>>
>> setBatchMode("show"): Displays the active hidden image, while batch mode
>> remains in same state. Requires 1.48h.
>>
>> Best wishes
>>
>> Kees
>>
>>
>> Dr Ir K.R. Straatman
>> Senior Experimental Officer
>> Advanced Imaging Facility
>> Centre for Core Biotechnology Services
>> University of Leicester
>>
>> http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif
>>
>>
>> -----Original Message-----
>> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
>> Avital Steinberg
>> Sent: 22 November 2014 15:34
>> To: [hidden email]
>> Subject: How to update the display after using batchMode
>>
>> Hi,
>> I set batchMode equal to true in order to turn off the display. I would
>> like to display the final processed image. I tried using
>> img.updateAndDraw() to show the final image, but the image window didn't
>> open. I also tried setting batchMode back to false, but that didn't work
>> either.
>>
>> How can I display the final image?
>>
>> Thank you,
>> Avital
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html