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);
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{};