Skip to content

Commit

Permalink
SYNC: Files modified on wiki.
Browse files Browse the repository at this point in the history
  • Loading branch information
lorensen committed Sep 18, 2015
1 parent d6d4e53 commit f24267c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 52 deletions.
25 changes: 7 additions & 18 deletions Developer/ImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@

#include "itkImageToImageFilter.h"

#include "itkRecursiveGaussianImageFilter.h"

namespace itk
{
template< class TImage>
class ImageFilter:public ImageToImageFilter< TImage, TImage >
{
public:

/** Standard class typedefs. */
typedef ImageFilter Self;
typedef ImageToImageFilter< TImage, TImage > Superclass;
Expand All @@ -22,28 +21,18 @@ class ImageFilter:public ImageToImageFilter< TImage, TImage >
/** Run-time type information (and related methods). */
itkTypeMacro(ImageFilter, ImageToImageFilter);


/** Image dimension. */
itkStaticConstMacro(ImageDimension, unsigned int,
TImage::ImageDimension);


/** Smoothing filter type */
typedef RecursiveGaussianImageFilter<
TImage,
TImage
> InternalGaussianFilterType;

/** Pointer to a gaussian filter. */
typedef typename InternalGaussianFilterType::Pointer InternalGaussianFilterPointer;
itkSetMacro( Variable, double );
itkGetMacro( Variable, double);

protected:
ImageFilter();
ImageFilter(){}
~ImageFilter(){}

/** Does the real work. */
virtual void GenerateData();

double m_Variable;

private:
ImageFilter(const Self &); //purposely not implemented
void operator=(const Self &); //purposely not implemented
Expand All @@ -53,7 +42,7 @@ class ImageFilter:public ImageToImageFilter< TImage, TImage >


#ifndef ITK_MANUAL_INSTANTIATION
#include "ImageFilter.hxx"
#include "ImageFilter.txx"
#endif


Expand Down
45 changes: 11 additions & 34 deletions Developer/ImageFilter.hxx
Original file line number Diff line number Diff line change
@@ -1,53 +1,30 @@
#ifndef __itkImageFilter_txx
#define __itkImageFilter_txx
#ifndef __itkImageFilter_hxx
#define __itkImageFilter_hxx

#include "ImageFilter.h"
#include "itkObjectFactory.h"
#include "itkImageRegionIterator.h"
#include "itkImageRegionConstIterator.h"

namespace itk
{

template< class TImage>
ImageFilter< TImage>
::ImageFilter()
{

}

template< class TImage>
void ImageFilter< TImage>
::GenerateData()
{
InternalGaussianFilterPointer smoothingFilters[ImageDimension];

// Instantiate all filters
for ( unsigned int i = 0; i < ImageDimension; i++ )
{
smoothingFilters[i] = InternalGaussianFilterType::New();
smoothingFilters[i]->SetOrder(InternalGaussianFilterType::ZeroOrder);
smoothingFilters[i]->SetDirection(i);
}

// Connect all filters (start at 1 because 0th filter is connected to the input
for ( unsigned int i = 1; i < ImageDimension; i++ )
{
smoothingFilters[i]->SetInput(
smoothingFilters[i - 1]->GetOutput() );
}

const typename TImage::ConstPointer inputImage( this->GetInput() );
typename TImage::ConstPointer input = this->GetInput();
typename TImage::Pointer output = this->GetOutput();

const typename TImage::RegionType region = inputImage->GetRequestedRegion();
const typename TImage::SizeType size = region.GetSize();
itk::Index<2> cornerPixel = input->GetLargestPossibleRegion().GetIndex();
typename TImage::PixelType newValue = 3;

smoothingFilters[0]->SetInput(inputImage);
this->AllocateOutputs();

smoothingFilters[ImageDimension-1]->Update();
ImageAlgorithm::Copy(input.GetPointer(), output.GetPointer(), output->GetRequestedRegion(),
output->GetRequestedRegion() );

// Copy the output from the last filter
//this->GraftOutput( m_SmoothingFilters[ImageDimension-1]->GetOutput() );
this->GetOutput()->Graft(smoothingFilters[ImageDimension-1]->GetOutput() );
output->SetPixel( cornerPixel, newValue );
}

}// end namespace
Expand Down

0 comments on commit f24267c

Please sign in to comment.