23 #ifndef __itkContourExtractor2DImageFilter_h
24 #define __itkContourExtractor2DImageFilter_h
26 #include "itkConceptChecking.h"
28 #include "itkNumericTraits.h"
29 #include "itkPolyLineParametricPath.h"
30 #include "vcl_deque.h"
32 #include <itksys/hash_map.hxx>
96 template <
class TInputImage>
101 itkStaticConstMacro(InputImageDimension,
unsigned int, TInputImage::ImageDimension);
114 itkFactorylessNewMacro(Self) itkCloneMacro(Self)
135 itkSetMacro(ReverseContourOrientation,
bool);
136 itkGetConstReferenceMacro(ReverseContourOrientation,
bool);
137 itkBooleanMacro(ReverseContourOrientation);
142 itkSetMacro(VertexConnectHighPixels,
bool);
143 itkGetConstReferenceMacro(VertexConnectHighPixels,
bool);
144 itkBooleanMacro(VertexConnectHighPixels);
148 void SetRequestedRegion(const InputRegionType region);
149 itkGetConstReferenceMacro(RequestedRegion, InputRegionType);
150 void ClearRequestedRegion();
154 itkSetMacro(ContourValue, InputRealType);
155 itkGetConstReferenceMacro(ContourValue, InputRealType);
157 #ifdef ITK_USE_CONCEPT_CHECKING
159 itkConceptMacro(DimensionShouldBe2, (Concept::SameDimension<itkGetStaticConstMacro(InputImageDimension), 2>));
160 itkConceptMacro(InputPixelTypeComparable, (Concept::Comparable<InputPixelType>));
161 itkConceptMacro(InputHasPixelTraitsCheck, (Concept::HasPixelTraits<InputPixelType>));
162 itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputPixelType>));
167 ContourExtractor2DImageFilter();
168 virtual ~ContourExtractor2DImageFilter();
169 void PrintSelf(std::ostream &os, Indent indent)
const;
176 virtual void GenerateInputRequestedRegion() throw(InvalidRequestedRegionError);
179 VertexType InterpolateContourPosition(InputPixelType fromValue,
180 InputPixelType toValue,
181 InputIndexType fromIndex,
182 InputOffsetType toOffset);
183 void AddSegment(const VertexType from, const VertexType to);
185 ContourExtractor2DImageFilter(const Self &);
186 void operator=(const Self &);
188 InputRealType m_ContourValue;
189 bool m_ReverseContourOrientation;
190 bool m_VertexConnectHighPixels;
191 bool m_UseCustomRegion;
192 InputRegionType m_RequestedRegion;
193 unsigned int m_NumberOfContoursCreated;
210 class ContourType : public vcl_deque<VertexType>
213 unsigned int m_ContourNumber;
219 typedef vcl_list<ContourType> ContourContainer;
220 typedef typename ContourContainer::iterator ContourRef;
225 typedef typename VertexType::CoordRepType CoordinateType;
226 inline size_t operator()(
const VertexType &k)
const
232 const size_t hashVertex1 = this->float_hash(k[0] * 0xbeef);
233 const size_t hashVertex2 = this->float_hash(k[1]);
234 const size_t hashValue = hashVertex1 ^ hashVertex2;
240 inline size_t float_hash(
const CoordinateType &k)
const
247 CoordinateType mantissa = vcl_frexp(k, &exponent);
248 size_t value =
static_cast<size_t>(vcl_fabs(mantissa));
249 value = (2 * value - 1) * ~0U;
266 typedef itksys::hash_map<VertexType, ContourRef, VertexHash> VertexToContourMap;
267 typedef typename VertexToContourMap::iterator VertexMapIterator;
268 typedef typename VertexToContourMap::value_type VertexContourRefPair;
271 ContourContainer m_Contours;
274 VertexToContourMap m_ContourStarts;
275 VertexToContourMap m_ContourEnds;
280 #ifndef ITK_MANUAL_INSTANTIATION
Base class for filters that take an image as input and produce an path as output. ...