<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 6.00.2900.2722" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=387203918-06102005><FONT face=Arial color=#0000ff 
size=2>Amitesh, </FONT></SPAN></DIV>
<DIV><SPAN class=387203918-06102005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=387203918-06102005><FONT face=Arial color=#0000ff size=2>There 
are several ways to do this:</FONT></SPAN></DIV>
<DIV><SPAN class=387203918-06102005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=387203918-06102005><FONT face=Arial color=#0000ff size=2>1. 
itk::VarianceImageFunction will compute the variance over a neighborhood.&nbsp; 
You can specify different neighborhood sizes using the SetRadius() 
method.</FONT></SPAN></DIV>
<DIV><SPAN class=387203918-06102005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=387203918-06102005><FONT face=Arial color=#0000ff size=2>2. 
itk::NoiseImageFilter will compute the variance over a neighborhood over a 
complete image.&nbsp; The result is an image of standard deviations. The size of 
the neighborhood can specified with the SetRadius() call.</FONT></SPAN></DIV>
<DIV><SPAN class=387203918-06102005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=387203918-06102005><FONT face=Arial color=#0000ff size=2>Also, 
you do not need to specify the offsets within a NeighborhoodIterator.&nbsp; They 
are computed automatically for you.&nbsp; It is only the 
ShapedNeighborhoodIterators that you need to turn on/off certain offsets.&nbsp; 
</FONT></SPAN></DIV>
<DIV><SPAN class=387203918-06102005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=387203918-06102005><FONT face=Arial color=#0000ff size=2>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)</FONT></SPAN></DIV>
<DIV><SPAN class=387203918-06102005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=387203918-06102005><FONT face=Arial color=#0000ff 
size=2>&nbsp;&nbsp;&nbsp; bit = 
ConstNeighborhoodIterator&lt;InputImageType&gt;(m_Radius, input, 
*fit)</FONT></SPAN></DIV>
<DIV><SPAN class=387203918-06102005><FONT face=Arial color=#0000ff 
size=2>&nbsp;&nbsp;&nbsp; unsigned int neighborhoodSize = 
bit.Size();<BR></FONT></SPAN></DIV>
<DIV><SPAN class=387203918-06102005><FONT face=Arial color=#0000ff 
size=2>&nbsp;&nbsp; ..........</DIV></FONT></SPAN>
<DIV><SPAN class=387203918-06102005><FONT face=Arial color=#0000ff 
size=2><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sum = 
NumericTraits&lt;InputRealType&gt;::Zero;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
sumOfSquares = 
NumericTraits&lt;InputRealType&gt;::Zero;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for 
(i = 0; i &lt; neighborhoodSize; 
++i)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value = 
static_cast&lt;InputRealType&gt;( bit.GetPixel(i) 
);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sum += 
value;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sumOfSquares += 
(value*value);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 
calculate the standard deviation value<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var = 
(sumOfSquares - (sum*sum/num)) / (num - 1.0);<BR></DIV></FONT></SPAN>
<BLOCKQUOTE>
  <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> 
  insight-users-bounces+millerjv=crd.ge.com@itk.org 
  [mailto:insight-users-bounces+millerjv=crd.ge.com@itk.org]<B>On Behalf Of 
  </B>Amitesh Agarwal<BR><B>Sent:</B> Thursday, October 06, 2005 2:18 
  PM<BR><B>To:</B> Insight-users@itk.org<BR><B>Subject:</B> [Insight-users] 
  statical analysis on an image<BR><BR></FONT></DIV>Hi all,<BR><BR>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??<BR><BR>Thanks 
<BR>Amitesh<BR></BLOCKQUOTE></BODY></HTML>