Skip to content
Snippets Groups Projects
Commit 74f2aed2 authored by Otmane Lahlou's avatar Otmane Lahlou
Browse files

ENH: use the min/max of the histogram to limit the asymptotes

parent d5269de5
No related branches found
No related tags found
No related merge requests found
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "otbCurves2DWidget.h" #include "otbCurves2DWidget.h"
#include "otbVerticalAsymptoteCurve.h" #include "otbVerticalAsymptoteCurve.h"
#include "itkNumericTraits.h"
namespace otb namespace otb
{ {
...@@ -129,14 +130,16 @@ public: ...@@ -129,14 +130,16 @@ public:
if (m_ModifyLeft) if (m_ModifyLeft)
{ {
double tx = x - abcisseL; double tx = x - abcisseL;
if ( m_LeftAsymptote->GetAbcisse() + tx < m_RightAsymptote->GetAbcisse()) double newLeftAbcisse = m_LeftAsymptote->GetAbcisse() + tx;
if ( newLeftAbcisse < m_RightAsymptote->GetAbcisse()
&& newLeftAbcisse >= m_MinimumAbcisse)
{ {
m_LeftAsymptote->SetAbcisse(m_LeftAsymptote->GetAbcisse() + tx); m_LeftAsymptote->SetAbcisse(newLeftAbcisse);
m_Curve->redraw(); m_Curve->redraw();
// Update The Rendering Function min and max // Update The Rendering Function min and max
ParametersType param = m_RenderingFunction->GetParameters(); ParametersType param = m_RenderingFunction->GetParameters();
param.SetElement(2 * m_Channel, m_LeftAsymptote->GetAbcisse() + tx); param.SetElement(2 * m_Channel, newLeftAbcisse);
param.SetElement(2 * m_Channel + 1, m_RightAsymptote->GetAbcisse()); param.SetElement(2 * m_Channel + 1, m_RightAsymptote->GetAbcisse());
m_RenderingFunction->SetParameters(param); m_RenderingFunction->SetParameters(param);
} }
...@@ -145,15 +148,18 @@ public: ...@@ -145,15 +148,18 @@ public:
if (m_ModifyRight) if (m_ModifyRight)
{ {
double tx = x - abcisseR; double tx = x - abcisseR;
if (m_RightAsymptote->GetAbcisse() + tx > m_LeftAsymptote->GetAbcisse()) double newRightAbcisse = m_RightAsymptote->GetAbcisse() + tx;
//std::cout <<"right abcisse "<< newRightAbcisse << " max "<< m_MaximumAbcisse << std::endl;
if (newRightAbcisse > m_LeftAsymptote->GetAbcisse()
&& newRightAbcisse < m_MaximumAbcisse)
{ {
m_RightAsymptote->SetAbcisse(m_RightAsymptote->GetAbcisse() + tx); m_RightAsymptote->SetAbcisse(newRightAbcisse + tx);
m_Curve->redraw(); m_Curve->redraw();
// Update The Rendering Function min and max // Update The Rendering Function min and max
ParametersType param = m_RenderingFunction->GetParameters(); ParametersType param = m_RenderingFunction->GetParameters();
param.SetElement(2 * m_Channel, m_LeftAsymptote->GetAbcisse()); param.SetElement(2 * m_Channel, m_LeftAsymptote->GetAbcisse());
param.SetElement(2 * m_Channel + 1, m_RightAsymptote->GetAbcisse() + tx); param.SetElement(2 * m_Channel + 1, newRightAbcisse);
m_RenderingFunction->SetParameters(param); m_RenderingFunction->SetParameters(param);
} }
} }
...@@ -182,6 +188,12 @@ public: ...@@ -182,6 +188,12 @@ public:
/** Set/Get the rendering Function */ /** Set/Get the rendering Function */
itkSetObjectMacro(RenderingFunction, RenderingFunctionType); itkSetObjectMacro(RenderingFunction, RenderingFunctionType);
/** Set Extremum of the histogram (used as limit for the
* asymptotes). If not set, values are initialized to double type extremum
*/
itkSetMacro(MaximumAbcisse, double);
itkSetMacro(MinimumAbcisse, double);
/** Set/Get the channel dealed with in the image*/ /** Set/Get the channel dealed with in the image*/
itkSetMacro(Channel, unsigned int); itkSetMacro(Channel, unsigned int);
...@@ -192,6 +204,8 @@ protected: ...@@ -192,6 +204,8 @@ protected:
m_Channel = 0; m_Channel = 0;
m_ModifyLeft = false; m_ModifyLeft = false;
m_ModifyRight = false; m_ModifyRight = false;
m_MaximumAbcisse = itk::NumericTraits<double>::max();
m_MinimumAbcisse = itk::NumericTraits<double>::NonpositiveMin();
} }
/** Destructor */ /** Destructor */
...@@ -229,6 +243,10 @@ private: ...@@ -229,6 +243,10 @@ private:
//Channel we're dealing handling //Channel we're dealing handling
unsigned int m_Channel; unsigned int m_Channel;
// extremum of the histogram used as limit for the abcisse
double m_MaximumAbcisse;
double m_MinimumAbcisse;
}; // end class }; // end class
} // end namespace otb } // end namespace otb
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment