Commit d3222cab authored by Julien Osman's avatar Julien Osman
Browse files

ENH: Replace the setters of 2 limits by one setter for the 2 limits

parent b00b1339
......@@ -246,8 +246,7 @@ private:
m_ClampFilter = ClampFilterType::New();
m_ClampFilter->SetInput(m_ExtractorFilter->GetOutput());
m_ClampFilter->SetLower(GetParameterFloat("parameters.min"));
m_ClampFilter->SetUpper(GetParameterFloat("parameters.max"));
m_ClampFilter->SetThresholds(GetParameterFloat("parameters.min"), GetParameterFloat("parameters.max"));
m_HarTexFilter = HarTexturesFilterType::New();
m_HarImageList = ImageListType::New();
......
......@@ -84,14 +84,9 @@ public:
/** The values outside the range are set to \p lower or \p upper. */
void ClampOutside(const OutputPixelValueType& lower, const OutputPixelValueType& upper);
/** Set/Get methods to set the lower threshold */
void SetLower(OutputPixelValueType val);
/** Set/Get methods to set the lower and upper threshold */
void SetThresholds(OutputPixelValueType lowerVal, OutputPixelValueType upperVal);
itkGetConstMacro(Lower, OutputPixelValueType);
/** Set/Get methods to set the upper threshold */
void SetUpper(OutputPixelValueType val);
itkGetConstMacro(Upper, OutputPixelValueType);
......
......@@ -45,23 +45,14 @@ ClampImageFilter<TInputImage, TOutputImage>::ClampImageFilter()
}
template <class TInputImage, class TOutputImage>
void ClampImageFilter<TInputImage, TOutputImage>::SetLower(OutputPixelValueType val)
void ClampImageFilter<TInputImage, TOutputImage>::SetThresholds(OutputPixelValueType lowerVal, OutputPixelValueType upperVal)
{
if (m_Lower != val)
assert( lowerVal <= upperVal );
if ((m_Lower != lowerVal) || (m_Upper != upperVal))
{
m_Lower = val;
this->GetFunctor().SetLowest(m_Lower);
this->Modified();
}
}
template <class TInputImage, class TOutputImage>
void ClampImageFilter<TInputImage, TOutputImage>::SetUpper(OutputPixelValueType val)
{
if (m_Upper != val)
{
m_Upper = val;
this->GetFunctor().SetHighest(m_Upper);
m_Lower = lowerVal;
m_Upper = upperVal;
this->GetFunctor().SetThresholds(m_Lower, m_Upper);
this->Modified();
}
}
......@@ -88,8 +79,7 @@ void ClampImageFilter<TInputImage, TOutputImage>::ClampAbove(const OutputPixelVa
{
m_Lower = std::numeric_limits<OutputPixelValueType>::lowest();
m_Upper = thresh;
this->GetFunctor().SetLowest(m_Lower);
this->GetFunctor().SetHighest(m_Upper);
this->GetFunctor().SetThresholds(m_Lower, m_Upper);
this->Modified();
}
}
......@@ -104,8 +94,7 @@ void ClampImageFilter<TInputImage, TOutputImage>::ClampBelow(const OutputPixelVa
{
m_Upper = std::numeric_limits<OutputPixelValueType>::max();
m_Lower = thresh;
this->GetFunctor().SetLowest(m_Lower);
this->GetFunctor().SetHighest(m_Upper);
this->GetFunctor().SetThresholds(m_Lower, m_Upper);
this->Modified();
}
}
......@@ -127,8 +116,7 @@ void ClampImageFilter<TInputImage, TOutputImage>::ClampOutside(const OutputPixel
{
m_Lower = lower;
m_Upper = upper;
this->GetFunctor().SetLowest(m_Lower);
this->GetFunctor().SetHighest(m_Upper);
this->GetFunctor().SetThresholds(m_Lower, m_Upper);
this->Modified();
}
}
......
......@@ -94,16 +94,12 @@ public:
return m_CompOut;
}
void SetLowest(OutputPixelValueType const& lowest) noexcept
void SetThresholds(OutputPixelValueType const& lowest, OutputPixelValueType const& highest) noexcept
{
assert( lowest <= highest );
m_LowestB = lowest;
m_Zero = clamp<ThresholdPixelValueType>(m_Zero, lowest, m_HighestB);
}
void SetHighest(OutputPixelValueType const& highest) noexcept
{
m_HighestB = highest;
m_Zero = clamp<ThresholdPixelValueType>(m_Zero, m_LowestB, highest);
m_Zero = clamp<ThresholdPixelValueType>(ThresholdPixelValueType{}, lowest, highest);
}
void operator()(OutputPixelType & out, InputPixelType const& in) const
......
......@@ -53,8 +53,7 @@ int otbClampImageFilterTest(int itkNotUsed(argc), char* argv[])
reader->SetFileName(argv[1]);
filter->SetInput(reader->GetOutput());
filter->SetLower(100);
filter->SetUpper(400);
filter->SetThresholds(100, 400);
writer->SetInput(filter->GetOutput());
writer->SetFileName(argv[2]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment