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://oncora1.lyon.fnclcc.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 CLITKEXTRACTBONESSFILTER_H
20 #define CLITKEXTRACTBONESSFILTER_H
23 #include "clitkFilterBase.h"
24 #include "clitkDecomposeAndReconstructImageFilter.h"
25 #include "clitkExplosionControlledThresholdConnectedImageFilter.h"
26 #include "clitkSegmentationUtils.h"
27 #include "clitkFilterWithAnatomicalFeatureDatabaseManagement.h"
30 #include "itkStatisticsImageFilter.h"
34 //--------------------------------------------------------------------
36 Extract bony anatomy through thresholding and connected component labelling.
38 //--------------------------------------------------------------------
40 template <class TInputImageType>
41 class ITK_EXPORT ExtractBonesFilter:
42 public virtual clitk::FilterBase,
43 public clitk::FilterWithAnatomicalFeatureDatabaseManagement,
44 public itk::ImageToImageFilter<TInputImageType,
45 itk::Image<uchar, TInputImageType::ImageDimension> >
49 /** Standard class typedefs. */
50 typedef itk::Image<uchar, TInputImageType::ImageDimension> MaskImageType;
51 typedef ExtractBonesFilter Self;
52 typedef itk::ImageToImageFilter<TInputImageType, MaskImageType> Superclass;
53 typedef itk::SmartPointer<Self> Pointer;
54 typedef itk::SmartPointer<const Self> ConstPointer;
56 /** Method for creation through the object factory. */
59 /** Run-time type information (and related methods). */
60 itkTypeMacro(ExtractBonesFilter, ImageToImageFilter);
63 /** Some convenient typedefs */
64 typedef TInputImageType InputImageType;
65 typedef typename InputImageType::ConstPointer InputImageConstPointer;
66 typedef typename InputImageType::Pointer InputImagePointer;
67 typedef typename InputImageType::RegionType InputImageRegionType;
68 typedef typename InputImageType::PixelType InputImagePixelType;
69 typedef typename InputImageType::SizeType InputImageSizeType;
70 typedef typename InputImageType::IndexType InputImageIndexType;
72 typedef typename MaskImageType::ConstPointer MaskImageConstPointer;
73 typedef typename MaskImageType::Pointer MaskImagePointer;
74 typedef typename MaskImageType::RegionType MaskImageRegionType;
75 typedef typename MaskImageType::PixelType MaskImagePixelType;
76 typedef typename MaskImageType::SizeType MaskImageSizeType;
77 typedef typename MaskImageType::IndexType MaskImageIndexType;
79 itkStaticConstMacro(ImageDimension, unsigned int, InputImageType::ImageDimension);
80 typedef int InternalPixelType;
81 typedef itk::Image<InternalPixelType, InputImageType::ImageDimension> InternalImageType;
82 typedef typename InternalImageType::Pointer InternalImagePointer;
83 typedef typename InternalImageType::IndexType InternalIndexType;
84 typedef LabelizeParameters<InternalPixelType> LabelParamType;
87 void SetInput(const InputImageType * image);
89 // Set all options at a time
90 template<class ArgsInfoType>
91 void SetArgsInfo(ArgsInfoType arg);
93 // Background / Foreground
94 itkGetConstMacro(BackgroundValue, MaskImagePixelType);
95 itkGetConstMacro(ForegroundValue, MaskImagePixelType);
97 itkSetMacro(MinimalComponentSize, int);
98 itkGetConstMacro(MinimalComponentSize, int);
99 GGO_DefineOption(minSize, SetMinimalComponentSize, int);
101 // Output filename (for AFBD)
102 itkSetMacro(OutputBonesFilename, std::string);
103 itkGetMacro(OutputBonesFilename, std::string);
104 GGO_DefineOption(output, SetOutputBonesFilename, std::string);
107 itkBooleanMacro(InitialSmoothing);
108 itkSetMacro(InitialSmoothing, bool);
109 itkGetMacro(InitialSmoothing, bool);
110 GGO_DefineOption_Flag(smooth, SetInitialSmoothing);
112 itkSetMacro(SmoothingConductanceParameter, double);
113 itkGetConstMacro(SmoothingConductanceParameter, double);
114 GGO_DefineOption(cond, SetSmoothingConductanceParameter, double);
116 itkSetMacro(SmoothingNumberOfIterations, int);
117 itkGetConstMacro(SmoothingNumberOfIterations, int);
118 GGO_DefineOption(iter, SetSmoothingNumberOfIterations, int);
120 itkSetMacro(SmoothingTimeStep, double);
121 itkGetConstMacro(SmoothingTimeStep, double);
122 GGO_DefineOption(time, SetSmoothingTimeStep, double);
124 itkSetMacro(SmoothingUseImageSpacing, bool);
125 itkGetConstMacro(SmoothingUseImageSpacing, bool);
126 itkBooleanMacro(SmoothingUseImageSpacing);
127 GGO_DefineOption_Flag(spacing, SetSmoothingUseImageSpacing);
130 itkSetMacro(UpperThreshold1, InputImagePixelType);
131 itkGetMacro(UpperThreshold1, InputImagePixelType);
132 GGO_DefineOption(upper1, SetUpperThreshold1, InputImagePixelType);
134 itkSetMacro(LowerThreshold1, InputImagePixelType);
135 itkGetMacro(LowerThreshold1, InputImagePixelType);
136 GGO_DefineOption(lower1, SetLowerThreshold1, InputImagePixelType);
138 itkSetMacro(FullConnectivity, bool);
139 itkGetConstMacro(FullConnectivity, bool);
140 itkBooleanMacro(FullConnectivity);
141 GGO_DefineOption_Flag(full, SetFullConnectivity);
144 itkSetMacro(UpperThreshold2, InputImagePixelType);
145 itkGetMacro(UpperThreshold2, InputImagePixelType);
146 GGO_DefineOption(upper2, SetUpperThreshold2, InputImagePixelType);
148 itkSetMacro(LowerThreshold2, InputImagePixelType);
149 itkGetMacro(LowerThreshold2, InputImagePixelType);
150 GGO_DefineOption(lower2, SetLowerThreshold2, InputImagePixelType);
152 itkSetMacro(Radius2, InputImageSizeType);
153 itkGetConstMacro(Radius2, InputImageSizeType);
154 GGO_DefineOption_Vector(radius2, SetRadius2, InputImageSizeType, ImageDimension, true);
156 itkSetMacro(SampleRate2, int);
157 itkGetConstMacro(SampleRate2, int);
158 GGO_DefineOption(sampleRate2, SetSampleRate2, int);
161 itkSetMacro(AutoCrop, bool);
162 itkGetConstMacro(AutoCrop, bool);
163 itkBooleanMacro(AutoCrop);
164 GGO_DefineOption_Flag(noAutoCrop, SetAutoCrop);
167 ExtractBonesFilter();
168 virtual ~ExtractBonesFilter() {}
171 itkSetMacro(BackgroundValue, MaskImagePixelType);
172 itkSetMacro(ForegroundValue, MaskImagePixelType);
173 MaskImagePixelType m_BackgroundValue;
174 MaskImagePixelType m_ForegroundValue;
177 // Step 0 : Initial Filtering
178 bool m_InitialSmoothing;
179 double m_SmoothingConductanceParameter;
180 int m_SmoothingNumberOfIterations;
181 double m_SmoothingTimeStep;
182 bool m_SmoothingUseImageSpacing;
185 InputImagePixelType m_UpperThreshold1;
186 InputImagePixelType m_LowerThreshold1;
187 int m_MinimalComponentSize;
188 bool m_FullConnectivity;
191 InputImagePixelType m_UpperThreshold2;
192 InputImagePixelType m_LowerThreshold2;
193 InputImageSizeType m_Radius2;
196 virtual void GenerateOutputInformation();
197 virtual void GenerateData();
203 void RemoveTrachea();
204 void BonesSeparation();
205 std::string m_OutputBonesFilename;
206 InputImageConstPointer input;
207 InputImagePointer filtered_input;
208 MaskImageConstPointer patient;
209 InputImagePointer working_input;
210 typename InternalImageType::Pointer working_image;
211 typename InternalImageType::Pointer trachea;
212 typename InternalImageType::Pointer output;
215 ExtractBonesFilter(const Self&); //purposely not implemented
216 void operator=(const Self&); //purposely not implemented
219 //--------------------------------------------------------------------
221 } // end namespace clitk
222 //--------------------------------------------------------------------
224 #ifndef ITK_MANUAL_INSTANTIATION
225 #include "clitkExtractBonesFilter.txx"