Commit 4b0265ef authored by Julien Michel's avatar Julien Michel

BUG: Correlation field does not contain inf values anymore

parent 8d2e8176
......@@ -204,6 +204,8 @@ private:
/** Precision used in subpixel mode */
unsigned int m_SubPixelPrecision;
double m_Epsilon;
};
} // end namespace otb
......
......@@ -29,7 +29,6 @@
namespace otb
{
/**
* Constructor
*/
......@@ -47,6 +46,9 @@ FineCorrelationImageFilter<TInputImage,T0utputCorrelation,TOutputDeformationFiel
// Default interpolator
m_Interpolator = itk::LinearInterpolateImageFunction<TInputImage,double>::New();
// Epsilon in correlation formula set to e-10
m_Epsilon = 0.0000000001;
}
template <class TInputImage, class T0utputCorrelation, class TOutputDeformationField>
......@@ -216,12 +218,14 @@ FineCorrelationImageFilter<TInputImage,TOutputCorrelation,TOutputDeformationFiel
}
double res = 0;
if( fSquareSum == 0. || mSquareSum == 0. )
double denom = fSquareSum*mSquareSum;
if( denom < m_Epsilon)
{
res = itk::NumericTraits<double>::max();
res = 0;
}
else
res = crossProductSum/vcl_sqrt(fSquareSum*mSquareSum);
res = crossProductSum/vcl_sqrt(denom);
return res;
}
......
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