Re: getPixel() for loop
Posted by
Martin du Saire on
URL: http://imagej.273.s1.nabble.com/getPixel-for-loop-tp3702315p3702321.html
Is the grey-level mean for the entire image or a ROI? Would it be
more efficient to use the image calculator?
M
At 08:47 AM 6/27/2006, you wrote:
>Dear all,
>
>I am trying to determine the normalised variance of an image. For this I
>need to minus the grey-level mean from each pixel's grey-level and
>square this value. I figure the best way to do this is to determine each
>pixel value by using getPixel() in a for loop.
>
>My first question: is the initial (origin) pixel getPixel(0,0) or
>getPixel(1,1)?
>
>My second question: if I need to sum these values, how can I keep an
>'updater' variable in my for-loop?
>
>So for example, I have:
>
>W = getWidth();
>H = getHeight();
>for (i=0; i<=H-1; i++) { // Presuming that the origin is 0,0
> // else I guess for (i=1; i<=H; i++)?
> for (i=0; i<=W; i++) {
> p = getPixel(W,H);
> b = (p-mean)^2;
> SOME UPDATER HERE TO A SUM OF b
> }
> }
>Once out of the loop, I can do things to the total.
>
>Cheers, Andy