Dear All,
To start, I think to have found a bug (using the daily built version of ImageJ 1.52a57) where the objects found with the "Analyze Particles..." tool are not really matching with the threshold when applied to the following picture: <https://seafile.unistra.fr/d/f8f47d8fbdf84c098971/> https://seafile.unistra.fr/d/f8f47d8fbdf84c098971/ by using the following macro code : setAutoThreshold("MinError dark"); run("Analyze Particles...", "size=0-100 clear add"); waitForUser("a"); run("Analyze Particles...", "size=0-Infinity clear add"); Indeed, if you look (or zoom) in the bottom left corner there are clearly some particules <100 pixels witch are not selected (as they should). Additionally, the selection is not following the contour of the resulting thresholded picture and even by changing (manually) the threshold conditions, no setting is able to match with the obtained selection. Besides this, if I want to select my tissue excluding holes, here is no (easy) way to do this with the "Analyze Particles..." tool (or at least I didnt find it). Thus in order to solve this issue, I usually use the "Versatile Wand" plugin http://imagejdocu.tudor.lu/doku.php?id=plugin:segmentation:versatile_wand:st art <http://imagejdocu.tudor.lu/doku.php?id=plugin:segmentation:versatile_wand:s tart&s%5B%5D=wand> &s%5B%5D=wand within a function like: setAutoThreshold("MinError dark"); RingSelection(); function RingSelection() //need Versatile_Wand.java http://imagejdocu.tudor.lu/doku.php?id=plugin:segmentation:versatile_wand:st art { run("Clear Results"); run("Analyze Particles...", "display record"); for(i=0;i<nResults;i++) { xon=getResult("XStart",i); yon=getResult("YStart",i); call("Versatile_Wand_Tool.doWand",xon, yon, 0.0, 0.0, 0.0, "8-connected"); //run("Versatile Wand", "value=0 color=0 gradient=0 connectedness=8-connected x="+xon+" y="+yon+" do"); roiManager("Add"); } selectWindow("Results");run ("Close"); run("Select None"); } But this function is quite time consuming and (especially) cant be used in batchmode (because of the use of result windows) Thus is there an easy way to be able to exclude holes from selections? I thank you very much in advance for your help and ideas on this. My best regards, Romain -- R.Vauchelles Ingénieur d'étude Plateforme d'Imagerie Quantitative <https://urldefense.proofpoint.com/v2/url?u=http-3A__imageriepiq.u-2Dstrasbg .fr_&d=DwMFaQ&c=9mghv0deYPYDGP-W745IEdQLV1kHpn4XJRvR6xMRXtA&r=bszeieVRqFWzbI Cr8EzGmXE09BfqHCEHJ2sQhQTP5gGmFaoCtE39EdlmnzwsVtyM&m=qX2XP3uYtPhytrWqJnlWWLv rY5F_jg7skreds3xitYE&s=_kBYYzEGDTWPGuH9PSSBIazFewR9HFy3yY0oJWePm4E&e=> http://imageriepiq.u-strasbg.fr/ 03 68 85 42 98 - <mailto:[hidden email]> [hidden email] CNRS UMR 7021 - Laboratory of Bioimaging and Pathologies <https://urldefense.proofpoint.com/v2/url?u=http-3A__www-2Dlbp.u-2Dstrasbg.f r_&d=DwMFaQ&c=9mghv0deYPYDGP-W745IEdQLV1kHpn4XJRvR6xMRXtA&r=bszeieVRqFWzbICr 8EzGmXE09BfqHCEHJ2sQhQTP5gGmFaoCtE39EdlmnzwsVtyM&m=qX2XP3uYtPhytrWqJnlWWLvrY 5F_jg7skreds3xitYE&s=TG2HMdnfb9FRLHx9u6uvw9PjC2csBuXwfHOJaloohPM&e=> http://www-lbp.u-strasbg.fr Faculté de pharmacie, 74 route du Rhin CS 60024 67401 ILLKIRCH Cedex France -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
On Wednesday, 18 April 2018 15:43:01 BST [hidden email] wrote:
> To start, I think to have found a bug (using the daily built version of > ImageJ 1.52a57) where the objects found with the "Analyze Particles..." tool > are not really matching with the threshold when applied to the following > picture: > > <https://seafile.unistra.fr/d/f8f47d8fbdf84c098971/> > https://seafile.unistra.fr/d/f8f47d8fbdf84c098971/ > by using the following macro code : > setAutoThreshold("MinError dark"); > run("Analyze Particles...", "size=0-100 clear add"); > waitForUser("a"); > run("Analyze Particles...", "size=0-Infinity clear add"); The problem here is that you are using a 16bit image and the threshold is shown on a 16bit overlay. To see what you are exactly analysing, please binarise the image and then apply the particle analysis. Cheers Gabriel -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
On Wednesday, 18 April 2018 16:21:02 BST I wrote:
> The problem here is that you are using a 16bit image and the threshold is > shown on a 16bit overlay. I mean of course "shown on an 8 bit overlay". Cheers Gabriel -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Romain VAUCHELLES
Hi Romain,
> To start, I think to have found a bug (using the daily built version > of ImageJ 1.52a57) where the objects found with the "Analyze > Particles..." tool are not really matching with the threshold... Yes, there is a limitation of the display of the Thresholder for 16-bit and 32-bit images: In order to speed things up, the red color is just created by modifying the color lookup table, which has only 256 entries. So the red display (or B&W, blue+green over/under) is not accurate if the display range has more than 256 equally-spaced pixel values. With today's faster computers (remember that the beginnings of ImageJ date back to the 1990s!), one could cure this by creating a transparent overlay, instead of modifying the color lookup table (with a slight danger that this might break some existing plugins or macros, which rely on the current behavior). This would be also nice because one could do thresholding while showing the image with increased contrast or brightness (B&C settings other than the full range). Would be just some work... --- > Besides this, if I want to select my tissue excluding holes, here > is no (easy) way to do this with the "Analyze Particles..." tool > (or at least I didn’t find it). > I usually use the "Versatile Wand" plugin ... > But this function is quite time consuming ... If you just want a selection for all, use Edit>Selection>Create Selection. For individual selections: The "Analyze Particles" does not *measure* inside the holes, unless you select 'Include Holes'. If you care about the selection, this does not help. Unfortunately, creating a selection from an object where holes should be excluded is slow in ImageJ, because it uses the "ThresholdToSelection" based on Java's GeneralPath class, which is very powerful, but also rather slow. It's the same with Edit>Selection>Create Selection. Maybe you can work around by using masks? - Edit>Selection>Create Mask also creates masks from thresholded images - If you run 'Analyze Particles' with 'Count Masks' output, you get an image where each particle has a unique pixel value, starting with one. It depends what you want to do with the selection to determine whether (count) masks would be useful. E.g. if you run a bitwise 'and' of a mask and 1, it will be 1 at the foreground. Then you can multiply an image with the mask and it will be zero everywhere outside of what is the selected area. Or you can iterate over the pixels and set e.g. use the 'count mask' as an array index, which corresponds to the particle, and add up some data for each pixel of each particle (note that iterating over the pixels is best done in a plugin, or at least Javascript on Java 1.8; is is slow with the macro language). If you do need selections: If you have a count mask, threshold it from 1 to 1 and run 'Create Selection' for a selection corresponding to the first particle, do the same with threshold 2-2 for the second particle, etc. The 'Create Selection' step won't be faster than the Versatile Wand (the time-consuming operations should be the same), but you won't need the Results table. Michael ________________________________________________________________ On 18/04/2018 16:43, Romain VAUCHELLES wrote: > Dear All, > > > > To start, I think to have found a bug (using the daily built version of > ImageJ 1.52a57) where the objects found with the "Analyze Particles..." tool > are not really matching with the threshold when applied to the following > picture: > > <https://seafile.unistra.fr/d/f8f47d8fbdf84c098971/> > https://seafile.unistra.fr/d/f8f47d8fbdf84c098971/ > > by using the following macro code : > > > > setAutoThreshold("MinError dark"); > > run("Analyze Particles...", "size=0-100 clear add"); > > waitForUser("a"); > > run("Analyze Particles...", "size=0-Infinity clear add"); > > > > Indeed, if you look (or zoom) in the bottom left corner there are clearly > some particules <100 pixels witch are not selected (as they should). > > Additionally, the selection is not following the contour of the resulting > thresholded picture and even by changing (manually) the threshold > conditions, no setting is able to match with the obtained selection. > > > > > > Besides this, if I want to select my tissue excluding holes, here is no > (easy) way to do this with the "Analyze Particles..." tool (or at least I > didn’t find it). > > Thus in order to solve this issue, I usually use the "Versatile Wand" plugin > http://imagejdocu.tudor.lu/doku.php?id=plugin:segmentation:versatile_wand:st > art > <http://imagejdocu.tudor.lu/doku.php?id=plugin:segmentation:versatile_wand:s > tart&s%5B%5D=wand> &s%5B%5D=wand > > within a function like: > > > > setAutoThreshold("MinError dark"); > > RingSelection(); > > > > function RingSelection() //need Versatile_Wand.java > http://imagejdocu.tudor.lu/doku.php?id=plugin:segmentation:versatile_wand:st > art > > { > > run("Clear Results"); > > run("Analyze Particles...", "display > record"); > > for(i=0;i<nResults;i++) > > { > > xon=getResult("XStart",i); > > yon=getResult("YStart",i); > > > call("Versatile_Wand_Tool.doWand",xon, yon, 0.0, 0.0, 0.0, "8-connected"); > > //run("Versatile Wand", > "value=0 color=0 gradient=0 connectedness=8-connected x="+xon+" y="+yon+" > do"); > > roiManager("Add"); > > } > > selectWindow("Results");run ("Close"); > > run("Select None"); > > } > > > > But this function is quite time consuming and (especially) can’t be used in > batchmode (because of the use of result windows) > > Thus is there an easy way to be able to exclude holes from selections? > > > > I thank you very much in advance for your help and ideas on this. > > > > My best regards, > > > > Romain > > > > > > -- > > R.Vauchelles > > Ingénieur d'étude Plateforme d'Imagerie Quantitative > <https://urldefense.proofpoint.com/v2/url?u=http-3A__imageriepiq.u-2Dstrasbg > .fr_&d=DwMFaQ&c=9mghv0deYPYDGP-W745IEdQLV1kHpn4XJRvR6xMRXtA&r=bszeieVRqFWzbI > Cr8EzGmXE09BfqHCEHJ2sQhQTP5gGmFaoCtE39EdlmnzwsVtyM&m=qX2XP3uYtPhytrWqJnlWWLv > rY5F_jg7skreds3xitYE&s=_kBYYzEGDTWPGuH9PSSBIazFewR9HFy3yY0oJWePm4E&e=> > http://imageriepiq.u-strasbg.fr/ > > 03 68 85 42 98 - <mailto:[hidden email]> > [hidden email] > > CNRS UMR 7021 - Laboratory of Bioimaging and Pathologies > <https://urldefense.proofpoint.com/v2/url?u=http-3A__www-2Dlbp.u-2Dstrasbg.f > r_&d=DwMFaQ&c=9mghv0deYPYDGP-W745IEdQLV1kHpn4XJRvR6xMRXtA&r=bszeieVRqFWzbICr > 8EzGmXE09BfqHCEHJ2sQhQTP5gGmFaoCtE39EdlmnzwsVtyM&m=qX2XP3uYtPhytrWqJnlWWLvrY > 5F_jg7skreds3xitYE&s=TG2HMdnfb9FRLHx9u6uvw9PjC2csBuXwfHOJaloohPM&e=> > http://www-lbp.u-strasbg.fr > > Faculté de pharmacie, 74 route du Rhin > > CS 60024 67401 ILLKIRCH Cedex France > > > > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Dear Michael and Gabriel,
Many thanks both of you for your answers and help, >The "Analyze Particles" does not *measure* inside the holes, unless you select 'Include Holes'. I tested this suggestion with the following macro on this sample image https://seafile.unistra.fr/f/63589e164b2748d1bd80/ run("Set Measurements...", "area redirect=None decimal=3"); run("Analyze Particles...", "display clear add"); roiManager("Select", 0); roiManager("Measure"); So the measured area obtained through the Analyse Particules tool or later on by reselecting the obtained ROI from the Roi Manager are not matching. This is very confusing, so maybe a note about this issues should be added on the tool help @: https://imagej.nih.gov/ij/docs/guide/146-30.html#sec:Analyze-Menu >If you just want a selection for all, use Edit>Selection>Create Selection. Thanks a lot for this indication, I didn't know about this tool. It will help a lot out for other applications, but this time I rather need to get some separate ROIs. >If you have a count mask, threshold it from 1 to 1 and run 'Create Selection' for a selection corresponding to the first particle, do the same with threshold 2-2 for the second particle, etc. This is a nice solution as well! I tested it within a new fuction and it runs as fast as the solution using the Versatile Wand function, but with the advantage of working in batchmode. Thanks a lot! RingSelectionCM(); function RingSelectionCM() { roiManager("Reset"); run("Select None"); run("Create Mask"); run("Analyze Particles...", " show=[Count Masks] clear"); getStatistics(aarea, mmean, mmin, mmax); for(iRing=1; iRing<mmax; iRing++) { setThreshold(iRing, iRing); run("Create Selection"); roiManager("Add"); } run("Select None"); close("mask"); close("Count Masks of mask"); } I also noticed that if no results window is open, the number nResults is increasing at each use of the Analyse Particules tool, unless I select the Clear result option. Indeed, if no results window is open in parallel, the first time I use the Analyse Particule tool with [Count Masks], the levels of grays in my areas are equal to 1 ,2 , 3 … n . The second time, levels are equal to n, n+1, n+2 .. , and so on. And if a results window is open in parallel, the levels of grays in my areas are always equal to 1 ,2 , 3 … n at each iteration (and this even without activating the clear result option). Is this an expected behavior? Thanks a lot in advance for your answer and help. My best regards, -- R.Vauchelles Ingénieur d'étude Plateforme d'Imagerie Quantitative <https://urldefense.proofpoint.com/v2/url?u=http-3A__imageriepiq.u-2Dstrasbg.fr_&d=DwMFaQ&c=9mghv0deYPYDGP-W745IEdQLV1kHpn4XJRvR6xMRXtA&r=bszeieVRqFWzbICr8EzGmXE09BfqHCEHJ2sQhQTP5gGmFaoCtE39EdlmnzwsVtyM&m=qX2XP3uYtPhytrWqJnlWWLvrY5F_jg7skreds3xitYE&s=_kBYYzEGDTWPGuH9PSSBIazFewR9HFy3yY0oJWePm4E&e=> http://imageriepiq.u-strasbg.fr/ 03 68 85 42 98 - <mailto:[hidden email]> [hidden email] CNRS UMR 7021 - Laboratory of Bioimaging and Pathologies <https://urldefense.proofpoint.com/v2/url?u=http-3A__www-2Dlbp.u-2Dstrasbg.fr_&d=DwMFaQ&c=9mghv0deYPYDGP-W745IEdQLV1kHpn4XJRvR6xMRXtA&r=bszeieVRqFWzbICr8EzGmXE09BfqHCEHJ2sQhQTP5gGmFaoCtE39EdlmnzwsVtyM&m=qX2XP3uYtPhytrWqJnlWWLvrY5F_jg7skreds3xitYE&s=TG2HMdnfb9FRLHx9u6uvw9PjC2csBuXwfHOJaloohPM&e=> http://www-lbp.u-strasbg.fr Faculté de pharmacie, 74 route du Rhin CS 60024 67401 ILLKIRCH Cedex France -----Message d'origine----- De : ImageJ Interest Group [mailto:[hidden email]] De la part de Michael Schmid Envoyé : mercredi 18 avril 2018 17:59 À : [hidden email] Objet : Re: Issues with Analyse Particule Hi Romain, > To start, I think to have found a bug (using the daily built version > of ImageJ 1.52a57) where the objects found with the "Analyze > Particles..." tool are not really matching with the threshold... Yes, there is a limitation of the display of the Thresholder for 16-bit and 32-bit images: In order to speed things up, the red color is just created by modifying the color lookup table, which has only 256 entries. So the red display (or B&W, blue+green over/under) is not accurate if the display range has more than 256 equally-spaced pixel values. With today's faster computers (remember that the beginnings of ImageJ date back to the 1990s!), one could cure this by creating a transparent overlay, instead of modifying the color lookup table (with a slight danger that this might break some existing plugins or macros, which rely on the current behavior). This would be also nice because one could do thresholding while showing the image with increased contrast or brightness (B&C settings other than the full range). Would be just some work... --- > Besides this, if I want to select my tissue excluding holes, here > is no (easy) way to do this with the "Analyze Particles..." tool > (or at least I didn’t find it). > I usually use the "Versatile Wand" plugin ... > But this function is quite time consuming ... If you just want a selection for all, use Edit>Selection>Create Selection. For individual selections: The "Analyze Particles" does not *measure* inside the holes, unless you select 'Include Holes'. If you care about the selection, this does not help. Unfortunately, creating a selection from an object where holes should be excluded is slow in ImageJ, because it uses the "ThresholdToSelection" based on Java's GeneralPath class, which is very powerful, but also rather slow. It's the same with Edit>Selection>Create Selection. Maybe you can work around by using masks? - Edit>Selection>Create Mask also creates masks from thresholded images - If you run 'Analyze Particles' with 'Count Masks' output, you get an image where each particle has a unique pixel value, starting with one. It depends what you want to do with the selection to determine whether (count) masks would be useful. E.g. if you run a bitwise 'and' of a mask and 1, it will be 1 at the foreground. Then you can multiply an image with the mask and it will be zero everywhere outside of what is the selected area. Or you can iterate over the pixels and set e.g. use the 'count mask' as an array index, which corresponds to the particle, and add up some data for each pixel of each particle (note that iterating over the pixels is best done in a plugin, or at least Javascript on Java 1.8; is is slow with the macro language). If you do need selections: If you have a count mask, threshold it from 1 to 1 and run 'Create Selection' for a selection corresponding to the first particle, do the same with threshold 2-2 for the second particle, etc. The 'Create Selection' step won't be faster than the Versatile Wand (the time-consuming operations should be the same), but you won't need the Results table. Michael ________________________________________________________________ On 18/04/2018 16:43, Romain VAUCHELLES wrote: > Dear All, > > > > To start, I think to have found a bug (using the daily built version > of ImageJ 1.52a57) where the objects found with the "Analyze > Particles..." tool are not really matching with the threshold when > applied to the following > picture: > > < <https://seafile.unistra.fr/d/f8f47d8fbdf84c098971/> https://seafile.unistra.fr/d/f8f47d8fbdf84c098971/> > <https://seafile.unistra.fr/d/f8f47d8fbdf84c098971/> https://seafile.unistra.fr/d/f8f47d8fbdf84c098971/ > > by using the following macro code : > > > > setAutoThreshold("MinError dark"); > > run("Analyze Particles...", "size=0-100 clear add"); > > waitForUser("a"); > > run("Analyze Particles...", "size=0-Infinity clear add"); > > > > Indeed, if you look (or zoom) in the bottom left corner there are > clearly some particules <100 pixels witch are not selected (as they should). > > Additionally, the selection is not following the contour of the > resulting thresholded picture and even by changing (manually) the > threshold conditions, no setting is able to match with the obtained selection. > > > > > > Besides this, if I want to select my tissue excluding holes, here is > no > (easy) way to do this with the "Analyze Particles..." tool (or at > least I didn’t find it). > > Thus in order to solve this issue, I usually use the "Versatile Wand" > plugin > <http://imagejdocu.tudor.lu/doku.php?id=plugin:segmentation:versatile_w> http://imagejdocu.tudor.lu/doku.php?id=plugin:segmentation:versatile_w > and:st > art > <http://imagejdocu.tudor.lu/doku.php?id=plugin:segmentation:versatile_ > wand:s > tart&s%5B%5D=wand> &s%5B%5D=wand > > within a function like: > > > > setAutoThreshold("MinError dark"); > > RingSelection(); > > > > function RingSelection() //need Versatile_Wand.java > <http://imagejdocu.tudor.lu/doku.php?id=plugin:segmentation:versatile_w> http://imagejdocu.tudor.lu/doku.php?id=plugin:segmentation:versatile_w > and:st > art > > { > > run("Clear Results"); > > run("Analyze Particles...", "display > record"); > > for(i=0;i<nResults;i++) > > { > > > xon=getResult("XStart",i); > > > yon=getResult("YStart",i); > > > call("Versatile_Wand_Tool.doWand",xon, yon, 0.0, 0.0, 0.0, > "8-connected"); > > //run("Versatile > Wand", > "value=0 color=0 gradient=0 connectedness=8-connected x="+xon+" y="+yon+" > do"); > > roiManager("Add"); > > } > > selectWindow("Results");run ("Close"); > > run("Select None"); > > } > > > > But this function is quite time consuming and (especially) can’t be > used in batchmode (because of the use of result windows) > > Thus is there an easy way to be able to exclude holes from selections? > > > > I thank you very much in advance for your help and ideas on this. > > > > My best regards, > > > > Romain > > > > > > -- > > R.Vauchelles > > Ingénieur d'étude Plateforme d'Imagerie Quantitative > <https://urldefense.proofpoint.com/v2/url?u=http-3A__imageriepiq.u-2Ds > trasbg > .fr_&d=DwMFaQ&c=9mghv0deYPYDGP-W745IEdQLV1kHpn4XJRvR6xMRXtA&r=bszeieVR > qFWzbI > Cr8EzGmXE09BfqHCEHJ2sQhQTP5gGmFaoCtE39EdlmnzwsVtyM&m=qX2XP3uYtPhytrWqJ > nlWWLv > rY5F_jg7skreds3xitYE&s=_kBYYzEGDTWPGuH9PSSBIazFewR9HFy3yY0oJWePm4E&e=> > <http://imageriepiq.u-strasbg.fr/> http://imageriepiq.u-strasbg.fr/ > > 03 68 85 42 98 - < <mailto:[hidden email]> mailto:[hidden email]> > <mailto:[hidden email]> [hidden email] > > CNRS UMR 7021 - Laboratory of Bioimaging and Pathologies > <https://urldefense.proofpoint.com/v2/url?u=http-3A__www-2Dlbp.u-2Dstr > asbg.f > r_&d=DwMFaQ&c=9mghv0deYPYDGP-W745IEdQLV1kHpn4XJRvR6xMRXtA&r=bszeieVRqF > WzbICr > 8EzGmXE09BfqHCEHJ2sQhQTP5gGmFaoCtE39EdlmnzwsVtyM&m=qX2XP3uYtPhytrWqJnl > WWLvrY > 5F_jg7skreds3xitYE&s=TG2HMdnfb9FRLHx9u6uvw9PjC2csBuXwfHOJaloohPM&e=> > <http://www-lbp.u-strasbg.fr> http://www-lbp.u-strasbg.fr > > Faculté de pharmacie, 74 route du Rhin > > CS 60024 67401 ILLKIRCH Cedex France > > > > > -- > ImageJ mailing list: <http://imagej.nih.gov/ij/list.html> http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: <http://imagej.nih.gov/ij/list.html> http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |