NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
itkMIDASRegionGrowingImageFilter.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 itkMIDASRegionGrowingImageFilter_h
16 #define itkMIDASRegionGrowingImageFilter_h
17 
18 #include <stack>
19 #include <cassert>
20 #include <itkImage.h>
21 #include <itkImageToImageFilter.h>
22 #include <itkImageRegionConstIteratorWithIndex.h>
23 #include <itkPolyLineParametricPath.h>
24 #include <itkContinuousIndex.h>
25 
26 namespace itk {
27 
32 template <class TInputImage, class TOutputImage, class TPointSet>
33 class ITK_EXPORT MIDASRegionGrowingImageFilter : public ImageToImageFilter<TInputImage, TOutputImage> {
34 
35 public:
37  typedef SmartPointer<const Self> ConstPointer;
38  typedef SmartPointer<Self> Pointer;
39  typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
40 
42  itkNewMacro(Self);
43 
45  itkTypeMacro(MIDASRegionGrowingImageFilter, ImageToImageFilter );
46 
47  typedef TInputImage InputImageType;
49  typedef TOutputImage OutputImageType;
53  typedef typename OutputImageType::Pointer OutputImagePointerType;
54  typedef typename OutputImageType::ConstPointer OutputImageConstPointerType;
56  typedef TPointSet PointSetType;
57 
58  typedef itk::ContinuousIndex<double,TInputImage::ImageDimension> ContinuousIndexType;
59  typedef itk::PolyLineParametricPath<TInputImage::ImageDimension> ParametricPathType;
60 
61  typedef typename ParametricPathType::Pointer ParametricPathPointer;
62  typedef std::vector<ParametricPathPointer> ParametricPathVectorType;
63  typedef typename ParametricPathType::VertexListType ParametricPathVertexListType;
64  typedef typename ParametricPathType::VertexType ParametricPathVertexType;
65 
69  itkSetMacro(LowerThreshold, InputPixelType);
70  itkGetConstMacro(LowerThreshold, InputPixelType);
71 
75  itkSetMacro(UpperThreshold, InputPixelType);
76  itkGetConstMacro(UpperThreshold, InputPixelType);
77 
81  itkSetMacro(ForegroundValue, OutputPixelType);
82  itkGetConstMacro(ForegroundValue, OutputPixelType);
83 
87  itkSetMacro(BackgroundValue, OutputPixelType);
88  itkGetConstMacro(BackgroundValue, OutputPixelType);
89 
93  itkSetMacro(RegionOfInterest, OutputImageRegionType);
94  itkGetConstMacro(RegionOfInterest, OutputImageRegionType);
95 
99  itkSetMacro(UseRegionOfInterest, bool);
100  itkGetConstMacro(UseRegionOfInterest, bool);
101 
107  itkSetMacro(ProjectSeedsIntoRegion, bool);
108  itkGetConstMacro(ProjectSeedsIntoRegion, bool);
109 
110  itkSetMacro(MaximumSeedProjectionDistanceInVoxels, unsigned int);
111  itkGetMacro(MaximumSeedProjectionDistanceInVoxels, unsigned int);
112 
113  itkSetMacro(SegmentationContourImageInsideValue, OutputPixelType);
114  itkGetConstMacro(SegmentationContourImageInsideValue, OutputPixelType);
115 
116  itkSetMacro(SegmentationContourImageBorderValue, OutputPixelType);
117  itkGetConstMacro(SegmentationContourImageBorderValue, OutputPixelType);
118 
119  itkSetMacro(SegmentationContourImageOutsideValue, OutputPixelType);
120  itkGetConstMacro(SegmentationContourImageOutsideValue, OutputPixelType);
121 
122  itkSetMacro(ManualContourImageBorderValue, OutputPixelType);
123  itkGetConstMacro(ManualContourImageBorderValue, OutputPixelType);
124 
135  itkSetMacro(EraseFullSlice, bool);
136  itkGetConstMacro(EraseFullSlice, bool);
137 
138  itkSetMacro(PropMask, OutputImageIndexType);
139  itkGetConstMacro(PropMask, OutputImageIndexType);
140 
141  itkSetMacro(UsePropMaskMode, bool);
142  itkGetConstMacro(UsePropMaskMode, bool);
143 
147  void SetManualContours(ParametricPathVectorType* contours);
148 
152  const PointSetType& GetSeedPoints(void) const
153  {
154  return *mspc_SeedPoints;
155  }
156 
160  void SetSeedPoints(const PointSetType &seeds)
161  {
162  mspc_SeedPoints = &seeds;
163  this->Modified();
164  }
165 
169  const OutputImageType* GetSegmentationContourImage(void) const
170  {
171  return m_SegmentationContourImage;
172  }
173 
182  itkSetObjectMacro(SegmentationContourImage, OutputImageType);
183 
187  const OutputImageType* GetManualContourImage(void) const
188  {
189  return m_ManualContourImage;
190  }
191 
204  itkSetObjectMacro(ManualContourImage, OutputImageType);
205 
206 protected:
207 
208  MIDASRegionGrowingImageFilter(); // purposely hidden
209  virtual ~MIDASRegionGrowingImageFilter(void) {} // purposely hidden
210 
211  virtual void GenerateData(void);
212 
213  virtual void ThreadedGenerateData(const typename OutputImageType::RegionType &outputRegionForThread, ThreadIdType threadId) {
214  std::cerr << "Not supported.\n";
215  abort();
216  }
217 
218 private:
219 
220  MIDASRegionGrowingImageFilter(const Self&); // purposely not implemented
221  void operator=(const Self&); // purposely not implemented
222 
230  void ConditionalAddPixel(
231  std::stack<typename OutputImageType::IndexType> &r_stack,
232  const typename OutputImageType::IndexType &currentImgIdx,
233  const typename OutputImageType::IndexType &nextImgIdx,
234  const bool &isFullyConnected
235  );
236 
241  bool IsFullyConnected(
242  const typename OutputImageType::IndexType &index1,
243  const typename OutputImageType::IndexType &index2
244  );
245 
253  bool IsCrossingLine(
254  const ParametricPathVectorType* contours,
255  const typename OutputImageType::IndexType &index1,
256  const typename OutputImageType::IndexType &index2
257  );
258 
259  InputPixelType m_LowerThreshold;
260  InputPixelType m_UpperThreshold;
261  OutputPixelType m_ForegroundValue;
262  OutputPixelType m_BackgroundValue;
263  typename PointSetType::ConstPointer mspc_SeedPoints;
264  OutputImageRegionType m_RegionOfInterest;
265  bool m_UseRegionOfInterest;
266  bool m_ProjectSeedsIntoRegion;
267  unsigned int m_MaximumSeedProjectionDistanceInVoxels;
268  typename OutputImageType::ConstPointer m_SegmentationContourImage;
269  OutputPixelType m_SegmentationContourImageInsideValue;
270  OutputPixelType m_SegmentationContourImageBorderValue;
271  OutputPixelType m_SegmentationContourImageOutsideValue;
272  typename OutputImageType::ConstPointer m_ManualContourImage;
273  OutputPixelType m_ManualContourImageBorderValue;
274  OutputPixelType m_ManualContourImageNonBorderValue;
275  ParametricPathVectorType* m_ManualContours;
276  bool m_EraseFullSlice;
277  OutputImageIndexType m_PropMask;
278  bool m_UsePropMaskMode;
279 };
280 
281 #ifndef ITK_MANUAL_INSTANTIATION
282 #include "itkMIDASRegionGrowingImageFilter.txx"
283 #endif
284 
285 }
286 
287 #endif
OutputImageType::IndexType OutputImageIndexType
Definition: itkMIDASRegionGrowingImageFilter.h:52
TInputImage InputImageType
Definition: itkMIDASRegionGrowingImageFilter.h:45
ImageType::SizeType SizeType
Definition: niftkMakeLapUSProbeBasicModel.cxx:31
OutputImageType::SizeType OutputImageSizeType
Definition: itkMIDASRegionGrowingImageFilter.h:51
SmartPointer< Self > Pointer
Definition: itkMIDASRegionGrowingImageFilter.h:38
MIDASRegionGrowingImageFilter Self
Definition: itkMIDASRegionGrowingImageFilter.h:36
void SetSeedPoints(const PointSetType &seeds)
Set the seeds, as region growing starts from each seed point.
Definition: itkMIDASRegionGrowingImageFilter.h:160
OutputImageType::Pointer OutputImagePointerType
Definition: itkMIDASRegionGrowingImageFilter.h:53
SmartPointer< const Self > ConstPointer
Definition: itkMIDASRegionGrowingImageFilter.h:37
TOutputImage OutputImageType
Definition: itkMIDASRegionGrowingImageFilter.h:49
Definition: niftkITKAffineResampleImage.cxx:74
ImageType::IndexType IndexType
Definition: niftkMakeLapUSProbeBasicModel.cxx:32
OutputImageType::ConstPointer OutputImageConstPointerType
Definition: itkMIDASRegionGrowingImageFilter.h:54
const OutputImageType * GetManualContourImage(void) const
Retrieve the "manual" contour image.
Definition: itkMIDASRegionGrowingImageFilter.h:187
ImageToImageFilter< TInputImage, TOutputImage > Superclass
Definition: itkMIDASRegionGrowingImageFilter.h:39
InputImageType::PixelType InputPixelType
Definition: itkMIDASRegionGrowingImageFilter.h:48
const PointSetType & GetSeedPoints(void) const
Retrieve the seeds.
Definition: itkMIDASRegionGrowingImageFilter.h:152
ParametricPathType::VertexType ParametricPathVertexType
Definition: itkMIDASRegionGrowingImageFilter.h:64
itk::ContinuousIndex< double, TInputImage::ImageDimension > ContinuousIndexType
Definition: itkMIDASRegionGrowingImageFilter.h:58
TPointSet PointSetType
Definition: itkMIDASRegionGrowingImageFilter.h:56
float PixelType
Definition: niftkBreastDCEandADC.cxx:88
OutputImageType::RegionType OutputImageRegionType
Definition: itkMIDASRegionGrowingImageFilter.h:50
ImageType::RegionType RegionType
Definition: niftkMakeLapUSProbeBasicModel.cxx:30
const OutputImageType * GetSegmentationContourImage(void) const
Retrieve the contour image.
Definition: itkMIDASRegionGrowingImageFilter.h:169
virtual void ThreadedGenerateData(const typename OutputImageType::RegionType &outputRegionForThread, ThreadIdType threadId)
Definition: itkMIDASRegionGrowingImageFilter.h:213
OutputImageType::PixelType OutputPixelType
Definition: itkMIDASRegionGrowingImageFilter.h:55
std::vector< ParametricPathPointer > ParametricPathVectorType
Definition: itkMIDASRegionGrowingImageFilter.h:62
ParametricPathType::Pointer ParametricPathPointer
Definition: itkMIDASRegionGrowingImageFilter.h:61
virtual ~MIDASRegionGrowingImageFilter(void)
Definition: itkMIDASRegionGrowingImageFilter.h:209
itk::PolyLineParametricPath< TInputImage::ImageDimension > ParametricPathType
Definition: itkMIDASRegionGrowingImageFilter.h:59
ParametricPathType::VertexListType ParametricPathVertexListType
Definition: itkMIDASRegionGrowingImageFilter.h:63
Implements region growing limited by contours.
Definition: itkMIDASRegionGrowingImageFilter.h:33