Hi Wayne,
Thanks - initially, I was translating my code from the macro language to
Javascript, so I used IJ.selectWindow instead of selectWindow, but I will
change that. It makes much more sense to always use the ImagePlus,
Avital
On Sat, Aug 29, 2015 at 6:44 PM, Rasband, Wayne (NIH/NIMH) [E] <
[hidden email]> wrote:
> > On Aug 29, 2015, at 2:48 AM, Avital Steinberg <
[hidden email]>
> wrote:
> >
> > Hi,
> > I am experiencing a problem with ImageJ: I open a few images. Then I
> select
> > an image and I want to run a command on it. The problem is that the
> command
> > is executed before the previous command (opening the image) is completed.
> > So - I get an error message saying that imageA is not open, and when I
> > click OK, imageA opens.
> >
> > I didn't have this problem when I was running the same script in the
> macro
> > language.
> >
> > Does anyone have a suggestion how to fix it?
>
> Always use versions of IJ.run() that include an ImagePlus argument, as in
> the following example. Note that the image is never displayed.
>
> img = IJ.openImage("
http://imagej.nih.gov/ij/images/Cell_Colony.jpg");
> IJ.run(img, "Invert", "");
> IJ.run(img, "Gaussian Blur...", "sigma=2");
> IJ.run(img, "Subtract Background...", "rolling=25");
> IJ.setAutoThreshold(img, "IsoData dark");
> IJ.run(img, "Analyze Particles...", "size=10 show=[Overlay Outlines]
> exclude");
> print("count="+ img.getOverlay().size());
>
> -wayne
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html