Posted by
Gabriel Landini on
URL: http://imagej.273.s1.nabble.com/Image-ID-increment-value-when-image-cropped-tp5017411p5017417.html
On Wednesday 19 Oct 2016 12:46:42 PEARSON Matthew wrote:
> Something is a bit odd as i wrote my own version of your little test macro
> below, to try to demonstrate the fault but it worked fine. However, if you
> follow these exact steps outside of a macro and use Image>Show Info as the
> means to report the imageID you'll see that the "red" plane of the clown
> image has the id of the unspilt crop - 2 not -1.
Sorry I might be repeating something said before as I had not followed this in
detail.
I might be very wrong, but I do not think it is 'safe' to guess what ID you
will get after a particular procedure.
I wonder if there is a possibility of procedures changing in the future, where
they create more (or less) temporary images and the code might not work?
I think it would be best to use the image name and the predictable result (in
your case "clown.jpg"+" (red)" then select if first and then get the ID. Then
you are sure which image the ID belongs to and do not have to guess.
For example your code assumes that after you run("Crop") the selected image is
the cropped one, but if you click on another just by mistake, you will get the
ID of the clicked one. Similar problem if you change the code and add
something in between, the IDs will be probably different. There is nothing
stating which image the ID should be obtained from, this is assumed that it is
the currently selected image.
Cheers
Gabriel
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html