NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
itkMIDASBaseConditionalMorphologyFilter.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef itkMIDASBaseConditionalMorphologyFilter_h
16 #define itkMIDASBaseConditionalMorphologyFilter_h
17 
18 #include <itkImageToImageFilter.h>
19 #include <itkImageDuplicator.h>
20 #include <itkConstNeighborhoodIterator.h>
21 
22 namespace itk
23 {
24 
31  template <class TInputImage1, class TInputImage2, class TOutputImage>
32  class ITK_EXPORT MIDASBaseConditionalMorphologyFilter : public ImageToImageFilter<TInputImage1, TOutputImage>
33  {
34  public:
37  typedef ImageToImageFilter<TInputImage1, TOutputImage> SuperClass;
38  typedef SmartPointer<Self> Pointer;
39  typedef SmartPointer<const Self> ConstPointer;
40 
42  itkTypeMacro(MIDASBaseConditionalMorphologyFilter, ImageToImageFilter);
43 
45  typedef typename TInputImage1::PixelType PixelType1;
46 
49 
51  typedef TInputImage1 InputMaskImageType;
52  typedef typename InputMaskImageType::Pointer InputMaskImagePointer;
56 
57  typedef TInputImage2 InputMainImageType;
58  typedef typename InputMainImageType::Pointer InputMainImagePointer;
61 
62  typedef TOutputImage OutputImageType;
63  typedef typename OutputImageType::Pointer OutputImagePointer;
67  typedef typename itk::ConstNeighborhoodIterator<OutputImageType>::RadiusType OutputImageRadiusType;
68 
70  typedef typename itk::ImageDuplicator<OutputImageType> MaskImageDuplicatorType;
71  typedef typename MaskImageDuplicatorType::Pointer MaskImageDuplicatorPointer;
72 
74  void SetRegion(InputMaskImageRegionType region) { m_Region = region; m_UserSetRegion = true; this->Modified(); }
75  InputMaskImageRegionType GetRegion() const { return m_Region; }
76 
78  itkSetMacro(NumberOfIterations, unsigned int);
79  itkGetConstMacro(NumberOfIterations, unsigned int);
80 
82  itkSetMacro(InValue, PixelType1);
83  itkGetConstMacro(InValue, PixelType1);
84 
86  itkSetMacro(OutValue, PixelType1);
87  itkGetConstMacro(OutValue, PixelType1);
88 
90  void SetBinaryImageInput(const InputMaskImageType* image);
91 
93  void SetGreyScaleImageInput(const InputMainImageType* image);
94 
95  protected:
98  void PrintSelf(std::ostream& os, Indent indent) const;
99 
101  virtual void GenerateData();
102 
104  virtual void DoFilter(InputMainImageType* inGrey, OutputImageType* inMask, OutputImageType *out) = 0;
105 
107  virtual void BeforeFilter() {};
108 
110  virtual void AfterFilter() {};
111 
113  virtual void BeforeIteration() {};
114 
116  virtual void AfterIteration() {};
117 
118  void CopyImageData(OutputImageType* in, OutputImageType *out);
119  bool IsOnBoundaryOfImage(const OutputImageIndexType &voxelIndex, const OutputImageSizeType &size);
120  bool IsOnBoundaryOfRegion(const OutputImageIndexType &voxelIndex, const OutputImageRegionType& region);
121 
122  InputMaskImageRegionType m_Region;
124 
125  private:
126  MIDASBaseConditionalMorphologyFilter(const Self&); //purposely not implemented
127  void operator=(const Self&); //purposely not implemented
128  void DoOneIterationOfFilter(InputMainImageType* inGrey, OutputImageType* inMask, OutputImageType *out);
129 
130  PixelType1 m_InValue;
131  PixelType1 m_OutValue;
132  unsigned int m_NumberOfIterations;
133 
134  // This is a member variable, so we don't repeatedly create/destroy the memory if the main filter is called repeatedly.
135  MaskImageDuplicatorPointer m_TempImage;
136  };
137 
138 }
139 
140 #ifndef ITK_MANUAL_INSTANTIATION
141 #include "itkMIDASBaseConditionalMorphologyFilter.txx"
142 #endif
143 
144 #endif
OutputImageType::SizeType OutputImageSizeType
Definition: itkMIDASBaseConditionalMorphologyFilter.h:65
InputMaskImageRegionType m_Region
Definition: itkMIDASBaseConditionalMorphologyFilter.h:122
itk::ConstNeighborhoodIterator< OutputImageType >::RadiusType OutputImageRadiusType
Definition: itkMIDASBaseConditionalMorphologyFilter.h:67
TInputImage1 InputMaskImageType
Definition: itkMIDASBaseConditionalMorphologyFilter.h:51
OutputImageType::RegionType OutputImageRegionType
Definition: itkMIDASBaseConditionalMorphologyFilter.h:64
OutputImageType::IndexType OutputImageIndexType
Definition: itkMIDASBaseConditionalMorphologyFilter.h:66
TInputImage1::PixelType PixelType1
Definition: itkMIDASBaseConditionalMorphologyFilter.h:42
ImageType::SizeType SizeType
Definition: niftkMakeLapUSProbeBasicModel.cxx:31
TInputImage2::PixelType PixelType2
Definition: itkMIDASBaseConditionalMorphologyFilter.h:48
SmartPointer< const Self > ConstPointer
Definition: itkMIDASBaseConditionalMorphologyFilter.h:39
InputMainImageType::RegionType InputMainImageRegionType
Definition: itkMIDASBaseConditionalMorphologyFilter.h:60
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: glew.h:4052
ImageToImageFilter< TInputImage1, TOutputImage > SuperClass
Definition: itkMIDASBaseConditionalMorphologyFilter.h:37
InputMaskImageType::IndexType InputMaskImageIndexType
Definition: itkMIDASBaseConditionalMorphologyFilter.h:55
Definition: niftkITKAffineResampleImage.cxx:74
ImageType::IndexType IndexType
Definition: niftkMakeLapUSProbeBasicModel.cxx:32
virtual void BeforeFilter()
Definition: itkMIDASBaseConditionalMorphologyFilter.h:107
GLuint in
Definition: glew.h:10220
Base class for MIDASConditionalErosionFilter and MIDASConditionalDilationFilter.
Definition: itkMIDASBaseConditionalMorphologyFilter.h:32
virtual ~MIDASBaseConditionalMorphologyFilter()
Definition: itkMIDASBaseConditionalMorphologyFilter.h:97
bool m_UserSetRegion
Definition: itkMIDASBaseConditionalMorphologyFilter.h:123
virtual void AfterIteration()
Definition: itkMIDASBaseConditionalMorphologyFilter.h:116
float PixelType
Definition: niftkBreastDCEandADC.cxx:88
virtual void AfterFilter()
Definition: itkMIDASBaseConditionalMorphologyFilter.h:110
ImageType::RegionType RegionType
Definition: niftkMakeLapUSProbeBasicModel.cxx:30
void SetRegion(InputMaskImageRegionType region)
Definition: itkMIDASBaseConditionalMorphologyFilter.h:74
InputMainImageType::Pointer InputMainImagePointer
Definition: itkMIDASBaseConditionalMorphologyFilter.h:58
InputMaskImageType::Pointer InputMaskImagePointer
Definition: itkMIDASBaseConditionalMorphologyFilter.h:52
SmartPointer< Self > Pointer
Definition: itkMIDASBaseConditionalMorphologyFilter.h:38
InputMaskImageRegionType GetRegion() const
Definition: itkMIDASBaseConditionalMorphologyFilter.h:75
MaskImageDuplicatorType::Pointer MaskImageDuplicatorPointer
Definition: itkMIDASBaseConditionalMorphologyFilter.h:71
virtual void BeforeIteration()
Definition: itkMIDASBaseConditionalMorphologyFilter.h:113
GLsizeiptr size
Definition: glew.h:1665
OutputImageType::Pointer OutputImagePointer
Definition: itkMIDASBaseConditionalMorphologyFilter.h:63
InputMaskImageType::RegionType InputMaskImageRegionType
Definition: itkMIDASBaseConditionalMorphologyFilter.h:54
TOutputImage OutputImageType
Definition: itkMIDASBaseConditionalMorphologyFilter.h:62
MIDASBaseConditionalMorphologyFilter Self
Definition: itkMIDASBaseConditionalMorphologyFilter.h:36
TInputImage2 InputMainImageType
Definition: itkMIDASBaseConditionalMorphologyFilter.h:57
InputMainImageType::SizeType InputMainImageSizeType
Definition: itkMIDASBaseConditionalMorphologyFilter.h:59
itk::ImageDuplicator< OutputImageType > MaskImageDuplicatorType
Definition: itkMIDASBaseConditionalMorphologyFilter.h:70
InputMaskImageType::SizeType InputMaskImageSizeType
Definition: itkMIDASBaseConditionalMorphologyFilter.h:53