http://imagej.273.s1.nabble.com/automate-bkg-substract-from-roi-tp3704147p3704151.html
Here is another background subtraction macro. With this one, each image
in the stack is corrected by its own calculated background level. Note
key.
> At 21:19 03/01/2006, you wrote:
>> 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
>
>
> Wayne,
>
> Thanks very much for the "bkg substract from roi" macro. It works very
> well with single images. However, in stacks it takes the value of bkg
> obtained from the first (or current) image and substracts it to the
> whole set of images in the stack. Since the images within the stack
> share the background roi's areas but have different background levels,
> the background correction is only valid for the first (or current)
> image of the stack.
>
> Is it possible to automate the process so that each image of the stack
> is corrected by its own calculated level of background? Alternatively,
> the stack can be first converted to images, substract background with
> the macro to each image individually and then convert the images back
> to stack.
>
> 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]