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"
29 #include "itkStatisticsImageFilter.h"
33 //--------------------------------------------------------------------
35 Extract bony anatomy through thresholding and connected component labelling.
37 //--------------------------------------------------------------------
39 template <class TInputImageType, class TOutputImageType>
40 class ITK_EXPORT ExtractBonesFilter:
41 public clitk::FilterBase,
42 public itk::ImageToImageFilter<TInputImageType, TOutputImageType>
46 /** Standard class typedefs. */
47 typedef ExtractBonesFilter Self;
48 typedef itk::ImageToImageFilter<TInputImageType, TOutputImageType> Superclass;
49 typedef itk::SmartPointer<Self> Pointer;
50 typedef itk::SmartPointer<const Self> ConstPointer;
52 /** Method for creation through the object factory. */
55 /** Run-time type information (and related methods). */
56 itkTypeMacro(ExtractBonesFilter, ImageToImageFilter);
59 /** Some convenient typedefs */
60 typedef TInputImageType InputImageType;
61 typedef typename InputImageType::ConstPointer InputImageConstPointer;
62 typedef typename InputImageType::Pointer InputImagePointer;
63 typedef typename InputImageType::RegionType InputImageRegionType;
64 typedef typename InputImageType::PixelType InputImagePixelType;
65 typedef typename InputImageType::SizeType InputImageSizeType;
66 typedef typename InputImageType::IndexType InputImageIndexType;
68 typedef TOutputImageType OutputImageType;
69 typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
70 typedef typename OutputImageType::Pointer OutputImagePointer;
71 typedef typename OutputImageType::RegionType OutputImageRegionType;
72 typedef typename OutputImageType::PixelType OutputImagePixelType;
73 typedef typename OutputImageType::SizeType OutputImageSizeType;
74 typedef typename OutputImageType::IndexType OutputImageIndexType;
76 itkStaticConstMacro(ImageDimension, unsigned int, InputImageType::ImageDimension);
77 typedef int InternalPixelType;
78 typedef itk::Image<InternalPixelType, InputImageType::ImageDimension> InternalImageType;
79 typedef typename InternalImageType::Pointer InternalImagePointer;
80 typedef typename InternalImageType::IndexType InternalIndexType;
81 typedef LabelizeParameters<InternalPixelType> LabelParamType;
84 void SetInput(const InputImageType * image);
86 // Set all options at a time
87 template<class ArgsInfoType>
88 void SetArgsInfo(ArgsInfoType arg);
90 // Background / Foreground
91 itkGetConstMacro(BackgroundValue, OutputImagePixelType);
92 itkGetConstMacro(ForegroundValue, OutputImagePixelType);
94 itkSetMacro(MinimalComponentSize, int);
95 itkGetConstMacro(MinimalComponentSize, int);
96 GGO_DefineOption(minSize, SetMinimalComponentSize, int);
99 itkBooleanMacro(InitialSmoothing);
100 itkSetMacro(InitialSmoothing, bool);
101 itkGetMacro(InitialSmoothing, bool);
102 GGO_DefineOption_Flag(smooth, SetInitialSmoothing);
104 itkSetMacro(SmoothingConductanceParameter, double);
105 itkGetConstMacro(SmoothingConductanceParameter, double);
106 GGO_DefineOption(cond, SetSmoothingConductanceParameter, double);
108 itkSetMacro(SmoothingNumberOfIterations, int);
109 itkGetConstMacro(SmoothingNumberOfIterations, int);
110 GGO_DefineOption(iter, SetSmoothingNumberOfIterations, int);
112 itkSetMacro(SmoothingTimeStep, double);
113 itkGetConstMacro(SmoothingTimeStep, double);
114 GGO_DefineOption(time, SetSmoothingTimeStep, double);
116 itkSetMacro(SmoothingUseImageSpacing, bool);
117 itkGetConstMacro(SmoothingUseImageSpacing, bool);
118 itkBooleanMacro(SmoothingUseImageSpacing);
119 GGO_DefineOption_Flag(spacing, SetSmoothingUseImageSpacing);
122 itkSetMacro(UpperThreshold1, InputImagePixelType);
123 itkGetMacro(UpperThreshold1, InputImagePixelType);
124 GGO_DefineOption(upper1, SetUpperThreshold1, InputImagePixelType);
126 itkSetMacro(LowerThreshold1, InputImagePixelType);
127 itkGetMacro(LowerThreshold1, InputImagePixelType);
128 GGO_DefineOption(lower1, SetLowerThreshold1, InputImagePixelType);
130 itkSetMacro(FullConnectivity, bool);
131 itkGetConstMacro(FullConnectivity, bool);
132 itkBooleanMacro(FullConnectivity);
133 GGO_DefineOption_Flag(full, SetFullConnectivity);
136 itkSetMacro(UpperThreshold2, InputImagePixelType);
137 itkGetMacro(UpperThreshold2, InputImagePixelType);
138 GGO_DefineOption(upper2, SetUpperThreshold2, InputImagePixelType);
140 itkSetMacro(LowerThreshold2, InputImagePixelType);
141 itkGetMacro(LowerThreshold2, InputImagePixelType);
142 GGO_DefineOption(lower2, SetLowerThreshold2, InputImagePixelType);
144 itkSetMacro(Radius2, InputImageSizeType);
145 itkGetConstMacro(Radius2, InputImageSizeType);
146 GGO_DefineOption_Vector(radius2, SetRadius2, InputImageSizeType, ImageDimension, true);
148 itkSetMacro(SampleRate2, int);
149 itkGetConstMacro(SampleRate2, int);
150 GGO_DefineOption(sampleRate2, SetSampleRate2, int);
153 itkSetMacro(AutoCrop, bool);
154 itkGetConstMacro(AutoCrop, bool);
155 itkBooleanMacro(AutoCrop);
156 GGO_DefineOption_Flag(autoCrop, SetAutoCrop);
159 ExtractBonesFilter();
160 virtual ~ExtractBonesFilter() {}
163 itkSetMacro(BackgroundValue, OutputImagePixelType);
164 itkSetMacro(ForegroundValue, OutputImagePixelType);
165 OutputImagePixelType m_BackgroundValue;
166 OutputImagePixelType m_ForegroundValue;
169 // Step 0 : Initial Filtering
170 bool m_InitialSmoothing;
171 double m_SmoothingConductanceParameter;
172 int m_SmoothingNumberOfIterations;
173 double m_SmoothingTimeStep;
174 bool m_SmoothingUseImageSpacing;
177 InputImagePixelType m_UpperThreshold1;
178 InputImagePixelType m_LowerThreshold1;
179 int m_MinimalComponentSize;
180 bool m_FullConnectivity;
183 InputImagePixelType m_UpperThreshold2;
184 InputImagePixelType m_LowerThreshold2;
185 InputImageSizeType m_Radius2;
188 virtual void GenerateOutputInformation();
189 virtual void GenerateData();
195 void RemoveTrachea();
196 void BonesSeparation();
197 InputImageConstPointer input;
198 InputImagePointer filtered_input;
199 OutputImageConstPointer patient;
200 InputImagePointer working_input;
201 typename InternalImageType::Pointer working_image;
202 typename InternalImageType::Pointer trachea;
203 typename InternalImageType::Pointer output;
206 ExtractBonesFilter(const Self&); //purposely not implemented
207 void operator=(const Self&); //purposely not implemented
210 //--------------------------------------------------------------------
212 } // end namespace clitk
213 //--------------------------------------------------------------------
215 #ifndef ITK_MANUAL_INSTANTIATION
216 #include "clitkExtractBonesFilter.txx"