[Insight-developers] Setting region and neighborhood iterators

john smith mkinsightdeveloper at gmail.com
Sun Feb 27 16:07:24 EST 2011


Hello,
 I am trying to create my own median filter using visualstudio 2010 and
cmake. I am trying to set the metadata in a .txx file. Furthermore, I am
thinking to use neighborhood iterators of radius=1. These iterators will
scan the hole input image, and every neighborhood of six pixels will give me
the value of one pixel in the output image, which will have the same region
size allocated as the input image. To the following lines, I have included
the code I have written to set the region and neighborhood iterators, but I
am not sure if it is correct. Could someone have a look and inform me if
there is any mistake?

Thanks.



----------------------------------code in .txx
file------------------------------------------
--------------------------------------------------------------------------------------

#ifndef __itkmyMedian_txx
#define __itkmyMedian_txx

#include "myMedianFilter.h"
#include "itkObjectFactory.h"
#include "itkImageRegionIterator.h"
#include "itkConstNeighborhoodIterator.h"


namespace itk
{

template< class TImage>
void myMedianFilter< TImage>
::GenerateData()
{
  typename TImage::ConstPointer input = this->GetInput();

  typename TImage::Pointer output = this->GetOutput();
  output->SetRegions(input->GetLargestPossibleRegion());
  output->Allocate();

  itk::ImageRegionIterator<TImage> outputIterator(output,
output->GetLargestPossibleRegion());


  TImage::SizeType radius;
  radius[0] = 1;
  radius[1] = 1;

  itk::ConstNeighborhoodIterator<TImage> inputIterator(input,
input->GetRadius());
...........
.........
...........

}

}// end namespace
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20110227/8394e40a/attachment.htm>


More information about the Insight-developers mailing list