19 #ifndef __itkContourExtractor2DImageFilter_h
20 #define __itkContourExtractor2DImageFilter_h
22 #include "itkConceptChecking.h"
24 #include "itkNumericTraits.h"
25 #include "itkPolyLineParametricPath.h"
28 #include <unordered_map>
90 template <
class TInputImage>
95 itkStaticConstMacro(InputImageDimension,
unsigned int, TInputImage::ImageDimension);
108 itkFactorylessNewMacro(
Self);
130 itkSetMacro(ReverseContourOrientation,
bool);
131 itkGetConstReferenceMacro(ReverseContourOrientation,
bool);
132 itkBooleanMacro(ReverseContourOrientation);
137 itkSetMacro(VertexConnectHighPixels,
bool);
138 itkGetConstReferenceMacro(VertexConnectHighPixels,
bool);
139 itkBooleanMacro(VertexConnectHighPixels);
145 void ClearRequestedRegion();
152 #ifdef ITK_USE_CONCEPT_CHECKING
154 itkConceptMacro(DimensionShouldBe2, (Concept::SameDimension<itkGetStaticConstMacro(InputImageDimension), 2>));
155 itkConceptMacro(InputPixelTypeComparable, (Concept::Comparable<InputPixelType>));
156 itkConceptMacro(InputHasPixelTraitsCheck, (Concept::HasPixelTraits<InputPixelType>));
157 itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputPixelType>));
164 void PrintSelf(std::ostream &os, Indent indent)
const override;
166 void GenerateData()
override;
171 void GenerateInputRequestedRegion()
override;
181 void operator=(
const Self &);
184 bool m_ReverseContourOrientation;
185 bool m_VertexConnectHighPixels;
186 bool m_UseCustomRegion;
188 unsigned int m_NumberOfContoursCreated;
205 class ContourType :
public std::deque<VertexType>
208 unsigned int m_ContourNumber;
214 typedef std::list<ContourType> ContourContainer;
215 typedef typename ContourContainer::iterator ContourRef;
220 typedef typename VertexType::CoordRepType CoordinateType;
221 inline size_t operator()(
const VertexType &k)
const
227 const size_t hashVertex1 = this->float_hash(k[0] * 0xbeef);
228 const size_t hashVertex2 = this->float_hash(k[1]);
229 const size_t hashValue = hashVertex1 ^ hashVertex2;
234 inline size_t float_hash(
const CoordinateType &k)
const
241 CoordinateType mantissa = std::frexp(k, &exponent);
242 size_t value =
static_cast<size_t>(std::fabs(mantissa));
243 value = (2 * value - 1) * ~0U;
260 typedef std::unordered_map<VertexType, ContourRef, VertexHash> VertexToContourMap;
261 typedef typename VertexToContourMap::iterator VertexMapIterator;
262 typedef typename VertexToContourMap::value_type VertexContourRefPair;
265 ContourContainer m_Contours;
268 VertexToContourMap m_ContourStarts;
269 VertexToContourMap m_ContourEnds;
274 #ifndef ITK_MANUAL_INSTANTIATION
275 #include "itkContourExtractor2DImageFilter.txx"