Login  Register

Re: automate bkg substract from roi

Posted by Wayne Rasband on Jan 03, 2006; 8:19pm
URL: http://imagej.273.s1.nabble.com/automate-bkg-substract-from-roi-tp3704147p3704149.html

Here is a macro that subtracts the mean gray level calculated from
user-defined selections that have been added to the ROI Manager. It
works with either a single image or a stack.

     n = roiManager("count");
     if (n==0)
         exit("This macro requires at least one ROI Manager entry");
     sum = 0;
     for (i=0; i<n; i++) {
         roiManager("select", i);
         getStatistics(area, mean);
         sum += mean;
     }
     average = sum/n;
     run("Select None");
     run("Subtract...", "stack value="+average);

-wayne

On Jan 1, 2006, at 4:29 PM, F Javier Diez Guerra wrote:

> Dear ImageJ listers,
>
> I wish everybody a better new year 2006.
>
> My question:
> Does anybody know of a macro or plugin to automate background
> substraction using  mean gray levels calculated from user-defined
> roi's in a stack? I have searched in the list archive and found no
> specific reference or comment to it.
>
> The purpose is to automate the following manual procedure:
>
> open an image stack (already corrected for uneven illumination)
> draw several roi's within dark background areas (must be done manually)
> import the roi's in multimeasure plugin
> do multimeasure
> average the roi mean gray values obtained for each image in the stack
> use this number  to process > Math > substract each image in the stack
> save the new stack as Vg stack-bkg.tif
> repeat again
>
> The stacks contain images obtained from the same microscope field
> (cultured cells) captured from different fluorescence channels (red,
> green).
>
> I appreciate your help.
>
> Best regards,
>
>
> F Javier Diez-Guerra, PhD
> Profesor Titular
> Centro de Biologia Molecular Severo Ochoa
> Facultad de Ciencias, Universidad Autónoma
> Ctra Colmenar Viejo Km 15
> Cantoblanco, 28049 Madrid
> SPAIN
>
> phone:  +34 91 4978051
> Fax:      +34 91 4978087
> e-mail: [hidden email]