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 "clitkSegmentationFunctions.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 itkSetMacro(UpperThreshold1, InputImagePixelType);
100 itkGetMacro(UpperThreshold1, InputImagePixelType);
101 GGO_DefineOption(upper1, SetUpperThreshold1, InputImagePixelType);
103 itkSetMacro(LowerThreshold1, InputImagePixelType);
104 itkGetMacro(LowerThreshold1, InputImagePixelType);
105 GGO_DefineOption(lower1, SetLowerThreshold1, InputImagePixelType);
107 itkSetMacro(FullConnectivity, bool);
108 itkGetConstMacro(FullConnectivity, bool);
109 itkBooleanMacro(FullConnectivity);
110 GGO_DefineOption_Flag(full, SetFullConnectivity);
113 itkSetMacro(UpperThreshold2, InputImagePixelType);
114 itkGetMacro(UpperThreshold2, InputImagePixelType);
115 GGO_DefineOption(upper2, SetUpperThreshold2, InputImagePixelType);
117 itkSetMacro(LowerThreshold2, InputImagePixelType);
118 itkGetMacro(LowerThreshold2, InputImagePixelType);
119 GGO_DefineOption(lower2, SetLowerThreshold2, InputImagePixelType);
121 itkSetMacro(Radius2, InputImageSizeType);
122 itkGetConstMacro(Radius2, InputImageSizeType);
123 GGO_DefineOption_Vector(radius2, SetRadius2, InputImageSizeType, ImageDimension, true);
125 itkSetMacro(SampleRate2, int);
126 itkGetConstMacro(SampleRate2, int);
127 GGO_DefineOption(sampleRate2, SetSampleRate2, int);
130 itkSetMacro(AutoCrop, bool);
131 itkGetConstMacro(AutoCrop, bool);
132 itkBooleanMacro(AutoCrop);
133 GGO_DefineOption_Flag(autoCrop, SetAutoCrop);
136 ExtractBonesFilter();
137 virtual ~ExtractBonesFilter() {}
140 itkSetMacro(BackgroundValue, OutputImagePixelType);
141 itkSetMacro(ForegroundValue, OutputImagePixelType);
142 OutputImagePixelType m_BackgroundValue;
143 OutputImagePixelType m_ForegroundValue;
146 InputImagePixelType m_UpperThreshold1;
147 InputImagePixelType m_LowerThreshold1;
148 int m_MinimalComponentSize;
149 bool m_FullConnectivity;
152 InputImagePixelType m_UpperThreshold2;
153 InputImagePixelType m_LowerThreshold2;
154 InputImageSizeType m_Radius2;
159 virtual void GenerateOutputInformation();
160 virtual void GenerateData();
166 void RemoveTrachea();
167 void BonesSeparation();
168 InputImageConstPointer input;
169 OutputImageConstPointer patient;
170 InputImagePointer working_input;
171 typename InternalImageType::Pointer working_image;
172 typename InternalImageType::Pointer trachea;
173 typename InternalImageType::Pointer output;
176 ExtractBonesFilter(const Self&); //purposely not implemented
177 void operator=(const Self&); //purposely not implemented
180 //--------------------------------------------------------------------
182 } // end namespace clitk
183 //--------------------------------------------------------------------
185 #ifndef ITK_MANUAL_INSTANTIATION
186 #include "clitkExtractBonesFilter.txx"