Hi all,
I would need to average intensities along an outline of an object (output of Particle Analyzer). What would be the proper way to do this? I have looked at some examples with using ROI (http://rsbweb.nih.gov/ij/plugins/particle-analyzer.html), but if I understand the implementation code well, it will only use image values at the points of ROI polygin vertices, not at every point of the outline, right? Many thanks for any hint, Jan Dr. Jan Schier Institute of Information Theory and Automation Dept. of Image Processing Pod vodarenskou vezi 4 Prague, Czech Republic -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Jan,
The following macro might give you the desired result. @ Wayne Rasband & all I figured out that actually the outlines you get after "Analyze Particles" and the ones you can produce under >Process >Binary >Outlines are not the same. Furthermore the ROIs you get after selecting "Add to Manager" under the Analyze Particle menu are exactly the inner part of the outlines produced by >Process >Binary >Outlines. The question here is if these differences exist on purpose or due to a difference in the outline production due to the java code or if this might be a bug!?? Here is the macro.... //average intensity at particle outlines openImages=nImages; if(openImages==0) { exit("No open images found"); } imageNames = newArray(nImages); for (i=0; i<imageNames.length; i++){ selectImage(i+1); imageNames[i] = getTitle(); } Dialog.create("Setup"); Dialog.addChoice("original image:", imageNames); Dialog.addChoice("binary image", imageNames); Dialog.addString("Area", "0-Infinity"); Dialog.addString("Circularity", "0.00-1.00"); Dialog.addChoice("Show", newArray("Nothing", "Outlines", "Bare Outlines", "Ellipses", "Masks", "Count Masks", "Overlay Outlines", "Overlay Masks"), "Nothing"); Dialog.addCheckboxGroup(3, 2, newArray("Display results", "Clear results", "Summarize", "Add to Manager", "Exclude edges", "Include holes"), newArray(false, false, false, true, false, false)); Dialog.show(); original=Dialog.getChoice(); binary=Dialog.getChoice(); Area=Dialog.getString(); Circularity=Dialog.getString(); Output=Dialog.getChoice(); DisplayResults=Dialog.getCheckbox(); if(DisplayResults==true) {DisplayResults=" display";} else {DisplayResults="";} ClearResults=Dialog.getCheckbox(); if(ClearResults==true) {ClearResults=" clear";} else {ClearResults="";} Summarize=Dialog.getCheckbox(); if(Summarize==true) {Summarize=" summarize";} else {Summarize="";} AddToManager=Dialog.getCheckbox(); if(AddToManager==true) {AddToManager=" add";} else {AddToManager="";} ExcludeEdges=Dialog.getCheckbox(); if(ExcludeEdges==true) {ExcludeEdges=" exclude";} else {ExcludeEdges="";} IncludeHoles=Dialog.getCheckbox(); if(IncludeHoles==true) {IncludeHoles=" include";} else {IncludeHoles="";} roiManager("reset"); setBatchMode(true); selectWindow(binary); run("Select None"); run("Analyze Particles...", "size=" + Area + " circularity="+Circularity+" show=" + Output + ExcludeEdges + ClearResults + IncludeHoles + Summarize + " record" + AddToManager); n = roiManager("count"); roiManager("Show None"); selectWindow(original); run("Select None"); for(i=0; i<n; i++) { roiManager("select", i); run("Make Band...", "band=1"); roiManager("Update"); run("Measure"); } setBatchMode(false); //end of macro -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
> roiManager("reset");
> setBatchMode(true); > selectWindow(binary); > run("Select None"); > run("Analyze Particles...", "size=" + Area + " circularity="+Circularity+" show=" + Output + ExcludeEdges + ClearResults + IncludeHoles + Summarize + " record" + AddToManager); > n = roiManager("count"); > roiManager("Show None"); > selectWindow(original); > run("Select None"); > for(i=0; i<n; i++) { > roiManager("select", i); > run("Make Band...", "band=1"); > roiManager("Update"); > run("Measure"); > } > setBatchMode(false); Dear Jan, thank you very much for the idea and for the very detailed script! That should indeed do the trick. In between, I have myself probably found another solution - the Roi.getInterpolatedPolynom() gives points along polynom with 1 pixel spacing, which is what I want. Best regards, Jan -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by gankaku
Hi Jan, Jan, Wayne, and everyone,
to me it seems that the outlines of 'Analyze particles' are what you get from the particle's selection by 'draw'. These outlines are inside the particle in the top-left and outside the particle at the bottom right side. The particle analyzers 'Outlines' and 'Bare Outlines' are the same in this respect. I agree that it would be nicer to have 'Analyze particles' draw the outlines as Process>Binary>Outline does it: These are completely inside the particle. With the outlines inside, it can never happen that the outlines of adjacent (but separate) particles touch. There may be a problem, however, with changing this: 'Analyze Particles' is a core component of ImageJ that is used in thousands of user macros. Changing it might break some established macros or change the result of established analysis methods somewhere out there. --- In any case, for analyzing the edge of particles, I would use Process>Binary>Outlines on the binary mask (it does not matter whether you create it with 'Analyze Particles' or Edit>Selection>Create Mask on a thresholded image; just beware that no image namedm 'Mask' should be present when running 'Create Mask'). Then, in Set Measurements, redirect the measurement to your original image and run 'Analyze Particles' on the mask with the outlines ('include holes' should be off). Now the 'Mean' column will be the average intensity of the outline. Michael ________________________________________________________________ On Jan 24, 2014, at 12:29, Jan Brocher - BioVoxxel wrote: > Hi Jan, > > The following macro might give you the desired result. > > @ Wayne Rasband & all > > I figured out that actually the outlines you get after "Analyze Particles" and the ones you can produce under >Process >Binary >Outlines are not the same. Furthermore the ROIs you get after selecting "Add to Manager" under the Analyze Particle menu are exactly the inner part of the outlines produced by >Process >Binary >Outlines. > > The question here is if these differences exist on purpose or due to a difference in the outline production due to the java code or if this might be a bug!?? > > > Here is the macro.... > > //average intensity at particle outlines > > openImages=nImages; > if(openImages==0) { > exit("No open images found"); > } > > imageNames = newArray(nImages); > for (i=0; i<imageNames.length; i++){ > selectImage(i+1); > imageNames[i] = getTitle(); > } > > Dialog.create("Setup"); > Dialog.addChoice("original image:", imageNames); > Dialog.addChoice("binary image", imageNames); > Dialog.addString("Area", "0-Infinity"); > Dialog.addString("Circularity", "0.00-1.00"); > Dialog.addChoice("Show", newArray("Nothing", "Outlines", "Bare Outlines", "Ellipses", "Masks", "Count Masks", "Overlay Outlines", "Overlay Masks"), "Nothing"); > Dialog.addCheckboxGroup(3, 2, newArray("Display results", "Clear results", "Summarize", "Add to Manager", "Exclude edges", "Include holes"), newArray(false, false, false, true, false, false)); > Dialog.show(); > > original=Dialog.getChoice(); > binary=Dialog.getChoice(); > Area=Dialog.getString(); > Circularity=Dialog.getString(); > Output=Dialog.getChoice(); > DisplayResults=Dialog.getCheckbox(); > if(DisplayResults==true) {DisplayResults=" display";} else {DisplayResults="";} > ClearResults=Dialog.getCheckbox(); > if(ClearResults==true) {ClearResults=" clear";} else {ClearResults="";} > Summarize=Dialog.getCheckbox(); > if(Summarize==true) {Summarize=" summarize";} else {Summarize="";} > AddToManager=Dialog.getCheckbox(); > if(AddToManager==true) {AddToManager=" add";} else {AddToManager="";} > ExcludeEdges=Dialog.getCheckbox(); > if(ExcludeEdges==true) {ExcludeEdges=" exclude";} else {ExcludeEdges="";} > IncludeHoles=Dialog.getCheckbox(); > if(IncludeHoles==true) {IncludeHoles=" include";} else {IncludeHoles="";} > > roiManager("reset"); > setBatchMode(true); > selectWindow(binary); > run("Select None"); > run("Analyze Particles...", "size=" + Area + " circularity="+Circularity+" show=" + Output + ExcludeEdges + ClearResults + IncludeHoles + Summarize + " record" + AddToManager); > n = roiManager("count"); > roiManager("Show None"); > selectWindow(original); > run("Select None"); > for(i=0; i<n; i++) { > roiManager("select", i); > run("Make Band...", "band=1"); > roiManager("Update"); > run("Measure"); > } > setBatchMode(false); > > //end of macro > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
This is not new news that the edge of a ROI may be inside the shape on the left and outside on the right (or was this changed since NIH-Image?). Of course it is absolutely essential to understand how the software works and I enjoy reading the discussions here, but there will always have to be compromises with the methods involved in making images discrete squares or cubes.
Of more importance, what are you trying to measure? What imaging modalities were used? What were the spatial & temporal scales? There are cases where pixel or sub-pixel resolution may be essential, but, at least for most (biological) samples that have crossed my desk, there is not enough precision in the original image, the areas are sufficiently large to make a pixel shift insignificant, or there is variation in the segmentation method such that there is no justification for worrying over single pixel shifts in the edges. In general, if a one pixel shift changes the results, a new experiment needs to be designed to test the hypothesis. Regards, Michael =========================================================================== Michael Cammer, Microscopy Core & Dustin Lab , Skirball Institute, NYU Langone Medical Center Cell: 914-309-3270 Lab: 212-263-3208 http://ocs.med.nyu.edu/microscopy & http://www.med.nyu.edu/skirball-lab/dustinlab/ -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Michael Schmid Sent: Friday, January 24, 2014 8:14 AM To: [hidden email] Subject: Re: Averaging intensity along an outline Hi Jan, Jan, Wayne, and everyone, to me it seems that the outlines of 'Analyze particles' are what you get from the particle's selection by 'draw'. These outlines are inside the particle in the top-left and outside the particle at the bottom right side. The particle analyzers 'Outlines' and 'Bare Outlines' are the same in this respect. I agree that it would be nicer to have 'Analyze particles' draw the outlines as Process>Binary>Outline does it: These are completely inside the particle. With the outlines inside, it can never happen that the outlines of adjacent (but separate) particles touch. There may be a problem, however, with changing this: 'Analyze Particles' is a core component of ImageJ that is used in thousands of user macros. Changing it might break some established macros or change the result of established analysis methods somewhere out there. --- In any case, for analyzing the edge of particles, I would use Process>Binary>Outlines on the binary mask (it does not matter whether you create it with 'Analyze Particles' or Edit>Selection>Create Mask on a thresholded image; just beware that no image namedm 'Mask' should be present when running 'Create Mask'). Then, in Set Measurements, redirect the measurement to your original image and run 'Analyze Particles' on the mask with the outlines ('include holes' should be off). Now the 'Mean' column will be the average intensity of the outline. Michael ________________________________________________________________ On Jan 24, 2014, at 12:29, Jan Brocher - BioVoxxel wrote: > Hi Jan, > > The following macro might give you the desired result. > > @ Wayne Rasband & all > > I figured out that actually the outlines you get after "Analyze Particles" and the ones you can produce under >Process >Binary >Outlines are not the same. Furthermore the ROIs you get after selecting "Add to Manager" under the Analyze Particle menu are exactly the inner part of the outlines produced by >Process >Binary >Outlines. > > The question here is if these differences exist on purpose or due to a difference in the outline production due to the java code or if this might be a bug!?? > > > Here is the macro.... > > //average intensity at particle outlines > > openImages=nImages; > if(openImages==0) { > exit("No open images found"); > } > > imageNames = newArray(nImages); > for (i=0; i<imageNames.length; i++){ > selectImage(i+1); > imageNames[i] = getTitle(); > } > > Dialog.create("Setup"); > Dialog.addChoice("original image:", imageNames); > Dialog.addChoice("binary image", imageNames); > Dialog.addString("Area", "0-Infinity"); > Dialog.addString("Circularity", "0.00-1.00"); > Dialog.addChoice("Show", newArray("Nothing", "Outlines", "Bare Outlines", "Ellipses", "Masks", "Count Masks", "Overlay Outlines", "Overlay Masks"), "Nothing"); > Dialog.addCheckboxGroup(3, 2, newArray("Display results", "Clear results", "Summarize", "Add to Manager", "Exclude edges", "Include holes"), newArray(false, false, false, true, false, false)); > Dialog.show(); > > original=Dialog.getChoice(); > binary=Dialog.getChoice(); > Area=Dialog.getString(); > Circularity=Dialog.getString(); > Output=Dialog.getChoice(); > DisplayResults=Dialog.getCheckbox(); > if(DisplayResults==true) {DisplayResults=" display";} else {DisplayResults="";} > ClearResults=Dialog.getCheckbox(); > if(ClearResults==true) {ClearResults=" clear";} else {ClearResults="";} > Summarize=Dialog.getCheckbox(); > if(Summarize==true) {Summarize=" summarize";} else {Summarize="";} > AddToManager=Dialog.getCheckbox(); > if(AddToManager==true) {AddToManager=" add";} else {AddToManager="";} > ExcludeEdges=Dialog.getCheckbox(); > if(ExcludeEdges==true) {ExcludeEdges=" exclude";} else {ExcludeEdges="";} > IncludeHoles=Dialog.getCheckbox(); > if(IncludeHoles==true) {IncludeHoles=" include";} else > {IncludeHoles="";} > > roiManager("reset"); > setBatchMode(true); > selectWindow(binary); > run("Select None"); > run("Analyze Particles...", "size=" + Area + " > circularity="+Circularity+" show=" + Output + ExcludeEdges + > ClearResults + IncludeHoles + Summarize + " record" + AddToManager); n > = roiManager("count"); roiManager("Show None"); > selectWindow(original); run("Select None"); for(i=0; i<n; i++) { > roiManager("select", i); > run("Make Band...", "band=1"); > roiManager("Update"); > run("Measure"); > } > setBatchMode(false); > > //end of macro > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html ------------------------------------------------------------ This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email. ================================= -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |