[Insight-users] statical analysis on an image
Miller, James V (Research)
millerjv at crd.ge.com
Thu Oct 6 14:49:17 EDT 2005
Amitesh,
There are several ways to do this:
1. itk::VarianceImageFunction will compute the variance over a neighborhood. You can specify different neighborhood sizes using the SetRadius() method.
2. itk::NoiseImageFilter will compute the variance over a neighborhood over a complete image. The result is an image of standard deviations. The size of the neighborhood can specified with the SetRadius() call.
Also, you do not need to specify the offsets within a NeighborhoodIterator. They are computed automatically for you. It is only the ShapedNeighborhoodIterators that you need to turn on/off certain offsets.
Here is a snippet from the NoiseImageFilter that calculates the standard deviation at one pixel (bit is a neighborhood iterator that is walking the input image)
bit = ConstNeighborhoodIterator<InputImageType>(m_Radius, input, *fit)
unsigned int neighborhoodSize = bit.Size();
..........
sum = NumericTraits<InputRealType>::Zero;
sumOfSquares = NumericTraits<InputRealType>::Zero;
for (i = 0; i < neighborhoodSize; ++i)
{
value = static_cast<InputRealType>( bit.GetPixel(i) );
sum += value;
sumOfSquares += (value*value);
}
// calculate the standard deviation value
var = (sumOfSquares - (sum*sum/num)) / (num - 1.0);
-----Original Message-----
From: insight-users-bounces+millerjv=crd.ge.com at itk.org [mailto:insight-users-bounces+millerjv=crd.ge.com at itk.org]On Behalf Of Amitesh Agarwal
Sent: Thursday, October 06, 2005 2:18 PM
To: Insight-users at itk.org
Subject: [Insight-users] statical analysis on an image
Hi all,
I have a small problem. I wanted to do a statical analysis on a 2D image for a neighborhood size bigger than 3x3, say for a neighbourhood size 7x7 or higher to find standard deviation at each pixel in the neighborhood. Is there already a function or method to do that? If not, while using neighborhooditerator I have noticed that i will have to define each of the offset saperately and for a 7x7 naighborhood it would be 48 possible offsets and will increase for bigger neighborhood sizes. I fell that may be quite cumbersome. Is there anyway to circumvent that??
Thanks
Amitesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20051006/00728387/attachment.html
More information about the Insight-users
mailing list