18#ifndef itkStatisticsLabelObject_h
19#define itkStatisticsLabelObject_h
40template <
typename TLabel,
unsigned int VImageDimension>
62 static constexpr unsigned int ImageDimension = VImageDimension;
70 using typename Superclass::LineType;
72 using typename Superclass::LengthType;
80 using typename Superclass::AttributeType;
107 else if (s ==
"Maximum")
111 else if (s ==
"Mean")
119 else if (s ==
"StandardDeviation")
121 return STANDARD_DEVIATION;
123 else if (s ==
"Variance")
127 else if (s ==
"Median")
131 else if (s ==
"MaximumIndex")
133 return MAXIMUM_INDEX;
135 else if (s ==
"MinimumIndex")
137 return MINIMUM_INDEX;
139 else if (s ==
"CenterOfGravity")
141 return CENTER_OF_GRAVITY;
149 else if (s ==
"WeightedPrincipalMoments")
151 return WEIGHTED_PRINCIPAL_MOMENTS;
153 else if (s ==
"WeightedPrincipalAxes")
155 return WEIGHTED_PRINCIPAL_AXES;
157 else if (s ==
"Kurtosis")
161 else if (s ==
"Skewness")
165 else if (s ==
"WeightedElongation")
167 return WEIGHTED_ELONGATION;
169 else if (s ==
"Histogram")
173 else if (s ==
"WeightedFlatness")
175 return WEIGHTED_FLATNESS;
178 return Superclass::GetAttributeFromName(s);
194 case STANDARD_DEVIATION:
195 return "StandardDeviation";
201 return "MaximumIndex";
203 return "MinimumIndex";
204 case CENTER_OF_GRAVITY:
205 return "CenterOfGravity";
208 case WEIGHTED_PRINCIPAL_MOMENTS:
209 return "WeightedPrincipalMoments";
210 case WEIGHTED_PRINCIPAL_AXES:
211 return "WeightedPrincipalAxes";
216 case WEIGHTED_ELONGATION:
217 return "WeightedElongation";
220 case WEIGHTED_FLATNESS:
221 return "WeightedFlatness";
224 return Superclass::GetNameFromAttribute(a);
229 using typename Superclass::CentroidType;
231 template <
typename TSourceLabelObject>
235 Superclass::template CopyAttributesFrom<TSourceLabelObject>(src);
237 m_Minimum = src->GetMinimum();
238 m_Maximum = src->GetMaximum();
239 m_Mean = src->GetMean();
240 m_Sum = src->GetSum();
241 m_StandardDeviation = src->GetStandardDeviation();
242 m_Variance = src->GetVariance();
243 m_Median = src->GetMedian();
244 m_MaximumIndex = src->GetMaximumIndex();
245 m_MinimumIndex = src->GetMinimumIndex();
246 m_CenterOfGravity = src->GetCenterOfGravity();
248 m_WeightedPrincipalMoments = src->GetWeightedPrincipalMoments();
249 m_WeightedPrincipalAxes = src->GetWeightedPrincipalAxes();
250 m_Kurtosis = src->GetKurtosis();
251 m_Skewness = src->GetSkewness();
252 m_WeightedElongation = src->GetWeightedElongation();
253 m_Histogram = src->GetHistogram();
254 m_WeightedFlatness = src->GetWeightedFlatness();
257 template <
typename TSourceLabelObject>
261 itkAssertOrThrowMacro((src !=
nullptr),
"Null Pointer");
262 this->
template CopyLinesFrom<TSourceLabelObject>(src);
263 this->
template CopyAttributesFrom<TSourceLabelObject>(src);
317 return m_StandardDeviation;
323 m_StandardDeviation = v;
353 return m_MaximumIndex;
365 return m_MinimumIndex;
377 return m_CenterOfGravity;
383 m_CenterOfGravity = v;
400 return m_WeightedPrincipalMoments;
406 m_WeightedPrincipalMoments = v;
412 return m_WeightedPrincipalAxes;
418 m_WeightedPrincipalAxes = v;
448 return m_WeightedElongation;
454 m_WeightedElongation = v;
457 const HistogramType *
472 return m_WeightedFlatness;
478 m_WeightedFlatness = v;
494 for (
unsigned int i = 0; i < ImageDimension; ++i)
496 offset[i] = m_CenterOfGravity[i];
497 for (
unsigned int j = 0; j < ImageDimension; ++j)
499 matrix[j][i] = m_WeightedPrincipalAxes[i][j];
506 result->SetMatrix(matrix);
507 result->SetOffset(offset);
516 AffineTransformPointer
521 for (
unsigned int i = 0; i < ImageDimension; ++i)
523 offset[i] = m_CenterOfGravity[i];
524 for (
unsigned int j = 0; j < ImageDimension; ++j)
526 matrix[j][i] = m_WeightedPrincipalAxes[i][j];
532 result->SetMatrix(matrix);
533 result->SetOffset(offset);
536 result->GetInverse(inverse);
548 m_StandardDeviation = 0;
551 m_MaximumIndex.Fill(0);
552 m_MinimumIndex.Fill(0);
553 m_CenterOfGravity.Fill(0);
555 m_WeightedPrincipalMoments.Fill(0);
556 m_WeightedPrincipalAxes.Fill(0);
559 m_WeightedElongation = 0;
560 m_Histogram =
nullptr;
561 m_WeightedFlatness = 0;
567 Superclass::PrintSelf(os, indent);
569 os << indent <<
"Minimum: " << m_Minimum << std::endl;
570 os << indent <<
"Maximum: " << m_Maximum << std::endl;
571 os << indent <<
"Mean: " << m_Mean << std::endl;
572 os << indent <<
"Sum: " << m_Sum << std::endl;
573 os << indent <<
"StandardDeviation: " << m_StandardDeviation << std::endl;
574 os << indent <<
"Variance: " << m_Variance << std::endl;
575 os << indent <<
"Median: " << m_Median << std::endl;
576 os << indent <<
"Skewness: " << m_Skewness << std::endl;
577 os << indent <<
"Kurtosis: " << m_Kurtosis << std::endl;
578 os << indent <<
"WeightedElongation: " << m_WeightedElongation << std::endl;
579 os << indent <<
"WeightedFlatness: " << m_WeightedFlatness << std::endl;
580 os << indent <<
"MaximumIndex: " << m_MaximumIndex << std::endl;
581 os << indent <<
"MinimumIndex: " << m_MinimumIndex << std::endl;
582 os << indent <<
"CenterOfGravity: " << m_CenterOfGravity << std::endl;
584 os << indent <<
"WeightedPrincipalMoments: " << m_WeightedPrincipalMoments << std::endl;
585 os << indent <<
"WeightedPrincipalAxes: " << std::endl << m_WeightedPrincipalAxes;
586 itkPrintSelfObjectMacro(Histogram);
594 double m_StandardDeviation{};
605 double m_WeightedElongation{};
609 double m_WeightedFlatness{};
An image region represents a structured region of data.
Control indentation during Print() invocation.
Templated n-dimensional image to store labeled objects.
unsigned int AttributeType
Light weight base class for most itk classes.
A Label object to store the common attributes related to the shape of the object.
typename AffineTransformType::Pointer AffineTransformPointer
A Label object to store the common attributes related to the statistics of the object.
const PointType & GetCenterOfGravity() const
void SetVariance(const double v)
const double & GetVariance() const
const double & GetStandardDeviation() const
void SetWeightedPrincipalMoments(const VectorType &v)
void SetHistogram(const HistogramType *v)
void SetMinimumIndex(const IndexType &v)
const IndexType & GetMinimumIndex() const
const double & GetWeightedElongation() const
const double & GetSkewness() const
static AttributeType GetAttributeFromName(const std::string &s)
void SetSkewness(const double v)
const IndexType & GetMaximumIndex() const
void SetKurtosis(const double v)
void PrintSelf(std::ostream &os, Indent indent) const override
void SetCenterOfGravity(const PointType &v)
AffineTransformPointer GetWeightedPrincipalAxesToPhysicalAxesTransform() const
void CopyAttributesFrom(const TSourceLabelObject *src)
void SetWeightedElongation(const double v)
const double & GetKurtosis() const
void SetMaximumIndex(const IndexType &v)
const double & GetMaximum() const
void SetSum(const double v)
const double & GetMean() const
const HistogramType * GetHistogram() const
void SetMaximum(const double v)
const double & GetWeightedFlatness() const
void SetStandardDeviation(const double v)
void SetWeightedFlatness(const double v)
void CopyAllFrom(const TSourceLabelObject *src)
AffineTransformPointer GetPhysicalAxesToWeightedPrincipalAxesTransform() const
const double & GetSum() const
static std::string GetNameFromAttribute(const AttributeType &a)
void SetWeightedPrincipalAxes(const MatrixType &v)
const double & GetMinimum() const
void SetMinimum(const double v)
const VectorType & GetWeightedPrincipalMoments() const
const double & GetMedian() const
void SetMedian(const double v)
const MatrixType & GetWeightedPrincipalAxes() const
void SetMean(const double v)
This class stores measurement vectors in the context of n-dimensional histogram.
Implements a weak reference to an object.
SmartPointer< Self > Pointer
ImageBaseType::IndexType IndexType
ImageBaseType::PointType PointType
ImageBaseType::SpacingType VectorType
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....