18 #ifndef itkLabelGeometryImageFilter_h
19 #define itkLabelGeometryImageFilter_h
25 #include "itksys/hash_map.hxx"
28 #include "vnl/algo/vnl_symmetric_eigensystem.h"
29 #include "vnl/vnl_det.h"
77 template<
typename TLabelImage,
typename TIntensityImage = TLabelImage >
112 itkStaticConstMacro(ImageDimension,
unsigned int,
113 TLabelImage::ImageDimension);
169 const unsigned int imageDimension = itkGetStaticConstMacro(ImageDimension);
172 for (
unsigned int i = 0; i < imageDimension * 2; i += 2 )
178 m_BoundingBoxVolume = 0;
179 m_BoundingBoxSize.Fill(0);
180 m_PixelIndices.clear();
182 m_WeightedCentroid.Fill(0);
183 m_ZeroOrderMoment = 0;
184 m_FirstOrderRawMoments.Fill(0);
185 m_FirstOrderWeightedRawMoments.Fill(0);
186 m_Eigenvalues.resize(ImageDimension);
187 m_Eigenvalues.clear();
188 m_Eigenvectors.set_size(ImageDimension, ImageDimension);
189 m_Eigenvectors.fill(0);
190 m_AxesLength.Fill(0);
196 unsigned int numberOfVertices = 1 << ImageDimension;
197 m_OrientedBoundingBoxVertices.resize(numberOfVertices, emptyPoint);
198 m_OrientedBoundingBoxVolume = 0;
199 m_OrientedBoundingBoxSize.Fill(0);
200 m_OrientedLabelImage = LabelImageType::New();
201 m_OrientedIntensityImage = IntensityImageType::New();
202 m_OrientedBoundingBoxOrigin.Fill(0);
203 m_RotationMatrix.set_size(ImageDimension, ImageDimension);
204 m_RotationMatrix.fill(0.0);
206 m_SecondOrderRawMoments.set_size(ImageDimension, ImageDimension);
207 m_SecondOrderCentralMoments.set_size(ImageDimension, ImageDimension);
208 for (
unsigned int i = 0; i < ImageDimension; i++ )
210 for (
unsigned int j = 0; j < ImageDimension; j++ )
212 m_SecondOrderRawMoments(i, j) = 0;
213 m_SecondOrderCentralMoments(i, j) = 0;
250 typedef itksys::hash_map< LabelPixelType, LabelGeometry >
MapType;
251 typedef typename itksys::hash_map< LabelPixelType, LabelGeometry >::iterator
MapIterator;
252 typedef typename itksys::hash_map< LabelPixelType, LabelGeometry >::const_iterator
MapConstIterator;
255 itkGetMacro(CalculatePixelIndices,
bool);
256 itkBooleanMacro(CalculatePixelIndices);
264 if ( value ==
false )
266 if ( ( this->m_CalculateOrientedBoundingBox ==
true )
267 || ( this->m_CalculateOrientedLabelRegions ==
true )
268 || ( this->m_CalculateOrientedIntensityRegions ==
true ) )
275 if ( this->m_CalculatePixelIndices != value )
277 this->m_CalculatePixelIndices = value;
282 itkGetMacro(CalculateOrientedBoundingBox,
bool);
283 itkBooleanMacro(CalculateOrientedBoundingBox);
286 if ( this->m_CalculateOrientedBoundingBox != value )
288 this->m_CalculateOrientedBoundingBox = value;
296 this->SetCalculatePixelIndices(
true);
300 itkGetMacro(CalculateOrientedLabelRegions,
bool);
301 itkBooleanMacro(CalculateOrientedLabelRegions);
304 if ( this->m_CalculateOrientedLabelRegions != value )
306 this->m_CalculateOrientedLabelRegions = value;
313 SetCalculateOrientedBoundingBox(
true);
318 itkGetMacro(CalculateOrientedIntensityRegions,
bool);
319 itkBooleanMacro(CalculateOrientedIntensityRegions);
322 if ( this->m_CalculateOrientedIntensityRegions != value )
324 this->m_CalculateOrientedIntensityRegions = value;
331 this->SetCalculateOrientedBoundingBox(
true);
340 this->SetNthInput( 1, const_cast< TIntensityImage * >( input ) );
353 return m_LabelGeometryMapper.find(label) != m_LabelGeometryMapper.end();
359 return m_LabelGeometryMapper.size();
364 return this->GetNumberOfObjects();
374 LabelIndicesType GetPixelIndices(LabelPixelType label)
const;
384 RealType GetIntegratedIntensity(LabelPixelType label)
const;
387 LabelPointType GetCentroid(LabelPixelType label)
const;
390 LabelPointType GetWeightedCentroid(LabelPixelType label)
const;
393 VectorType GetEigenvalues(LabelPixelType label)
const;
396 MatrixType GetEigenvectors(LabelPixelType label)
const;
399 AxesLengthType GetAxesLength(LabelPixelType label)
const;
403 RealType GetMinorAxisLength(LabelPixelType label)
const;
407 RealType GetMajorAxisLength(LabelPixelType label)
const;
410 RealType GetEccentricity(LabelPixelType label)
const;
414 RealType GetElongation(LabelPixelType label)
const;
417 RealType GetOrientation(LabelPixelType label)
const;
422 BoundingBoxType GetBoundingBox(LabelPixelType label)
const;
425 RealType GetBoundingBoxVolume(LabelPixelType label)
const;
428 LabelSizeType GetBoundingBoxSize(LabelPixelType label)
const;
436 BoundingBoxVerticesType GetOrientedBoundingBoxVertices(LabelPixelType label)
const;
439 RealType GetOrientedBoundingBoxVolume(LabelPixelType label)
const;
442 LabelPointType GetOrientedBoundingBoxSize(LabelPixelType label)
const;
445 LabelPointType GetOrientedBoundingBoxOrigin(LabelPixelType label)
const;
449 MatrixType GetRotationMatrix(LabelPixelType label)
const;
452 RegionType GetRegion(LabelPixelType label)
const;
455 TLabelImage * GetOrientedLabelImage(LabelPixelType label)
const;
459 TIntensityImage * GetOrientedIntensityImage(LabelPixelType label)
const;
461 #ifdef ITK_USE_CONCEPT_CHECKING
471 void PrintSelf(std::ostream & os,
Indent indent)
const ITK_OVERRIDE;
473 void GenerateData() ITK_OVERRIDE;
478 bool CalculateOrientedBoundingBoxVertices(vnl_symmetric_eigensystem<
double > eig, LabelGeometry & m_LabelGeometry);
480 bool m_CalculatePixelIndices;
481 bool m_CalculateOrientedBoundingBox;
482 bool m_CalculateOrientedLabelRegions;
483 bool m_CalculateOrientedIntensityRegions;
494 #ifndef ITK_MANUAL_INSTANTIATION
495 #include "itkLabelGeometryImageFilter.hxx"
MatrixType m_SecondOrderRawMoments
itk::FixedArray< float, itkGetStaticConstMacro(ImageDimension)*2 > BoundingBoxFloatType
Critical section locking class that can be allocated on the stack.
bool HasLabel(LabelPixelType label) const
RealType m_OrientedBoundingBoxVolume
Light weight base class for most itk classes.
itksys::hash_map< LabelPixelType, LabelGeometry >::const_iterator MapConstIterator
IntensityImageType::Pointer m_OrientedIntensityImage
MatrixType m_Eigenvectors
TLabelImage::IndexType LabelIndexType
SizeValueType m_ZeroOrderMoment
itk::FixedArray< RealType, itkGetStaticConstMacro(ImageDimension) > AxesLengthType
TLabelImage::RegionType LabelRegionType
SimpleDataObjectDecorator< RealType > RealObjectType
void SetCalculateOrientedIntensityRegions(const bool value)
itksys::hash_map< LabelPixelType, LabelGeometry >::iterator MapIterator
signed long IndexValueType
TIntensityImage::IndexType IndexType
TLabelImage LabelImageType
RealType m_FirstOrderCentralCrossMoment
MatrixType m_RotationMatrix
std::vector< LabelIndexType > LabelIndicesType
void SetCalculateOrientedBoundingBox(const bool value)
itksys::hash_map< LabelPixelType, LabelGeometry > MapType
unsigned long SizeValueType
TIntensityImage IntensityImageType
LabelPointType m_OrientedBoundingBoxOrigin
ImageBaseType::SpacingType VectorType
Simulate a standard C array with copy semnatics.
IndexArrayType m_FirstOrderRawMoments
Geometry stored per label.
TIntensityImage::RegionType RegionType
std::vector< LabelPixelType > LabelsType
itk::FixedArray< typename LabelIndexType::IndexValueType, itkGetStaticConstMacro(ImageDimension) > IndexArrayType
void SetCalculateOrientedLabelRegions(const bool value)
static ITK_CONSTEXPR_FUNC T max(const T &)
LabelIndicesType m_PixelIndices
~LabelGeometryImageFilter()
Decorates any "simple" data type (data types without smart pointers) with a DataObject API...
IndexArrayType m_FirstOrderWeightedRawMoments
void SetCalculatePixelIndices(const bool value)
TIntensityImage::Pointer InputImagePointer
ImageBaseType::PointType PointType
SizeValueType GetNumberOfLabels() const
BoundingBoxVerticesType m_OrientedBoundingBoxVertices
std::vector< LabelPixelType > GetLabels() const
RealType m_BoundingBoxVolume
DataObject::Pointer DataObjectPointer
Given a label map and an optional intensity image, compute geometric features.
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
SizeValueType GetNumberOfObjects() const
static ITK_CONSTEXPR_FUNC T NonpositiveMin()
SmartPointer< Self > Pointer
void SetIntensityInput(const TIntensityImage *input)
SmartPointer< const Self > ConstPointer
std::vector< LabelPointType > BoundingBoxVerticesType
LabelPointType m_OrientedBoundingBoxSize
TLabelImage::PointType LabelPointType
ImageToImageFilter< TLabelImage, TIntensityImage > Superclass
LabelImageType::Pointer m_OrientedLabelImage
Base class for filters that take an image as input and produce an image as output.
TLabelImage::Pointer LabelImagePointer
FixedArray< float, itkGetStaticConstMacro(ImageDimension) > m_AxesLength
const TIntensityImage * GetIntensityInput() const
Control indentation during Print() invocation.
MatrixType m_SecondOrderCentralMoments
BoundingBoxType m_BoundingBox
SizeValueType m_FirstOrderRawCrossMoment
ImageBaseType::SizeType SizeType
LabelGeometryImageFilter Self
std::vector< double > VectorType
TLabelImage::PixelType LabelPixelType
TLabelImage::SizeType LabelSizeType
Define additional traits for native types such as int or float.
vnl_matrix< double > MatrixType
#define itkConceptMacro(name, concept)
itk::FixedArray< typename LabelIndexType::IndexValueType, itkGetStaticConstMacro(ImageDimension)*2 > BoundingBoxType
NumericTraits< PixelType >::RealType RealType
Base class for all data objects in ITK.
LabelPointType m_Centroid
LabelSizeType m_BoundingBoxSize
LabelPointType m_WeightedCentroid
TIntensityImage::PixelType PixelType
ImageBaseType::IndexType IndexType
TIntensityImage::SizeType SizeType