[Insight-developers] Filling a neighborhood from an index

Miller, James V (Research) millerjv@crd.ge.com
Fri, 20 Sep 2002 09:17:50 -0400


Yes, you can sample a image into a Neighborhood. Examples of this are the MeanImageFunction and
MedianImageFunction.  From the MeanImageFunction, 

  ConstSmartNeighborhoodIterator<InputImageType>
    it(kernelSize, m_Image, m_Image->GetBufferedRegion());

  // Set the iterator at the desired location
  it.SetLocation(index);

  // Walk the neighborhood
  const unsigned int size = it.Size();
  for (unsigned int i = 0; i < size; ++i)
    {
    sum += static_cast<RealType>(it.GetPixel(i));
    }
  sum /= double(it.Size());

There is also a RandomAccessNeighborhoodIterator.


> -----Original Message-----
> From: Blezek, Daniel J (Research) 
> Sent: Friday, September 20, 2002 8:42 AM
> To: Insight-developers (E-mail)
> Subject: [Insight-developers] Filling a neighborhood from an index
> 
> 
> ITK'ers,
> 
>   I would like to fill an itkNeighborhood with values from an 
> image centered on an arbitrary index.
> I know there is an itkNeighborhoodIterator that walks through 
> the image and fills it's neighborhood
> everytime you increment the iterator.  I could copy the code 
> from this iterator into my code, but
> would a more general solution be useful?
> 
> Something like this (please forgive the pseudo-code, it's 
> hard enought to write itk code, much less
> contrive a realistic example):
> 
> ImageInputIteratorType inIt = blah, blah, blah;
> ImageOutputIteratorType outIt = blah, blah, blah;
> 
> while ( !inIt.isAtEnd() )
> {
>   InputNeighborhoodType n = inputImage->FillNeighborhood ( 
> inIt.GetIndex(), (region|size|whatever) );
>   while ( walkPixels )
>   {
>     smallest = <Find smallest from n>;
>     newindex = index + smallest.GetIndex();
>     n = inputImage->FillNeighborhood ( newindex, 
> (region|size|whatever) );
>     // more stuff
>   }
>   ++inIt;
>   ++outIt;
> }
> 
>   If such a beast exists, could someone clue me in?
> 
> Thanks,
> -dan
> 
> --
> Daniel Blezek, Ph.D.
> blezek@crd.ge.com
> Visualization and Computer Vision Lab, Imaging Technologies
> GE Global Research Center
> 
> _______________________________________________
> Insight-developers mailing list
> Insight-developers@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-developers
>