Skip to content

Commit c9e5538

Browse files
committed
BUG: Remove shadow declarations in RGBGibbsPriorFilter
RGBGibbsPriorFilter shadowed MRFImageFilter's m_NumberOfClasses and m_MaximumNumberOfIterations, requiring 4 redundant accessor overrides to direct `this->m_*` at the subclass copy. Remove the shadows and overrides; preserve the subclass-specific default of 10 (vs base 50) by calling SetMaximumNumberOfIterations(10) in the constructor. GTest in preceding commit verifies zero observable API change.
1 parent 7120cc6 commit c9e5538

2 files changed

Lines changed: 2 additions & 48 deletions

File tree

Modules/Segmentation/MarkovRandomFieldsClassifiers/include/itkRGBGibbsPriorFilter.h

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -130,45 +130,6 @@ class ITK_TEMPLATE_EXPORT RGBGibbsPriorFilter : public MRFImageFilter<TInputImag
130130
void
131131
SetClassifier(typename ClassifierType::Pointer ptrToClassifier);
132132

133-
/** Set the number of classes. */
134-
void
135-
SetNumberOfClasses(const unsigned int numberOfClasses) override
136-
{
137-
itkDebugMacro("setting NumberOfClasses to " << numberOfClasses);
138-
if (this->m_NumberOfClasses != numberOfClasses)
139-
{
140-
this->m_NumberOfClasses = numberOfClasses;
141-
this->Modified();
142-
}
143-
}
144-
145-
/** Get the number of classes. */
146-
[[nodiscard]] unsigned int
147-
GetNumberOfClasses() const override
148-
{
149-
return this->m_NumberOfClasses;
150-
}
151-
152-
/** Set/Get the number of iteration of the Iterated Conditional Mode
153-
* (ICM) algorithm. A default value is set at 50 iterations. */
154-
void
155-
SetMaximumNumberOfIterations(const unsigned int numberOfIterations) override
156-
{
157-
itkDebugMacro("setting MaximumNumberOfIterations to " << numberOfIterations);
158-
if (this->m_MaximumNumberOfIterations != numberOfIterations)
159-
{
160-
this->m_MaximumNumberOfIterations = numberOfIterations;
161-
this->Modified();
162-
}
163-
}
164-
165-
/** Get the number of iterations of the Iterated Conditional Mode
166-
* (ICM) algorithm. */
167-
[[nodiscard]] unsigned int
168-
GetMaximumNumberOfIterations() const override
169-
{
170-
return this->m_MaximumNumberOfIterations;
171-
}
172133

173134
/** Set/Get the threshold for the object size. */
174135
/** @ITKStartGrouping */
@@ -252,12 +213,6 @@ class ITK_TEMPLATE_EXPORT RGBGibbsPriorFilter : public MRFImageFilter<TInputImag
252213
/** Output. */
253214
LabelledImageType m_LabelledImage{};
254215

255-
/** Number of classes that need to be classified. */
256-
unsigned int m_NumberOfClasses{ 0 };
257-
258-
/** Maximum number of iterations. */
259-
unsigned int m_MaximumNumberOfIterations{ 10 };
260-
261216
typename ClassifierType::Pointer m_ClassifierPtr{};
262217

263218
/** Threshold for the existence of a boundary. */

Modules/Segmentation/MarkovRandomFieldsClassifiers/include/itkRGBGibbsPriorFilter.hxx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ RGBGibbsPriorFilter<TInputImage, TClassifiedImage>::RGBGibbsPriorFilter()
4141

4242
{
4343
m_StartPoint.Fill(0);
44+
this->SetMaximumNumberOfIterations(10);
4445
}
4546

4647
template <typename TInputImage, typename TClassifiedImage>
@@ -165,7 +166,7 @@ void
165166
RGBGibbsPriorFilter<TInputImage, TClassifiedImage>::SetClassifier(typename ClassifierType::Pointer ptrToClassifier)
166167
{
167168
m_ClassifierPtr = ptrToClassifier;
168-
m_ClassifierPtr->SetNumberOfClasses(m_NumberOfClasses);
169+
m_ClassifierPtr->SetNumberOfClasses(this->GetNumberOfClasses());
169170
}
170171

171172
template <typename TInputImage, typename TClassifiedImage>
@@ -683,8 +684,6 @@ RGBGibbsPriorFilter<TInputImage, TClassifiedImage>::PrintSelf(std::ostream & os,
683684
{
684685
Superclass::PrintSelf(os, indent);
685686

686-
os << indent << "NumberOfClasses: " << m_NumberOfClasses << std::endl;
687-
os << indent << "MaximumNumberOfIterations: " << m_MaximumNumberOfIterations << std::endl;
688687
os << indent << "ObjectThreshold: " << m_ObjectThreshold << std::endl;
689688
os << indent << "BoundaryGradient: " << m_BoundaryGradient << std::endl;
690689
os << indent << "CliqueWeight_1: " << m_CliqueWeight_1 << std::endl;

0 commit comments

Comments
 (0)