Login  Register

Re: How to update the display after using batchMode

Posted by Avital Steinberg on Nov 26, 2014; 5:44am
URL: http://imagej.273.s1.nabble.com/How-to-update-the-display-after-using-batchMode-tp5010591p5010630.html

Thank you - Christophe and Michael. Your answers were very helpful and now
I'm happy with my plugin. It corrected a bug that existed when it worked it
batchMode, and now I'm using better coding practices.

Michael - I used the following idea that you gave me: (I wasn't using
batchMode, but it's a useful idea regardless of that)

"if an image has no window yet (because it was created in BatchMode),
simply use imp.show() on the ImagePlus." when I had to use the run methods,
which work on the ImagePlus rather than the ImageProcessor and require the
image to be open.

I appreciate your help,

Avital

On Tue, Nov 25, 2014 at 11:50 AM, Michael Schmid <[hidden email]>
wrote:

> 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
>

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