Login  Register

Re: Non reproducible bug on ImageJ

Posted by Michael Schmid on Mar 18, 2015; 2:03pm
URL: http://imagej.273.s1.nabble.com/Non-reproducible-bug-on-ImageJ-tp5012035p5012039.html

Hi Philippe,

the "Restore Selection" command needs a previous selection that has been saved. The macro command "makeRectangle" does not save the selection it creates (it should not, maybe you want to restore the previous selection), so you can't restore the selection created by "makeRectangle". "Crop" does not save the selection either.

If there is no other open window, one could do the following:

  run("Blobs (25K)");
  makeRectangle(83, 41, 94, 159);
  run("Select None");        //saves the selection
  run("Restore Selection");
  run("Crop");
  close();
  run("Blobs (25K)");
  run("Restore Selection");

Unfortunately, this code does not work if there is another open window with a selection and that window comes to the foreground with close(). In that case, selecting that window saves its roi as the last one (WindowManager, line 42), and the roi of that other image will be transferred to the new image with the final "Restore Selection".

The conclusion: "Restore Selection" is not a safe way to transfer selections from one image to another - use the ROI Manager instead, or write Java/javascript code where you can access a roi.

Michael
________________________________________________________________
On Mar 18, 2015, at 14:20, Philippe CARL wrote:

> Dear all / Wayne,
>
> I have got some trouble with an issue on both ImageJ and Fiji that on top of
> this isn’t even reproducible which could make it very tricky to fix.
>
> So let’s consider the following short macro code:
>
> run("Blobs (25K)");
>
> makeRectangle(83, 41, 94, 159);
>
> run("Crop");
>
> close();
>
> run("Blobs (25K)");
>
> run("Restore Selection");
>
> So sometimes this code finishes with the Blobs picture open on which the
> previously defined ROI (i.e. makeRectangle(83, 41, 94, 159)) is selected (as
> expected).
>
> But sometimes it finishes with all the picture being selected (i.e. similar
> to run("Select All")), and this issue is connected to the fact that there is
> a “run("Crop")” within the code.
>
> This problem has now no consequences for the macro I was developing since I
> finally use a getBoundingRect(x, y, width, height) to get the rectangular
> ROI position and sizes and apply later on the copied values with a
> makeRectangle (x, y, width, height) instead of a run("Restore Selection").
>
> But it took me quite some time to figure out the origin of the issue and it
> may as well be problematic for other users.
>
> My best regards,
>
> Philippe
>
>
>
> Philippe CARL
>
> Laboratoire de Biophotonique et Pharmacologie
>
> UMR 7213 CNRS - Université de Strasbourg
>
> Faculté de Pharmacie
>
> 74 route du Rhin
>
> 67401 ILLKIRCH
>
> Tel : +33(0)3 68 85 41 84
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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