19 #ifndef __itkContourExtractor2DImageFilter_h 20 #define __itkContourExtractor2DImageFilter_h 22 #include "itkConceptChecking.h" 24 #include "itkNumericTraits.h" 25 #include "itkPolyLineParametricPath.h" 26 #include "vcl_deque.h" 28 #include <itksys/hash_map.hxx> 92 template <
class TInputImage>
97 itkStaticConstMacro(InputImageDimension,
unsigned int, TInputImage::ImageDimension);
110 itkFactorylessNewMacro(Self);
132 itkSetMacro(ReverseContourOrientation,
bool);
133 itkGetConstReferenceMacro(ReverseContourOrientation,
bool);
134 itkBooleanMacro(ReverseContourOrientation);
139 itkSetMacro(VertexConnectHighPixels,
bool);
140 itkGetConstReferenceMacro(VertexConnectHighPixels,
bool);
141 itkBooleanMacro(VertexConnectHighPixels);
145 void SetRequestedRegion(
const InputRegionType region);
146 itkGetConstReferenceMacro(RequestedRegion, InputRegionType);
147 void ClearRequestedRegion();
151 itkSetMacro(ContourValue, InputRealType);
152 itkGetConstReferenceMacro(ContourValue, InputRealType);
154 #ifdef ITK_USE_CONCEPT_CHECKING 156 itkConceptMacro(DimensionShouldBe2, (Concept::SameDimension<itkGetStaticConstMacro(InputImageDimension), 2>));
157 itkConceptMacro(InputPixelTypeComparable, (Concept::Comparable<InputPixelType>));
158 itkConceptMacro(InputHasPixelTraitsCheck, (Concept::HasPixelTraits<InputPixelType>));
159 itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputPixelType>));
166 void PrintSelf(std::ostream &os, Indent indent)
const override;
168 void GenerateData()
override;
173 void GenerateInputRequestedRegion()
override;
176 VertexType InterpolateContourPosition(InputPixelType fromValue,
177 InputPixelType toValue,
178 InputIndexType fromIndex,
179 InputOffsetType toOffset);
180 void AddSegment(
const VertexType from,
const VertexType to);
183 void operator=(
const Self &);
185 InputRealType m_ContourValue;
186 bool m_ReverseContourOrientation;
187 bool m_VertexConnectHighPixels;
188 bool m_UseCustomRegion;
189 InputRegionType m_RequestedRegion;
190 unsigned int m_NumberOfContoursCreated;
207 class ContourType :
public vcl_deque<VertexType>
210 unsigned int m_ContourNumber;
216 typedef vcl_list<ContourType> ContourContainer;
217 typedef typename ContourContainer::iterator ContourRef;
222 typedef typename VertexType::CoordRepType CoordinateType;
223 inline size_t operator()(
const VertexType &
k)
const 229 const size_t hashVertex1 = this->float_hash(k[0] * 0xbeef);
230 const size_t hashVertex2 = this->float_hash(k[1]);
231 const size_t hashValue = hashVertex1 ^ hashVertex2;
237 inline size_t float_hash(
const CoordinateType &
k)
const 244 CoordinateType mantissa = vcl_frexp(k, &exponent);
245 size_t value =
static_cast<size_t>(vcl_fabs(mantissa));
246 value = (2 * value - 1) * ~0U;
263 typedef itksys::hash_map<VertexType, ContourRef, VertexHash> VertexToContourMap;
264 typedef typename VertexToContourMap::iterator VertexMapIterator;
265 typedef typename VertexToContourMap::value_type VertexContourRefPair;
268 ContourContainer m_Contours;
271 VertexToContourMap m_ContourStarts;
272 VertexToContourMap m_ContourEnds;
277 #ifndef ITK_MANUAL_INSTANTIATION
Base class for filters that take an image as input and produce an path as output. ...