Subtracting Mean Pixel Value From Image

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

Subtracting Mean Pixel Value From Image

Aaron Hendrickson
Hi,

This should be a simple question.  I would like to automate the follow
process to be performed on a large number of images.

1. Measure the mean pixel value.
2. Subtract the measured mean from the image with 9 decimal place precision
(32-bit float result).

I know how to do this by hand by simply measuring the mean and then go to
Process>Math>Subtract but this would take a long time to do on hundreds of
images.  How might this be automated for large sequences of images (i.e. in
a batch processing fashion)?

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Subtracting Mean Pixel Value From Image

Herbie-3
Aaron,

what about a little macro?

getRawStatistics( N, mn );
run( "Subtract...", "value=[mn]" );

HTH

Herbie

_________________________________________________
On 10.09.13 13:19, Aaron Hendrickson wrote:

> Hi,
>
> This should be a simple question.  I would like to automate the follow
> process to be performed on a large number of images.
>
> 1. Measure the mean pixel value.
> 2. Subtract the measured mean from the image with 9 decimal place precision
> (32-bit float result).
>
> I know how to do this by hand by simply measuring the mean and then go to
> Process>Math>Subtract but this would take a long time to do on hundreds of
> images.  How might this be automated for large sequences of images (i.e. in
> a batch processing fashion)?
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Subtracting Mean Pixel Value From Image

ctrueden
In reply to this post by Aaron Hendrickson
Hi Aaron,

> I would like to automate the follow process to be performed on a large
> number of images.

Here's a simple macro:

//run("Set Measurements...", "area mean standard modal min centroid center
perimeter bounding fit shape feret's integrated median skewness kurtosis
area_fraction stack redirect=None decimal=3");
run("Measure");
mean = getResult("Mean");
run("32-bit");
run("Subtract...", "value=" + mean);

I mostly figured it out using Plugins > Macros > Record, and running the
commands I want. ImageJ will dump the corresponding macro commands into the
Recorder window.

The other trick is to run Help > Macro Functions to view the built-in
functions, then search. I knew I wanted to access the Mean value from the
results table, so I searched that page for "results" and found the
getResult function.

HTH,
Curtis

P.S. That first commented out "Set Measurements" line globally configures
which statistics get computed by the "Measure" command. You want to make
sure Mean is one of them (but it generally is by default). Uncommenting
that line is important to ensure your macro always works if you are
planning to distribute it.


On Tue, Sep 10, 2013 at 6:19 AM, Aaron Hendrickson <[hidden email]>wrote:

> Hi,
>
> This should be a simple question.  I would like to automate the follow
> process to be performed on a large number of images.
>
> 1. Measure the mean pixel value.
> 2. Subtract the measured mean from the image with 9 decimal place precision
> (32-bit float result).
>
> I know how to do this by hand by simply measuring the mean and then go to
> Process>Math>Subtract but this would take a long time to do on hundreds of
> images.  How might this be automated for large sequences of images (i.e. in
> a batch processing fashion)?
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html