@@ -93,31 +93,15 @@ class IntermodesThresholdImageFilter : public HistogramThresholdImageFilter<TInp
93
93
using HistogramType = typename Superclass::HistogramType;
94
94
using CalculatorType = IntermodesThresholdCalculator<HistogramType, InputPixelType>;
95
95
96
- void
97
- SetMaximumSmoothingIterations (SizeValueType maxSmoothingIterations)
98
- {
99
- m_IntermodesCalculator->SetMaximumSmoothingIterations (maxSmoothingIterations);
100
- }
101
96
102
- SizeValueType
103
- GetMaximumSmoothingIterations ()
104
- {
105
- return (m_IntermodesCalculator->GetMaximumSmoothingIterations ());
106
- }
97
+ itkSetMacro (MaxSmoothingIterations, SizeValueType);
98
+ itkGetMacro (MaxSmoothingIterations, SizeValueType);
107
99
108
100
/* * Select whether midpoint (intermode=true) or minimum between
109
101
peaks is used. */
110
- void
111
- SetUseInterMode (bool useIntermode)
112
- {
113
- m_IntermodesCalculator->SetUseInterMode (useIntermode);
114
- }
115
-
116
- bool
117
- GetUseInterMode ()
118
- {
119
- return (m_IntermodesCalculator->GetUseInterMode ());
120
- }
102
+ itkSetMacro (UseInterMode, bool );
103
+ itkGetConstReferenceMacro (UseInterMode, bool );
104
+ itkBooleanMacro (UseInterMode);
121
105
122
106
/* * Image related type alias. */
123
107
static constexpr unsigned int InputImageDimension = InputImageType::ImageDimension;
@@ -126,23 +110,44 @@ class IntermodesThresholdImageFilter : public HistogramThresholdImageFilter<TInp
126
110
protected:
127
111
IntermodesThresholdImageFilter ()
128
112
{
129
- m_IntermodesCalculator = CalculatorType::New ();
130
- this -> SetCalculator (m_IntermodesCalculator );
131
- m_IntermodesCalculator-> SetMaximumSmoothingIterations ( 10000 );
132
- m_IntermodesCalculator-> SetUseInterMode ( true );
113
+ auto calculator = CalculatorType::New ();
114
+ calculator-> SetMaximumSmoothingIterations (m_MaxSmoothingIterations );
115
+ calculator-> SetUseInterMode (m_UseInterMode );
116
+ Superclass::SetCalculator (calculator );
133
117
}
134
118
~IntermodesThresholdImageFilter () override = default ;
135
119
120
+ void
121
+ VerifyPreconditions () ITKv5_CONST override
122
+ {
123
+ Superclass::VerifyPreconditions ();
124
+ if (dynamic_cast <const CalculatorType *>(Superclass::GetCalculator ()) == nullptr )
125
+ {
126
+ itkExceptionMacro (<< " Invalid IntermodesCalculator." );
127
+ }
128
+ }
129
+
130
+ void
131
+ GenerateData () override
132
+ {
133
+ auto calculator = static_cast <CalculatorType *>(this ->Superclass ::GetModifiableCalculator ());
134
+ calculator->SetMaximumSmoothingIterations (m_MaxSmoothingIterations);
135
+ calculator->SetUseInterMode (m_UseInterMode);
136
+ this ->Superclass ::GenerateData ();
137
+ }
138
+
139
+
136
140
void
137
141
PrintSelf (std::ostream & os, Indent indent) const override
138
142
{
139
143
Superclass::PrintSelf (os, indent);
140
-
141
- itkPrintSelfObjectMacro (IntermodesCalculator) ;
144
+ os << indent << " MaxSmoothingIterations: " << m_MaxSmoothingIterations << std::endl;
145
+ os << indent << " UseIterMode: " << m_UseInterMode << std::endl ;
142
146
}
143
147
144
148
private:
145
- typename CalculatorType::Pointer m_IntermodesCalculator;
149
+ SizeValueType m_MaxSmoothingIterations{ 1000 };
150
+ bool m_UseInterMode{ true };
146
151
};
147
152
148
153
} // end namespace itk
0 commit comments