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 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
39 //--------------------------------------------------------------------
41 template <class TInputImageType>
42 class ITK_EXPORT ExtractBonesFilter:
43 public virtual clitk::FilterBase,
44 public clitk::FilterWithAnatomicalFeatureDatabaseManagement,
45 public itk::ImageToImageFilter<TInputImageType,
46 itk::Image<uchar, TInputImageType::ImageDimension> >
50 /** Standard class typedefs. */
51 typedef itk::Image<uchar, TInputImageType::ImageDimension> MaskImageType;
52 typedef ExtractBonesFilter Self;
53 typedef itk::ImageToImageFilter<TInputImageType, MaskImageType> Superclass;
54 typedef itk::SmartPointer<Self> Pointer;
55 typedef itk::SmartPointer<const Self> ConstPointer;
57 /** Method for creation through the object factory. */
60 /** Run-time type information (and related methods). */
61 itkTypeMacro(ExtractBonesFilter, ImageToImageFilter);
64 /** Some convenient typedefs */
65 typedef TInputImageType InputImageType;
66 typedef typename InputImageType::ConstPointer InputImageConstPointer;
67 typedef typename InputImageType::Pointer InputImagePointer;
68 typedef typename InputImageType::RegionType InputImageRegionType;
69 typedef typename InputImageType::PixelType InputImagePixelType;
70 typedef typename InputImageType::SizeType InputImageSizeType;
71 typedef typename InputImageType::IndexType InputImageIndexType;
73 typedef typename MaskImageType::ConstPointer MaskImageConstPointer;
74 typedef typename MaskImageType::Pointer MaskImagePointer;
75 typedef typename MaskImageType::RegionType MaskImageRegionType;
76 typedef typename MaskImageType::PixelType MaskImagePixelType;
77 typedef typename MaskImageType::SizeType MaskImageSizeType;
78 typedef typename MaskImageType::IndexType MaskImageIndexType;
80 itkStaticConstMacro(ImageDimension, unsigned int, InputImageType::ImageDimension);
81 typedef int InternalPixelType;
82 typedef itk::Image<InternalPixelType, InputImageType::ImageDimension> InternalImageType;
83 typedef typename InternalImageType::Pointer InternalImagePointer;
84 typedef typename InternalImageType::IndexType InternalIndexType;
85 typedef LabelizeParameters<InternalPixelType> LabelParamType;
88 void SetInput(const InputImageType * image);
90 // Background / Foreground
91 itkGetConstMacro(BackgroundValue, MaskImagePixelType);
92 itkGetConstMacro(ForegroundValue, MaskImagePixelType);
94 itkSetMacro(MinimalComponentSize, int);
95 itkGetConstMacro(MinimalComponentSize, int);
97 // Output filename (for AFBD)
98 itkSetMacro(OutputBonesFilename, std::string);
99 itkGetMacro(OutputBonesFilename, std::string);
102 itkBooleanMacro(InitialSmoothing);
103 itkSetMacro(InitialSmoothing, bool);
104 itkGetMacro(InitialSmoothing, bool);
106 itkSetMacro(SmoothingConductanceParameter, double);
107 itkGetConstMacro(SmoothingConductanceParameter, double);
109 itkSetMacro(SmoothingNumberOfIterations, int);
110 itkGetConstMacro(SmoothingNumberOfIterations, int);
112 itkSetMacro(SmoothingTimeStep, double);
113 itkGetConstMacro(SmoothingTimeStep, double);
115 itkSetMacro(SmoothingUseImageSpacing, bool);
116 itkGetConstMacro(SmoothingUseImageSpacing, bool);
117 itkBooleanMacro(SmoothingUseImageSpacing);
120 itkSetMacro(UpperThreshold1, InputImagePixelType);
121 itkGetMacro(UpperThreshold1, InputImagePixelType);
123 itkSetMacro(LowerThreshold1, InputImagePixelType);
124 itkGetMacro(LowerThreshold1, InputImagePixelType);
126 itkSetMacro(FullConnectivity, bool);
127 itkGetConstMacro(FullConnectivity, bool);
128 itkBooleanMacro(FullConnectivity);
131 itkSetMacro(UpperThreshold2, InputImagePixelType);
132 itkGetMacro(UpperThreshold2, InputImagePixelType);
134 itkSetMacro(LowerThreshold2, InputImagePixelType);
135 itkGetMacro(LowerThreshold2, InputImagePixelType);
137 itkSetMacro(Radius2, InputImageSizeType);
138 itkGetConstMacro(Radius2, InputImageSizeType);
140 itkSetMacro(SampleRate2, int);
141 itkGetConstMacro(SampleRate2, int);
144 itkSetMacro(FillHoles, bool);
145 itkGetConstMacro(FillHoles, bool);
146 itkBooleanMacro(FillHoles);
149 itkSetMacro(AutoCrop, bool);
150 itkGetConstMacro(AutoCrop, bool);
151 itkBooleanMacro(AutoCrop);
154 ExtractBonesFilter();
155 virtual ~ExtractBonesFilter() {}
158 itkSetMacro(BackgroundValue, MaskImagePixelType);
159 itkSetMacro(ForegroundValue, MaskImagePixelType);
160 MaskImagePixelType m_BackgroundValue;
161 MaskImagePixelType m_ForegroundValue;
164 // Step 0 : Initial Filtering
165 bool m_InitialSmoothing;
166 double m_SmoothingConductanceParameter;
167 int m_SmoothingNumberOfIterations;
168 double m_SmoothingTimeStep;
169 bool m_SmoothingUseImageSpacing;
172 InputImagePixelType m_UpperThreshold1;
173 InputImagePixelType m_LowerThreshold1;
174 int m_MinimalComponentSize;
175 bool m_FullConnectivity;
178 InputImagePixelType m_UpperThreshold2;
179 InputImagePixelType m_LowerThreshold2;
180 InputImageSizeType m_Radius2;
185 InputImageSizeType m_FillHolesDirections;
187 virtual void GenerateOutputInformation();
188 virtual void GenerateData();
194 void RemoveTrachea();
195 void BonesSeparation();
196 std::string m_OutputBonesFilename;
197 InputImageConstPointer input;
198 InputImagePointer filtered_input;
199 MaskImageConstPointer 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"