Login  Register

Re: Issues with Analyse Particule

Posted by Michael Schmid on Apr 18, 2018; 3:59pm
URL: http://imagej.273.s1.nabble.com/Issues-with-Analyse-Particule-tp5020527p5020531.html

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