Re: Plugin - assigning roi measurements to a variable

Posted by Gabriel Landini on
URL: http://imagej.273.s1.nabble.com/Plugin-assigning-roi-measurements-to-a-variable-tp3698886p3698888.html

On Wednesday 11 July 2007 08:52:24 David Platten wrote:

> I have written a macro that creates a signal-to-noise map of the open image
> (see the bottom of this message). I am a medical physicist working in a
> hospital - this routine is useful for checking the response of digital
> x-ray detectors. However, I'd like to use it with 10x10 pixel samples, but
> this takes ages.

I would do this differently because your method spends a lot of time in
setting ROIs and getting the mean and stdvev from it.

You can speed this up quite dramatically just by using the convolution filters
for mean and variance (and get the sd by applying the sqrt of it):
Here is the macro for a kernel of radius=5 (diameter=11) that calcuates the
SNR as mean/sd:

run("Lena (68K)");
setBatchMode(true);
run("Duplicate...", "title=lena-mean");
run("32-bit");
run("Duplicate...", "title=lena-sd");
selectWindow("lena-mean");
run("Mean...", "radius=5");
selectWindow("lena-sd");
run("Variance...", "radius=5");
run("Square Root");
imageCalculator("Divide create 32-bit", "lena-mean","lena-sd");
rename("SNR");
setBatchMode(false);

Now you can find the maximum of the SNR image (by filtering with a Maximum
filter) and subsample the image if you need to do a low resolution map.
I would have thought that have this image is more informative that having
non-overlapping ROIs, but perhaps you have some reason to do it that way.

I hope it helps.

G.