1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
19 #ifndef CLITKEXTRACTPATIENTFILTER_H
20 #define CLITKEXTRACTPATIENTFILTER_H
22 #include "clitkFilterBase.h"
23 #include "clitkFilterWithAnatomicalFeatureDatabaseManagement.h"
27 //--------------------------------------------------------------------
29 Try to extract the Patient part of a thorax CT.
31 Prefer high resolution input and resample (NN) output at the end
32 (like). Input is binarized using initial thresholds, connected
33 components are labeled (firstLabel). The air label (1) is
34 removed. The remaining is binarized and relabeled, patient should
35 now be the principal label (secondLabel). Two mechanismes are
36 provided to influence the label images. Crop to reduce
37 connectivity (image is restored to original size), eg for
38 SBF. Decomposition through ersion and reconstruction through
39 dilation (slow), eg for Pulmo bellows. Choose which labels to keep
40 from second Label image. Final mask is cleaned by opening and
44 //--------------------------------------------------------------------
46 template <class TInputImageType>
47 class ITK_EXPORT ExtractPatientFilter:
48 public virtual clitk::FilterBase,
49 public clitk::FilterWithAnatomicalFeatureDatabaseManagement,
50 public itk::ImageToImageFilter<TInputImageType,
51 itk::Image<uchar, TInputImageType::ImageDimension> >
54 /** Standard class typedefs. */
55 typedef itk::Image<uchar, TInputImageType::ImageDimension> MaskImageType;
56 typedef ExtractPatientFilter Self;
57 typedef itk::ImageToImageFilter<TInputImageType, MaskImageType> Superclass;
58 typedef itk::SmartPointer<Self> Pointer;
59 typedef itk::SmartPointer<const Self> ConstPointer;
61 /** Method for creation through the object factory. */
64 /** Run-time type information (and related methods). */
65 itkTypeMacro(ExtractPatientFilter, ImageToImageFilter);
68 /** Some convenient typedefs. */
69 typedef TInputImageType InputImageType;
70 typedef typename InputImageType::ConstPointer InputImageConstPointer;
71 typedef typename InputImageType::Pointer InputImagePointer;
72 typedef typename InputImageType::RegionType InputImageRegionType;
73 typedef typename InputImageType::PixelType InputImagePixelType;
74 typedef typename InputImageType::SizeType InputImageSizeType;
75 typedef typename InputImageType::IndexType InputImageIndexType;
77 typedef typename MaskImageType::ConstPointer MaskImageConstPointer;
78 typedef typename MaskImageType::Pointer MaskImagePointer;
79 typedef typename MaskImageType::RegionType MaskImageRegionType;
80 typedef typename MaskImageType::PixelType MaskImagePixelType;
81 typedef typename MaskImageType::SizeType MaskImageSizeType;
82 typedef typename MaskImageType::IndexType MaskImageIndexType;
84 itkStaticConstMacro(ImageDimension, unsigned int, InputImageType::ImageDimension);
85 typedef int InternalPixelType;
86 typedef itk::Image<InternalPixelType, ImageDimension> InternalImageType;
87 typedef typename InternalImageType::SizeType InternalImageSizeType;
90 void SetInput(const TInputImageType * image);
91 itkSetMacro(OutputPatientFilename, std::string);
92 itkGetMacro(OutputPatientFilename, std::string);
95 itkSetMacro(UpperThreshold, InputImagePixelType);
96 itkGetMacro(UpperThreshold, InputImagePixelType);
98 itkSetMacro(LowerThreshold, InputImagePixelType);
99 itkGetMacro(LowerThreshold, InputImagePixelType);
100 itkSetMacro(UseLowerThreshold, bool);
101 itkGetConstMacro(UseLowerThreshold, bool);
102 itkBooleanMacro(UseLowerThreshold);
105 itkSetMacro(DecomposeAndReconstructDuringFirstStep, bool);
106 itkGetConstMacro(DecomposeAndReconstructDuringFirstStep, bool);
107 itkBooleanMacro(DecomposeAndReconstructDuringFirstStep);
109 itkSetMacro(Radius1, InternalImageSizeType);
110 itkGetConstMacro(Radius1, InternalImageSizeType);
112 itkSetMacro(MaximumNumberOfLabels1, int);
113 itkGetConstMacro(MaximumNumberOfLabels1, int);
115 itkSetMacro(NumberOfNewLabels1, int);
116 itkGetConstMacro(NumberOfNewLabels1, int);
119 itkSetMacro(DecomposeAndReconstructDuringSecondStep, bool);
120 itkGetConstMacro(DecomposeAndReconstructDuringSecondStep, bool);
121 itkBooleanMacro(DecomposeAndReconstructDuringSecondStep);
123 itkSetMacro(Radius2, InternalImageSizeType);
124 itkGetConstMacro(Radius2, InternalImageSizeType);
126 itkSetMacro(MaximumNumberOfLabels2, int);
127 itkGetConstMacro(MaximumNumberOfLabels2, int);
129 itkSetMacro(NumberOfNewLabels2, int);
130 itkGetConstMacro(NumberOfNewLabels2, int);
133 itkSetMacro(FirstKeep, int);
134 itkGetConstMacro(FirstKeep, int);
136 itkSetMacro(LastKeep, int);
137 itkGetConstMacro(LastKeep, int);
140 itkSetMacro(FinalOpenClose, bool);
141 itkGetConstMacro(FinalOpenClose, bool);
142 itkBooleanMacro(FinalOpenClose);
145 itkSetMacro(AutoCrop, bool);
146 itkGetConstMacro(AutoCrop, bool);
147 itkBooleanMacro(AutoCrop);
150 ExtractPatientFilter();
151 virtual ~ExtractPatientFilter() {}
153 itkSetMacro(BackgroundValue, MaskImagePixelType);
154 itkSetMacro(ForegroundValue, MaskImagePixelType);
155 itkGetConstMacro(BackgroundValue, MaskImagePixelType);
156 itkGetConstMacro(ForegroundValue, MaskImagePixelType);
157 MaskImagePixelType m_BackgroundValue;
158 MaskImagePixelType m_ForegroundValue;
160 std::string m_OutputPatientFilename;
161 InputImagePixelType m_UpperThreshold;
162 InputImagePixelType m_LowerThreshold;
163 bool m_UseLowerThreshold;
164 bool m_DecomposeAndReconstructDuringFirstStep;
165 bool m_DecomposeAndReconstructDuringSecondStep;
166 bool m_FinalOpenClose;
167 InternalImageSizeType m_Radius1;
168 InternalImageSizeType m_Radius2;
169 int m_MaximumNumberOfLabels1;
170 int m_MaximumNumberOfLabels2;
171 int m_NumberOfNewLabels1;
172 int m_NumberOfNewLabels2;
177 virtual void GenerateOutputInformation();
178 virtual void GenerateData();
180 InputImageConstPointer input;
181 MaskImagePointer output;
182 typename InternalImageType::Pointer working_image;
185 ExtractPatientFilter(const Self&); //purposely not implemented
186 void operator=(const Self&); //purposely not implemented
189 //--------------------------------------------------------------------
191 } // end namespace clitk
192 //--------------------------------------------------------------------
194 #ifndef ITK_MANUAL_INSTANTIATION
195 #include "clitkExtractPatientFilter.txx"