Fill particles with mean value

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Fill particles with mean value

Jan Eglinger-3
Dear ImageJ and Fiji users,

I would like to fill objects with the value of their mean intensity.

Similar to the "Count Masks" option of 'Analyze Particles...' that fills
each particle with its count value, I would like to use a value measured
in another image by the "Redirect to:" option in 'Set Measurements...'
for filling of each particle.
That would result in an image of objects each filled with the mean
intensity value that this object has in a second image/channel.

Did anybody implement this yet in one way or another?

Jan
Reply | Threaded
Open this post in threaded view
|

Re: Fill particles with mean value

Gabriel Landini
On Monday 21 May 2012 15:41:50 you wrote:

> Dear ImageJ and Fiji users,
>
> I would like to fill objects with the value of their mean intensity.
>
> Similar to the "Count Masks" option of 'Analyze Particles...' that fills
> each particle with its count value, I would like to use a value measured
> in another image by the "Redirect to:" option in 'Set Measurements...'
> for filling of each particle.
> That would result in an image of objects each filled with the mean
> intensity value that this object has in a second image/channel.
>
> Did anybody implement this yet in one way or another?
>
> Jan

Use a binary image, then run particles 8 plugin with redirection to an RGB
image (where you extract the mean rgb values from)
Then, you can do this to the original binary image:

run("RGB Color");

for (i=0; i<nResults; i++) {    

     x = getResult('XStart', i); // start points
     y = getResult('YStart', i);

     r=getResult('RedAverage', i);
     g=getResult('GreenAverage', i);
     b=getResult('BlueAverage', i);

     setColor(r, g, b);
     floodFill(x, y, 8);

}
Reply | Threaded
Open this post in threaded view
|

Re: Fill particles with mean value

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by Jan Eglinger-3
On May 21, 2012, at 10:41 AM, Jan Eglinger wrote:

> Dear ImageJ and Fiji users,
>
> I would like to fill objects with the value of their mean intensity.
>
> Similar to the "Count Masks" option of 'Analyze Particles...' that fills
> each particle with its count value, I would like to use a value measured
> in another image by the "Redirect to:" option in 'Set Measurements...'
> for filling of each particle.
> That would result in an image of objects each filled with the mean
> intensity value that this object has in a second image/channel.
>
> Did anybody implement this yet in one way or another?

You can do this sort of thing using an overlay. Here is a JavaScript example:

  imp = IJ.openImage("http://imagej.nih.gov/ij/images/blobs.gif");
  IJ.run("Set Measurements...", "  mean redirect=None");
  IJ.setAutoThreshold(imp, "Default");
  rt = new ResultsTable();
  ParticleAnalyzer.setResultsTable(rt);
  IJ.run(imp, "Analyze Particles...", "show=[Overlay Outlines] clear");
  imp2 = IJ.createImage("Mean Particles", "32-bit Black", imp.getWidth(), imp.getHeight(), 1);
  overlay = imp.getOverlay();
  ip = imp2.getProcessor();
  for (i=0; i<overlay.size(); i++) {
    value = rt.getValue("Mean", i);
    ip.setValue(value);
    ip.fill(overlay.get(i));
  }
  imp2.resetDisplayRange();
  imp2.show();

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: Fill particles with mean value

Jan Eglinger-3
Dear Wayne and Gabriel,

thank you very much for your code examples. That was exactly what I
imagined.

Cheers,
Jan


On 21.05.2012 7:35 PM, Rasband, Wayne (NIH/NIMH) [E] wrote:

> On May 21, 2012, at 10:41 AM, Jan Eglinger wrote:
>> I would like to fill objects with the value of their mean intensity.
>>
>> Similar to the "Count Masks" option of 'Analyze Particles...' that fills
>> each particle with its count value, I would like to use a value measured
>> in another image by the "Redirect to:" option in 'Set Measurements...'
>> for filling of each particle.
>> That would result in an image of objects each filled with the mean
>> intensity value that this object has in a second image/channel.
>>
>> Did anybody implement this yet in one way or another?
>
> You can do this sort of thing using an overlay. Here is a JavaScript example:
>
>   imp = IJ.openImage("http://imagej.nih.gov/ij/images/blobs.gif");
>   IJ.run("Set Measurements...", "  mean redirect=None");
>   IJ.setAutoThreshold(imp, "Default");
>   rt = new ResultsTable();
>   ParticleAnalyzer.setResultsTable(rt);
>   IJ.run(imp, "Analyze Particles...", "show=[Overlay Outlines] clear");
>   imp2 = IJ.createImage("Mean Particles", "32-bit Black", imp.getWidth(), imp.getHeight(), 1);
>   overlay = imp.getOverlay();
>   ip = imp2.getProcessor();
>   for (i=0; i<overlay.size(); i++) {
>     value = rt.getValue("Mean", i);
>     ip.setValue(value);
>     ip.fill(overlay.get(i));
>   }
>   imp2.resetDisplayRange();
>   imp2.show();
>
> -wayne