18 #ifndef itkStatisticsLabelObject_h
19 #define itkStatisticsLabelObject_h
40 template <
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;
81 static constexpr AttributeType MINIMUM = 200;
82 static constexpr AttributeType MAXIMUM = 201;
83 static constexpr AttributeType MEAN = 202;
84 static constexpr AttributeType SUM = 203;
85 static constexpr AttributeType STANDARD_DEVIATION = 204;
86 static constexpr AttributeType VARIANCE = 205;
87 static constexpr AttributeType MEDIAN = 206;
88 static constexpr AttributeType MAXIMUM_INDEX = 207;
89 static constexpr AttributeType MINIMUM_INDEX = 208;
90 static constexpr AttributeType CENTER_OF_GRAVITY = 209;
92 static constexpr AttributeType WEIGHTED_PRINCIPAL_MOMENTS = 211;
93 static constexpr AttributeType WEIGHTED_PRINCIPAL_AXES = 212;
94 static constexpr AttributeType KURTOSIS = 213;
95 static constexpr AttributeType SKEWNESS = 214;
96 static constexpr AttributeType WEIGHTED_ELONGATION = 215;
97 static constexpr AttributeType HISTOGRAM = 216;
98 static constexpr AttributeType WEIGHTED_FLATNESS = 217;
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);
198 case STANDARD_DEVIATION:
199 return "StandardDeviation";
208 return "MaximumIndex";
211 return "MinimumIndex";
213 case CENTER_OF_GRAVITY:
214 return "CenterOfGravity";
219 case WEIGHTED_PRINCIPAL_MOMENTS:
220 return "WeightedPrincipalMoments";
222 case WEIGHTED_PRINCIPAL_AXES:
223 return "WeightedPrincipalAxes";
231 case WEIGHTED_ELONGATION:
232 return "WeightedElongation";
237 case WEIGHTED_FLATNESS:
238 return "WeightedFlatness";
242 return Superclass::GetNameFromAttribute(a);
247 using typename Superclass::CentroidType;
249 template <
typename TSourceLabelObject>
253 Superclass::template CopyAttributesFrom<TSourceLabelObject>(src);
255 m_Minimum = src->GetMinimum();
256 m_Maximum = src->GetMaximum();
257 m_Mean = src->GetMean();
258 m_Sum = src->GetSum();
259 m_StandardDeviation = src->GetStandardDeviation();
260 m_Variance = src->GetVariance();
261 m_Median = src->GetMedian();
262 m_MaximumIndex = src->GetMaximumIndex();
263 m_MinimumIndex = src->GetMinimumIndex();
264 m_CenterOfGravity = src->GetCenterOfGravity();
266 m_WeightedPrincipalMoments = src->GetWeightedPrincipalMoments();
267 m_WeightedPrincipalAxes = src->GetWeightedPrincipalAxes();
268 m_Kurtosis = src->GetKurtosis();
269 m_Skewness = src->GetSkewness();
270 m_WeightedElongation = src->GetWeightedElongation();
271 m_Histogram = src->GetHistogram();
272 m_WeightedFlatness = src->GetWeightedFlatness();
275 template <
typename TSourceLabelObject>
279 itkAssertOrThrowMacro((src !=
nullptr),
"Null Pointer");
280 this->
template CopyLinesFrom<TSourceLabelObject>(src);
281 this->
template CopyAttributesFrom<TSourceLabelObject>(src);
335 return m_StandardDeviation;
341 m_StandardDeviation = v;
371 return m_MaximumIndex;
383 return m_MinimumIndex;
395 return m_CenterOfGravity;
401 m_CenterOfGravity = v;
418 return m_WeightedPrincipalMoments;
424 m_WeightedPrincipalMoments = v;
430 return m_WeightedPrincipalAxes;
436 m_WeightedPrincipalAxes = v;
466 return m_WeightedElongation;
472 m_WeightedElongation = v;
475 const HistogramType *
490 return m_WeightedFlatness;
496 m_WeightedFlatness = v;
512 for (
unsigned int i = 0; i < ImageDimension; ++i)
514 offset[i] = m_CenterOfGravity[i];
515 for (
unsigned int j = 0; j < ImageDimension; ++j)
517 matrix[j][i] = m_WeightedPrincipalAxes[i][j];
524 result->SetMatrix(matrix);
525 result->SetOffset(offset);
534 AffineTransformPointer
539 for (
unsigned int i = 0; i < ImageDimension; ++i)
541 offset[i] = m_CenterOfGravity[i];
542 for (
unsigned int j = 0; j < ImageDimension; ++j)
544 matrix[j][i] = m_WeightedPrincipalAxes[i][j];
550 result->SetMatrix(matrix);
551 result->SetOffset(offset);
554 result->GetInverse(inverse);
566 m_StandardDeviation = 0;
569 m_MaximumIndex.Fill(0);
570 m_MinimumIndex.Fill(0);
571 m_CenterOfGravity.Fill(0);
573 m_WeightedPrincipalMoments.Fill(0);
574 m_WeightedPrincipalAxes.Fill(0);
577 m_WeightedElongation = 0;
578 m_Histogram =
nullptr;
579 m_WeightedFlatness = 0;
585 Superclass::PrintSelf(os, indent);
587 os << indent <<
"Minimum: " << m_Minimum << std::endl;
588 os << indent <<
"Maximum: " << m_Maximum << std::endl;
589 os << indent <<
"Mean: " << m_Mean << std::endl;
590 os << indent <<
"Sum: " << m_Sum << std::endl;
591 os << indent <<
"StandardDeviation: " << m_StandardDeviation << std::endl;
592 os << indent <<
"Variance: " << m_Variance << std::endl;
593 os << indent <<
"Median: " << m_Median << std::endl;
594 os << indent <<
"Skewness: " << m_Skewness << std::endl;
595 os << indent <<
"Kurtosis: " << m_Kurtosis << std::endl;
596 os << indent <<
"WeightedElongation: " << m_WeightedElongation << std::endl;
597 os << indent <<
"WeightedFlatness: " << m_WeightedFlatness << std::endl;
598 os << indent <<
"MaximumIndex: " << m_MaximumIndex << std::endl;
599 os << indent <<
"MinimumIndex: " << m_MinimumIndex << std::endl;
600 os << indent <<
"CenterOfGravity: " << m_CenterOfGravity << std::endl;
602 os << indent <<
"WeightedPrincipalMoments: " << m_WeightedPrincipalMoments << std::endl;
603 os << indent <<
"WeightedPrincipalAxes: " << std::endl << m_WeightedPrincipalAxes;
604 itkPrintSelfObjectMacro(Histogram);
612 double m_StandardDeviation{};
623 double m_WeightedElongation{};
627 double m_WeightedFlatness{};