Posted by
gankaku on
Jan 19, 2015; 5:20pm
URL: http://imagej.273.s1.nabble.com/variance-of-pixel-values-tp5011278p5011284.html
Dear Rabih,
see attached a modified macro to measure the variance in a selection (if
there is no selection it measures the variance of the complete image).
//-----------------------
original = getTitle();
//w = getWidth();
//h = getHeight();
getStatistics(area, mean);
getSelectionBounds(x, y, width, height);
for(v=0; v<height; v++) {
for(u=0; u<width; u++) {
summedIntensitySquares = summedIntensitySquares + pow((getPixel(u,v) -
mean), 2);
}
}
variance = (1 / (width * height)) * summedIntensitySquares
RMSC = sqrt((1 / (width * height)) * summedIntensitySquares);
print("Var: " + variance);
print("SD: " + RMSC);
//----------------------------
The variance filter calculates the variance in a limited area
(neighborhood). This neighborhood will be defined by the user using the
radius since the neighborhood is created as circular form to preserve
directional isotropy.
You can convert an image under >Image >Type >...
It might be helpful for you to have a look here:
http://rsb.info.nih.gov/ij/docs/guide/146.htmlRegards,
Jan
--
CEO: Dr. rer. nat. Jan Brocher
phone: +49 (0)6234 917 03 39
mobile: +49 (0)176 705 746 81
e-mail:
[hidden email]
info:
[hidden email]
inquiries:
[hidden email]
web: www.biovoxxel.de
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html