Re: Partial Integrated Density Measurement

Posted by Christophe CHAMOT on
URL: http://imagej.273.s1.nabble.com/Partial-Integrated-Density-Measurement-tp3696765p3696766.html

Adem Can a écrit :

> Dear List members,
>
> I have a question about "integrated density" tool in 8 bit images.
>
> Integrated density calculates total gray values by multiplying each gray
> value with number of pixels with that value and adds them up. What I need is
> to be able to determine a cut-off gray value and get the integrated density
> of pixels above that value. This is very similar to thresholding in terms of
> its mechanics. But instead of making everything 255 above the cut-off value,
> I need to retain the gray value information and calculate integrated density
> on those pixels above the threshold.
>
> I cannot specify a ROI like in the dot blot method and get the integrated
> density value for each ROI. I working on neuronal innervations, they don't
> have regular shapes and spread all over the image. And also I am using batch
> processing for image quantification, it is impossible to specify ROIs one by
> one.
>
> Here is a simple flow of how such function should work:
>
> 1. Open file from the specified directory
> 2. Determine the threshold value using certain predetermined parameters (e.g.
> mean+2xstandard deviation) from the histogram
> 3. Calculate the partial integrated density of those pixels with values
> above the threshold from Step 2.
> 4. Return partial integrated density value in the summary window with the
> name of file
> 5. Go back to Step 1
>
> I pretty much know how to get batch mode running in a set of images, only
> thing missing is Step 3 and 4 for me. Thanks in advance for your help.
>
>
>  
Hi Adem,

A simple macro can do it, if there are only images in your folder. Copy
and paste the following code in a macro (plugins>New...) and run :

-----------------------------------------snip------------------------------------------------------------
run("Set Measurements...", "  integrated limit redirect=None decimal=3");
dir1 = getDirectory("Choose Source Directory ");
list = getFileList(dir1);
setBatchMode(true);
for (i=0; i<list.length; i++) {
showProgress(i+1, list.length);
open(dir1+list[i]);
getStatistics(area, mean, min, max, std, histogram);
tmp=mean-(2*std);
if (tmp<0) {
min = 0;
}else{
min=tmp;
}
tmp=mean+(2*std);
if (tmp > 255) {
max = 255;
}else{
max = tmp;
}
//showMessage("Min : "+min+"\nMax : "+max);
setThreshold(min,max);
run("Measure");
}
-----------------------------------------snap------------------------------------------------------------

Cheers,

--
Christophe CHAMOT
---------------------------------------------------------------------
Plate-Forme de Recherche UMR7592
"Imageries des Processus Dynamiques
en Biologie  Cellulaire et Biologie du Développement "
Institut Jacques Monod, CNRS,  Universités Paris 6 et 7
2, place Jussieu - Tour 43
75251 Paris cedex  05
Tel: 01 44 27 47 56
fax: 01 44 27 98 57
http://www.ijm.fr/
---------------------------------------------------------------------