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 CLITKEXTRACTAIRWAYTREEINFOSFILTER_H
20 #define CLITKEXTRACTAIRWAYTREEINFOSFILTER_H
23 #include "clitkFilterBase.h"
24 #include "clitkDecomposeAndReconstructImageFilter.h"
25 #include "clitkExplosionControlledThresholdConnectedImageFilter.h"
26 #include "clitkSegmentationUtils.h"
27 #include "clitkFilterWithAnatomicalFeatureDatabaseManagement.h"
31 #include "itkStatisticsImageFilter.h"
35 //--------------------------------------------------------------------
37 From a trachea binary image, compute the skeleton and track the
38 path to find the carena.
40 //--------------------------------------------------------------------
47 typedef itk::Index<3> IndexType;
48 typedef itk::Point<double, 3> PointType;
49 typedef double PixelType;
50 Bifurcation(IndexType _index, PixelType _l, PixelType _l1, PixelType _l2) {
63 typedef itk::Index<3> NodeType;
64 typedef tree<NodeType> TreeType;
65 typedef TreeType::iterator TreeIterator;
66 TreeIterator treeIter;
68 //--------------------------------------------------------------------
71 //--------------------------------------------------------------------
72 template <class TImageType>
73 class ITK_EXPORT ExtractAirwaysTreeInfoFilter:
74 public virtual clitk::FilterBase,
75 public clitk::FilterWithAnatomicalFeatureDatabaseManagement,
76 public itk::ImageToImageFilter<TImageType, TImageType>
80 /** Standard class typedefs. */
81 typedef itk::ImageToImageFilter<TImageType, TImageType> Superclass;
82 typedef ExtractAirwaysTreeInfoFilter Self;
83 typedef itk::SmartPointer<Self> Pointer;
84 typedef itk::SmartPointer<const Self> ConstPointer;
86 /** Method for creation through the object factory. */
89 /** Run-time type information (and related methods). */
90 itkTypeMacro(ExtractAirwaysTreeInfoFilter, ImageToImageFilter);
93 /** Some convenient typedefs */
94 typedef TImageType ImageType;
95 typedef typename ImageType::ConstPointer ImageConstPointer;
96 typedef typename ImageType::Pointer ImagePointer;
97 typedef typename ImageType::RegionType ImageRegionType;
98 typedef typename ImageType::PixelType ImagePixelType;
99 typedef typename ImageType::SizeType ImageSizeType;
100 typedef typename ImageType::IndexType ImageIndexType;
101 typedef typename ImageType::PointType ImagePointType;
103 typedef Bifurcation BifurcationType;
104 typedef ImageIndexType NodeType;
105 typedef tree<NodeType> TreeType;
106 typedef typename TreeType::iterator TreeIterator;
108 itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
109 typedef int InternalPixelType;
110 typedef itk::Image<InternalPixelType, ImageType::ImageDimension> InternalImageType;
111 typedef typename InternalImageType::Pointer InternalImagePointer;
112 typedef typename InternalImageType::IndexType InternalIndexType;
113 typedef LabelizeParameters<InternalPixelType> LabelParamType;
115 // Data Structures for trees
116 struct FullTreeNodeType {
117 ImageIndexType index;
118 ImagePointType point;
121 struct StructuralTreeNodeType {
122 ImageIndexType index;
123 ImagePointType point;
126 typedef tree<FullTreeNodeType> FullTreeType;
127 typedef tree<StructuralTreeNodeType> StructuralTreeType;
128 FullTreeType mFullSkeletonTree;
129 StructuralTreeType mStructuralSkeletonTree;
131 /** Connect inputs */
132 void SetInput(const ImageType * image);
134 // Background / Foreground
135 itkGetConstMacro(BackgroundValue, ImagePixelType);
136 itkGetConstMacro(ForegroundValue, ImagePixelType);
139 itkGetConstMacro(FirstTracheaPoint, ImagePointType);
140 itkGetConstMacro(CarinaPoint, ImagePointType);
143 ExtractAirwaysTreeInfoFilter();
144 virtual ~ExtractAirwaysTreeInfoFilter() {}
147 ImageConstPointer input;
148 ImagePointer skeleton;
149 ImagePointer working_input;
152 itkSetMacro(BackgroundValue, ImagePixelType);
153 itkSetMacro(ForegroundValue, ImagePixelType);
154 ImagePixelType m_BackgroundValue;
155 ImagePixelType m_ForegroundValue;
158 ImagePointType m_FirstTracheaPoint;
159 ImagePointType m_CarinaPoint;
161 virtual void GenerateOutputInformation();
162 virtual void GenerateData();
164 TreeType m_SkeletonTree;
165 void TrackFromThisIndex2(ImageIndexType index, ImagePointer skeleton,
166 ImagePixelType label,
167 typename FullTreeType::iterator currentNode,
168 typename StructuralTreeType::iterator currentSNode);
169 void TrackFromThisIndex(std::vector<BifurcationType> & listOfBifurcations,
170 ImagePointer skeleton,
171 ImageIndexType index,
172 ImagePixelType label,
173 TreeIterator currentNode);
175 ExtractAirwaysTreeInfoFilter(const Self&); //purposely not implemented
176 void operator=(const Self&); //purposely not implemented
179 //--------------------------------------------------------------------
181 } // end namespace clitk
182 //--------------------------------------------------------------------
184 #ifndef ITK_MANUAL_INSTANTIATION
185 #include "clitkExtractAirwaysTreeInfoFilter.txx"