Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
itkConnectedAdaptiveThresholdImageFilter.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 #ifndef __itkConnectedAdaptiveThresholdImageFilter_h
17 #define __itkConnectedAdaptiveThresholdImageFilter_h
18 
19 #include "itkConnectedThresholdImageFilter.h"
20 #include "itkImage.h"
21 
22 namespace itk
23 {
30  template <class TInputImage, class TOutputImage>
32  : public ConnectedThresholdImageFilter<TInputImage, TOutputImage>
33  {
34  public:
37  typedef ConnectedThresholdImageFilter<TInputImage, TOutputImage> Superclass;
40 
42  itkFactorylessNewMacro(Self) itkCloneMacro(Self)
43 
45  itkTypeMacro(ConnectedAdaptiveThresholdImageFilter, ConnectedThresholdImageFilter);
46 
47  typedef TInputImage InputImageType;
48  typedef TOutputImage OutputImageType;
49  typedef typename OutputImageType::Pointer OutputImagePointer;
50  typedef typename InputImageType::IndexType IndexType;
51  typedef typename InputImageType::PixelType PixelType;
52 
53  void SetGrowingDirectionIsUpwards(bool upwards) { m_GrowingDirectionIsUpwards = upwards; }
54  /* Switch between fine and raw leakage detection. */
55  void SetFineDetectionMode(bool fine)
56  {
57  m_FineDetectionMode = fine;
58  m_DiscardLastPreview = false;
59  }
60 
61  int GetSeedpointValue(void) { return m_SeedpointValue; }
62  int GetLeakagePoint(void) { return m_DetectedLeakagePoint; }
64 
65  /*
66  * Correct the position of the seed point, only performed if seed point value is outside threshold range
67  * @param sizeOfVolume edge length of the square volume in which the search for a "better" seed is performed
68  */
69  IndexType CorrectSeedPointPosition(unsigned int sizeOfVolume, int lowerTh, int upperTh);
70 
71  /* Sets all voxels in a square volume with the size of @param croppingSize
72  * and the center point equal to @param seedPoint to the value zero.
73  */
74  void CropMask(unsigned int croppingSize);
75 
76  /* Modifies the iterator mask to keep all previous segmentation results in the same mask.
77  * @returnParam largest value in the segmentation mask
78  */
79  unsigned int AdjustIteratorMask();
80 
81  /* Sets parameters needed for adjusting the iterator mask
82  * @param iteratorMaskForFineSegmentation pointer to the image containing the complete segmentation result of one
83  * leaf (inclusively leakage-segmentation)
84  * @param adjLowerTh lower threshold value of the segmentation without leakage-segmentation
85  * @param adjLowerTh upper threshold value of the segmentation without leakage-segmentation
86  * @param discardLeafSegmentation flag if the last segmentation preview ended with a leakage already in the first
87  * step
88  */
89  void SetParameterForFineSegmentation(TOutputImage *iteratorMaskForFineSegmentation,
90  unsigned int adjLowerTh,
91  unsigned int adjUpperTh,
92  itk::Index<3> seedPoint,
93  bool discardLeafSegmentation);
94 
95  TOutputImage *GetResultImage();
96 
97  protected:
100 
101  void GenerateData();
102 
104 
105  private:
106  OutputImagePointer m_OutoutImageMaskFineSegmentation;
107  bool m_GrowingDirectionIsUpwards;
108  PixelType m_SeedpointValue;
109  PixelType m_DetectedLeakagePoint;
110  PixelType m_InitValue;
111  unsigned int m_AdjLowerTh;
112  unsigned int m_AdjUpperTh;
113  itk::Index<3> m_SeedPointIndex;
114 
115  /* Flag for switching between raw segmentation and fine segmentation (Bronchial tree segmentation) */
116  bool m_FineDetectionMode;
117 
118  bool m_DiscardLastPreview;
119  };
120 
121 } // end namespace itk
122 
123 #ifndef ITK_MANUAL_INSTANTIATION
125 #endif
126 
127 #endif
ImageFilter used for processing an image with an adaptive iterator (such as itkAdaptiveThresholdItera...
ConnectedThresholdImageFilter< TInputImage, TOutputImage > Superclass