Skip to content
Snippets Groups Projects
Commit 39dde69d authored by Thomas Feuvrier's avatar Thomas Feuvrier
Browse files

BUG: Improve FlexibleDistanceWithMissingValue testing with epsilon value in testing parameters

parent aec43f21
No related branches found
No related tags found
No related merge requests found
...@@ -831,7 +831,9 @@ ${TEMP}/bfTvVectorImageToAmplitudeImageFilterOutput.tif ...@@ -831,7 +831,9 @@ ${TEMP}/bfTvVectorImageToAmplitudeImageFilterOutput.tif
otbFlexibleDistanceWithMissingValueNew) otbFlexibleDistanceWithMissingValueNew)
ADD_TEST(bfTuFlexibleDistanceWithMissingValue ${BASICFILTERS_TESTS8} ADD_TEST(bfTuFlexibleDistanceWithMissingValue ${BASICFILTERS_TESTS8}
otbFlexibleDistanceWithMissingValue) otbFlexibleDistanceWithMissingValue
0.00000001
)
# ------- otb::LabelizeNeighborhoodConnectedImageFilter ---------------------------- # ------- otb::LabelizeNeighborhoodConnectedImageFilter ----------------------------
......
...@@ -21,6 +21,7 @@ PURPOSE. See the above copyright notices for more information. ...@@ -21,6 +21,7 @@ PURPOSE. See the above copyright notices for more information.
#include <iostream> #include <iostream>
#include <cstdlib> #include <cstdlib>
#include <iomanip>
#include "itkVariableLengthVector.h" #include "itkVariableLengthVector.h"
#include "otbFlexibleDistanceWithMissingValue.h" #include "otbFlexibleDistanceWithMissingValue.h"
...@@ -30,7 +31,7 @@ int otbFlexibleDistanceWithMissingValue( int argc, char * argv[] ) ...@@ -30,7 +31,7 @@ int otbFlexibleDistanceWithMissingValue( int argc, char * argv[] )
typedef itk::VariableLengthVector< double > VectorType; typedef itk::VariableLengthVector< double > VectorType;
typedef otb::Statistics::FlexibleDistanceWithMissingValue< VectorType > DistanceType; typedef otb::Statistics::FlexibleDistanceWithMissingValue< VectorType > DistanceType;
const double epsilon = 0.00000001; const double epsilon(atof(argv[1]));
float a = 2.0; float a = 2.0;
float b = 0.5; float b = 0.5;
...@@ -45,7 +46,12 @@ int otbFlexibleDistanceWithMissingValue( int argc, char * argv[] ) ...@@ -45,7 +46,12 @@ int otbFlexibleDistanceWithMissingValue( int argc, char * argv[] )
DistanceType::Pointer dist = DistanceType::New(); DistanceType::Pointer dist = DistanceType::New();
double distanceValue = dist->Evaluate( x, y ); double distanceValue = dist->Evaluate( x, y );
std::cout << "Distance: " << distanceValue << std::endl; std::cout << std::setprecision(20)<< std::endl;
std::cout << "dim,a,b : " << dim<<","<<a<<","<<b<< std::endl;
std::cout << "dim*vcl_pow(3,b) : " << dim*vcl_pow(3,b) << std::endl;
std::cout << "Distance : " << distanceValue << std::endl;
std::cout << "Epsilon : " << epsilon << std::endl;
std::cout << "-> Tests diff : " << vcl_abs(distanceValue - dim*vcl_pow(3,b)) << std::endl;
if ( vcl_abs(distanceValue - dim*vcl_pow(3,b)) < epsilon ) if ( vcl_abs(distanceValue - dim*vcl_pow(3,b)) < epsilon )
return EXIT_SUCCESS; return EXIT_SUCCESS;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment