Posted by
Wayne Rasband on
Mar 20, 2009; 4:08pm
URL: http://imagej.273.s1.nabble.com/Images-to-stack-in-batch-mode-tp3693222p3693228.html
Images are displayed in a thread separate from the thread used to run
plugins, so it would be better not to display the image until you have
finished processing it. With macros, you can easily do this by running
in batch mode. JavaScripts and plugins can run plugins or commands on
images that are not displayed using
IJ.runPlugIn(ImagePlus, className, arg)
or
IJ.run(ImagePlus, command, options)
Here is and updated version of your example that does not display the
image until it has finished:
bProc.dilate(); bProc.dilate();
bProc.erode(); bProc.erode();
ImagePlus impb = new ImagePlus("Zygo phase mask - "+file, bProc);
createSelectionFromMask(impb);
impb.show();
.
.
.
void createSelectionFromMask(ImagePlus imp) {
ImageProcessor ip = imp.getProcessor();
ip.setThreshold(0, 0, ImageProcessor.NO_LUT_UPDATE);
IJ.runPlugIn(imp, "ij.plugin.filter.ThresholdToSelection", "");
}
-wayne
On Mar 20, 2009, at 11:15 AM, Joachim Wesner wrote:
> Hi list,
>
> I seem to remember there were related entries in the list (archives)
> here,
> but it seems I cannot find the right entries/keyword in the moment....
>
> I´m working on a plugin that seems to show erratic behaviour on my new
> fast
> dual core system. I think I "nailed" the problem down to the
> point where I call an external plugin to do some extra processing on an
> internal image that I create (and usually close again after).
>
> The task here is to create a circular ROI from interferometer mask
> data +
> some hole filling
> .
> .
> .
> bProc.dilate(); bProc.dilate();
> bProc.erode(); bProc.erode();
> ImagePlus impb = new ImagePlus("Zygo phase mask - "+file,
> bProc);
> impb.updateAndRepaintWindow();
> impb.show();
> // IJ.wait(200);
> createSelectionFromMask(bProc);
> .
> .
> .
> .
> void createSelectionFromMask(ImageProcessor ip) {
> ip.setThreshold(0, 0, ImageProcessor.NO_LUT_UPDATE);
> IJ.runPlugIn("ij.plugin.filter.ThresholdToSelection", "");
> }
>
>
> It only works if I really shortly "show" the ImagePlus impb before
> calling
> createSelectionFromMask,, OK, I can accept that, as it´s another
> plugin, that I use.
>
> HOWEVER,
>
> Without the added IJ.wait it seems that often on the new fast, dual
> core
> system, the other plugin already runs *BEFORE* the image is "shown",
> so it
> will cease to work.
> Inserting the short delay of 200-500 ms seems to cure the problem for
> the
> moment, but I wonder if there is a better solution!?
>
>
> Sincerely
>
> Joachim
>
>
> Leica Microsystems CMS GmbH | GmbH mit Sitz in Wetzlar | Amtsgericht
> Wetzlar HRB 2432
> Geschäftsführer: Dr. Stefan Traeger | Dr. Wolf-Otto Reuter | Dr.
> David Roy
> Martyr | Colin Davis
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit
http://www.messagelabs.com/email> ______________________________________________________________________
>