Hi all,
I was wondering if any one knows why when you split channels on a cropped image the ID number of the first split channel is 1st channel ID = cropped image ID - 2. If i didn't crop the image the first split channel has ID original - 1. This is having some implications for me in a macro whereby ideally the user can run it on the whole image or crop to an ROI first. However my loop to determine channel id's of windows once it's split channels is messed up if they crop first as the ID of the first channel jumps -2 instead of -1! I'm sure this is probably intentional behaviour and if so i will create some extra lines to deal with this potential change. Thanks for the help, Matt -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute of Genetics and Molecular Medicine (IGMM) University of Edinburgh Crewe Road EH4 2XU -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi all,
I have solved my own problem. I made the ROI selection part of the macro using a dialog and waitForUser instead of the ROI being drawn and cropped pre-running the macro. This way the image ID's are ordered as i expect. This still doesn't explain why this is the case though. Thanks, Matt -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute of Genetics and Molecular Medicine (IGMM) University of Edinburgh Crewe Road EH4 2XU On 18 Oct 2016, at 15:43, PEARSON Matthew <[hidden email]<mailto:[hidden email]>> wrote: Hi all, I was wondering if any one knows why when you split channels on a cropped image the ID number of the first split channel is 1st channel ID = cropped image ID - 2. If i didn't crop the image the first split channel has ID original - 1. This is having some implications for me in a macro whereby ideally the user can run it on the whole image or crop to an ROI first. However my loop to determine channel id's of windows once it's split channels is messed up if they crop first as the ID of the first channel jumps -2 instead of -1! I'm sure this is probably intentional behaviour and if so i will create some extra lines to deal with this potential change. Thanks for the help, Matt -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute of Genetics and Molecular Medicine (IGMM) University of Edinburgh Crewe Road EH4 2XU -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Matt,
sorry, I can't reproduce the problem. Try the following macro: //run("HeLa Cells (1.3M, 48-bit RGB)"); run("Clown (14K)"); getImageID(); makeRectangle(114, 66, 50, 38); run("Crop"); getImageID(); run("Split Channels"); //selectWindow("C1-hela-cells.tif"); selectWindow("clown.jpg (red)"); getImageID(); It's the same for the 'Clown' (RGB) and 'HeLa Cells' (Composite) images, the first image after splitting gets the first free ID, i.e., the ID of the image just opened before minus one. Of course, if there is some step creating an ImagePlus between opening the original image and 'Split Channels', the imageID of the result will be lower. So, if you cannot exclude that an image will be generated in between, it would be better to select the results of the 'split' operation by the new window title, which is the old title plus " (red)" etc. for RGB images, and "C"+the channel number (starting with 1)+"-"+the title for composite images. Michael ________________________________________________________________ On 18 Oct 2016, at 15:43, PEARSON Matthew wrote: > > Hi all, > > I was wondering if any one knows why when you split channels on a > cropped image the ID number of the first split channel is 1st channel > ID = cropped image ID - 2. If i didn't crop the image the first > split channel has ID original - 1. > > This is having some implications for me in a macro whereby ideally > the user can run it on the whole image or crop to an ROI first. > However my loop to determine channel id's of windows once it's split > channels is messed up if they crop first as the ID of the first > channel jumps -2 instead of -1! > > I'm sure this is probably intentional behaviour and if so i will > create some extra lines to deal with this potential change. > > Thanks for the help, > > Matt > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Michael,
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. Interested to know if you find the same. Thanks, Matt run("Clown (14K)"); original = getImageID(); print(original); makeRectangle(114, 66, 50, 38); run("Crop"); crop = getImageID(); print(crop); Run("Split Channels"); selectImage(crop-1); red = getImageID(); print(red); -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute of Genetics and Molecular Medicine (IGMM) University of Edinburgh Crewe Road EH4 2XU On 19 Oct 2016, at 10:12, Michael Schmid <[hidden email]<mailto:[hidden email]>> wrote: Hi Matt, sorry, I can't reproduce the problem. Try the following macro: //run("HeLa Cells (1.3M, 48-bit RGB)"); run("Clown (14K)"); getImageID(); makeRectangle(114, 66, 50, 38); run("Crop"); getImageID(); run("Split Channels"); //selectWindow("C1-hela-cells.tif"); selectWindow("clown.jpg (red)"); getImageID(); It's the same for the 'Clown' (RGB) and 'HeLa Cells' (Composite) images, the first image after splitting gets the first free ID, i.e., the ID of the image just opened before minus one. Of course, if there is some step creating an ImagePlus between opening the original image and 'Split Channels', the imageID of the result will be lower. So, if you cannot exclude that an image will be generated in between, it would be better to select the results of the 'split' operation by the new window title, which is the old title plus " (red)" etc. for RGB images, and "C"+the channel number (starting with 1)+"-"+the title for composite images. Michael ________________________________________________________________ On 18 Oct 2016, at 15:43, PEARSON Matthew wrote: Hi all, I was wondering if any one knows why when you split channels on a cropped image the ID number of the first split channel is 1st channel ID = cropped image ID - 2. If i didn't crop the image the first split channel has ID original - 1. This is having some implications for me in a macro whereby ideally the user can run it on the whole image or crop to an ROI first. However my loop to determine channel id's of windows once it's split channels is messed up if they crop first as the ID of the first channel jumps -2 instead of -1! I'm sure this is probably intentional behaviour and if so i will create some extra lines to deal with this potential change. Thanks for the help, Matt -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.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 |
Hi Gabriel,
Yes i know what you mean, generally i have found using the image ID to be very useful and for me at least its often easier for selecting windows that you want to process in a loop if the id's have been stored in an array and you simply need to increment a variable to select the next image via its id. Likewise i suppose you could store the strings of window names and do it that way. I have not had any issues before now but i will be checking it more thoroughly in future just in case. Thanks, Matt -- Matt Pearson Microscopy Facility MRC Human Genetics Unit Institute of Genetics and Molecular Medicine (IGMM) University of Edinburgh Crewe Road EH4 2XU On 19 Oct 2016, at 14:15, Gabriel Landini <[hidden email]<mailto:[hidden email]>> wrote: 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 -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |