VMTK
Loading...
Searching...
No Matches
itkMedialCurveImageFilter.h
Go to the documentation of this file.
1/*=========================================================================
2
3Original Method Developed By:
4 Module : EvoLib
5 File : $RCSfile: itkMedialCurveImageFilter.h,v $
6 Copyright : (C)opyright (University of Zaragoza) 2005++
7 See COPYRIGHT statement in top level directory.
8 Authors : Monica Hernandez && Xavier Mellado
9 Modified : $Author: xmellado $
10 Purpose : Computation of the Medial curve of a tube like object.
11 Date : $Date: 2007/02/19 10:01:15 $
12 Version : $Revision: 1.2 $
13 Changes : $Locker: $
14 $Log: itkMedialCurveImageFilter.h,v $
15 Revision 1.2 2007/02/19 10:01:15 xmellado
16 Release v1.0
17
18Modifications Made To Support Integration Into:
19 The Vascular Modeling Toolkit (VMTK)
20 vmtk.github.io
21
22Modification Authors:
23 Richard Izzo
24 University at Buffalo
25 Github: rlizzo
26 Luca Antiga
27 Orobix Srl.
28 Github: lantiga
29
30=========================================================================*/
31
32#ifndef _itkMedialCurveImageFilter_h
33#define _itkMedialCurveImageFilter_h
34
35#include <time.h>
36
37//STL
38#include <functional>
39#include <queue>
40
41#include <itkImage.h>
42#include <itkNeighborhoodIterator.h>
43#include <itkImageRegionIterator.h>
44#include <itkConstantBoundaryCondition.h>
45
46#include <itkImageToImageFilter.h>
47
48namespace itk
49{
50
54/// The object is represented as a binary image. A topological prunning is performed guided
55/// by the distance transform to the object. The prunning stops when all voxels that are end points
56/// are not simple. The average outward flux imposes an extra criterion for deletion. This class implements the centerline extraction
57/// algorithm described in : "S. Bouix, K. Siddiqi, and A. Tannenbaum. Flux driven automatic centerline extraction. Technical Report
58/// SOCS-04.2, School of Ccomputer Science, McGill University, 2004."
59
62template< class TInputImage,
63 class TAverageOutwardFluxPixelType = float,
64 class TOutputPixelType = unsigned char>
65class ITK_EXPORT MedialCurveImageFilter:
66 public ImageToImageFilter<TInputImage, ::itk::Image<TOutputPixelType,TInputImage::ImageDimension> >
67{
68 public:
69
70 //-----------------------------------------------------
71 // Typedefs
72 //-----------------------------------------------------
73
74 typedef typename itk::Image< TAverageOutwardFluxPixelType, TInputImage::ImageDimension > TAverageOutwardFluxFImage;
75 typedef typename itk::Image< TOutputPixelType, TInputImage::ImageDimension > TOutputImage;
76
79 typedef ImageToImageFilter<TInputImage,TOutputImage> Superclass;
80 typedef SmartPointer<Self> Pointer;
81 typedef SmartPointer<const Self> ConstPointer;
82
85
87 itkTypeMacro( MedialCurveImageFilter, ImageToImageFilter );
88
89 typedef itk::ConstantBoundaryCondition< TOutputImage > OutputBCType;
90
91 typedef typename TInputImage::ConstPointer InputConstPointerType;
92 typedef typename TAverageOutwardFluxFImage::ConstPointer AOFConstPointerType;
93 typedef typename TOutputImage::Pointer OutputPointerType;
94
95 typedef typename TOutputImage::IndexType OutputIndexType;
96 typedef typename TOutputImage::SizeType OutputSizeType;
97 typedef typename TOutputImage::RegionType OutputRegionType;
98 typedef typename TOutputImage::PixelType OutputPixelType;
100 typedef typename TInputImage::IndexType InputIndexType;
101 typedef typename TInputImage::PixelType InputPixelType;
102
103 typedef itk::ImageRegionConstIterator< TInputImage > InputConstIteratorType;
104 typedef itk::ImageRegionIterator< TOutputImage > OutputIteratorType;
105 typedef itk::ConstNeighborhoodIterator< TInputImage > InputConstNeighborhoodIteratorType;
106 typedef itk::ConstNeighborhoodIterator< TAverageOutwardFluxFImage > AOFConstNeighborhoodIteratorType;
107 typedef itk::NeighborhoodIterator< TOutputImage > OutputNeighborhoodIteratorType;
108
109 struct Pixel
110 {
111 private:
112 InputIndexType pixelIndex;
113 InputPixelType pixelValue;
114
115 public:
116 InputPixelType GetPriority() const {return pixelValue;};
117 void SetIndex(InputIndexType p) { pixelIndex=p;};
118 void SetValue(InputPixelType v) {pixelValue=v;};
119 InputIndexType GetIndex() {return pixelIndex;};
120 InputPixelType GetValue() {return pixelValue;};
121 };
122
123 struct Greater
124 {
125 public:
126 bool operator()(const Pixel &p1, const Pixel &p2) const
127 {
128 return p1.GetPriority() > p2.GetPriority();
129 }
130 };
131
132 typedef std::vector<Pixel> HeapContainer;
133 typedef std::priority_queue<Pixel, HeapContainer, Greater > HeapType;
134
136 itkStaticConstMacro(InputImageDimension, unsigned int,
137 TInputImage::ImageDimension);
138 itkStaticConstMacro(OutputImageDimension, unsigned int,
139 TOutputImage::ImageDimension);
140
141
142 //-----------------------------------------------------
143 // Methods
144 //-----------------------------------------------------
145
147 {
148 this->ProcessObject::SetNthInput( 1, const_cast< TAverageOutwardFluxFImage * >(aofImage.GetPointer()) );
149 }
150
152 {
153 return ( static_cast< TAverageOutwardFluxFImage *>(this->ProcessObject::GetInput(1)) );
154 }
155
157 itkSetMacro( Threshold, double );
158
160 itkGetConstReferenceMacro( Threshold, double );
161
162#ifdef ITK_USE_CONCEPT_CHECKING
164 itkConceptMacro(SameDimensionCheck,
165 (Concept::SameDimension<InputImageDimension, OutputImageDimension>));
166 itkConceptMacro(AOFIsFloatingPointCheck,
167 (Concept::IsFloatingPoint<TAverageOutwardFluxPixelType>));
169#endif
170
171 protected:
172
175
177 virtual ~MedialCurveImageFilter();
178
181 bool IsBoundary( OutputIndexType p );
182
186
190
192 bool IsEnd( OutputIndexType p );
193
195 void DistanceToObject();
196
198 void GenerateData() ITK_OVERRIDE;
199
200 void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
201
202
203 //-----------------------------------------------------
204 // Variables
205 //-----------------------------------------------------
206
207 InputConstPointerType distance; // Implicit representation of the object. Is at input 0.
208 AOFConstPointerType aof; // Average outward flux. Is at input 1.
209 double m_Threshold; // Threshold for the average outward flux.
210 OutputPointerType queued; // Image that stores queued labels in Update().
211 OutputPointerType auxQueued; // Image that stores queued labels in IsIntSimple() and IsExtSimple().
214
215
216 private:
217
218 MedialCurveImageFilter( const MedialCurveImageFilter& ); //purposely not implemented
219 void operator = ( const MedialCurveImageFilter& ); //purposely not implemented
220};
221
222#include "itkMedialCurveImageFilter.txx"
223
224}//end itk namespace
225
226#endif // _itkMedialCurveImageFilter_h
227
itk::NeighborhoodIterator< TOutputImage > OutputNeighborhoodIteratorType
virtual AOFConstPointerType GetAverageOutwardFluxImage()
itk::Image< TOutputPixelType, TInputImage::ImageDimension > TOutputImage
itk::ImageRegionConstIterator< TInputImage > InputConstIteratorType
itkSetMacro(Threshold, double)
SmartPointer< const Self > ConstPointer
bool IsIntSimple(OutputIndexType p)
Returns true if its deletion from the object changes the local object topology in the 27 neighborhood...
void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
itk::ConstNeighborhoodIterator< TAverageOutwardFluxFImage > AOFConstNeighborhoodIteratorType
void DistanceToObject()
Computes the binary object from its implicit representation.
itk::ConstNeighborhoodIterator< TInputImage > InputConstNeighborhoodIteratorType
TInputImage::ConstPointer InputConstPointerType
TAverageOutwardFluxFImage::ConstPointer AOFConstPointerType
itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension)
itk::ConstantBoundaryCondition< TOutputImage > OutputBCType
MedialCurveImageFilter()
Default Constructor.
itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension)
TOutputImage::RegionType OutputRegionType
virtual void SetAverageOutwardFluxImage(AOFConstPointerType aofImage)
bool IsExtSimple(OutputIndexType p)
Returns true if its deletion from the object changes the local background topology in the 18 neighbor...
bool IsBoundary(OutputIndexType p)
Returns true if p belongs to the object and at least one of its 27 neighbors belong to the background...
itkGetConstReferenceMacro(Threshold, double)
itk::ImageRegionIterator< TOutputImage > OutputIteratorType
bool IsEnd(OutputIndexType p)
Returns true if the point has less than two object neighbors.
itk::Image< TAverageOutwardFluxPixelType, TInputImage::ImageDimension > TAverageOutwardFluxFImage
itkTypeMacro(MedialCurveImageFilter, ImageToImageFilter)
TOutputImage::PixelType OutputPixelType
ImageToImageFilter< TInputImage, TOutputImage > Superclass
std::priority_queue< Pixel, HeapContainer, Greater > HeapType
TOutputImage::IndexType OutputIndexType
bool operator()(const Pixel &p1, const Pixel &p2) const