Hi Mohamed,
the standard deviation is calculated as
sqrt( (sum of squared pixel values - (sum of pixel values)^2 / n) / (n - 1) )
The (n-1) in the denominator might be the reason for the difference.
Sometimes one finds the equation with n instead of n-1 in the denominator. That would be the 'population standard deviation', which is justified if there can't be any more data than the pixels that you have in the ROI.
The denominator n-1 is appropriate if there could be more data, e.g. because the standard deviation is due to detector noise (one could take more and more images), or if you want to calculate the error bars of the mean value.
As usual, it's nicely explained in the Wikipedia,
http://en.wikipedia.org/wiki/Standard_deviationMichael
________________________________________________________________
On Mar 16, 2012, at 17:55, Mohammed Tlais wrote:
> Dear Members,
>
> I tried to compute the standard deviation manually for my ROIs, and
> compared it to the results obtained by imageJ itself; and I noticed a small
> difference (around 0.01) in the results between my values and imageJ's
> standard deviation; the mean of gray values that I calculated was exactly
> the same as that of imageJ; and the standard deviation = Sqrt (Variance),
> where variance = [Sum(grayValues-mean)^2]/(number of pixels inside ROI).
>
> I am interested in seeing the code on how the standard deviation is
> computed, to know where this difference is coming from.
>
> Best Regards,
> Mohamed Tleis