Commit c0755656 authored by Guillaume Pasero's avatar Guillaume Pasero

COV: divide by zero fixes and better LUT parsing in ColorMapping

parent 9b9c2624
......@@ -35,6 +35,11 @@ typedef otb::GeographicalDistance<Point2DType> GeoDistanceType;
int otbRPCSolverAdapterTest(int argc, char* argv[])
{
if (argc < 7)
{
std::cout << "Usage: test_driver input grid_size geo_tol img_tol dem_dir geoid" << std::endl;
return EXIT_FAILURE;
}
// This test takes a sensor model (possibly a rpc one), use it to
// generate gcps and estimate a rpc model. It then checks the
// precision of both forward and inverse transform
......@@ -45,6 +50,12 @@ int otbRPCSolverAdapterTest(int argc, char* argv[])
const std::string demdir = argv[5];
const std::string geoid = argv[6];
if (gridSize == 0)
{
std::cerr << "Grid size is null!" << std::endl;
return EXIT_FAILURE;
}
std::cout<<"GeoTol: "<<geoTol<<" meters"<<std::endl;
std::cout<<"ImgTol: "<<imgTol<<" pixels"<<std::endl;
......
......@@ -774,22 +774,36 @@ private:
if (!line.empty() && line[0] != '#')
{
// retrieve the label
std::string::size_type pos = line.find_first_of(" ", 0);
LabelType clabel = atoi(line.substr(0, pos).c_str());
++pos;
std::string::size_type length;
std::string::size_type pos = line.find_first_not_of(" \t;,", 0);
if (pos == std::string::npos)
continue;
std::string::size_type nextpos = line.find_first_of(" \t;,", pos);
if (nextpos == std::string::npos)
continue;
length = nextpos - pos;
LabelType clabel = atoi(line.substr(pos, length).c_str());
// Retrieve the color
VectorPixelType color(3);
color.Fill(0);
for (unsigned int i = 0; i < 3; ++i)
unsigned int i;
for (i = 0; i < 3; ++i)
{
std::string::size_type nextpos = line.find_first_of(" ", pos);
int value = atoi(line.substr(pos, nextpos).c_str());
if (nextpos == std::string::npos)
break;
pos = line.find_first_not_of(" \t;,", nextpos);
if (pos == std::string::npos)
break;
nextpos = line.find_first_of(" \t;,", pos);
length = ( nextpos == std::string::npos ? std::string::npos : nextpos - pos );
int value = atoi(line.substr(pos, length).c_str());
if (value < 0 || value > 255)
otbAppLogWARNING("WARNING: color value outside 8-bits range (<0 or >255). Value will be clamped." << std::endl);
color[i] = static_cast<PixelType> (value);
pos = nextpos + 1;
nextpos = line.find_first_of(" ", pos);
}
// test if 3 values have been parsed
if (i < 3)
continue;
otbAppLogINFO("Adding color mapping " << clabel << " -> [" << (int) color[0] << " " << (int) color[1] << " "<< (int) color[2] << " ]" << std::endl);
if(putLabelBeforeColor)
{
......
......@@ -68,9 +68,9 @@ int otbAngularProjectionBinaryImageFilterTest ( int argc, char * argv[] )
return EXIT_FAILURE;
}
const char * inputImageName1 = parseResult->GetParameterString("--InputImages", 0).c_str();
const char * inputImageName2 = parseResult->GetParameterString("--InputImages", 1).c_str();
const char * outputImageName = parseResult->GetParameterString("--OutputImages").c_str();
std::string inputImageName1(parseResult->GetParameterString("--InputImages", 0));
std::string inputImageName2(parseResult->GetParameterString("--InputImages", 1));
std::string outputImageName(parseResult->GetParameterString("--OutputImages"));
// Main type definition
const unsigned int Dimension = 2;
......
......@@ -39,9 +39,19 @@ int otbGaussianAdditiveNoiseSampleListFilterNew(int itkNotUsed(argc), char * itk
int otbGaussianAdditiveNoiseSampleListFilter(int argc, char * argv[])
{
if (argc < 4)
{
std::cout << "Usage : test_driver output_filename sample_size samples... " << std::endl;
return EXIT_FAILURE;
}
// Compute the number of samples
const char * outfname = argv[1];
unsigned int sampleSize = atoi(argv[2]);
if (sampleSize == 0)
{
std::cerr << "Sample size is null!" << std::endl;
return EXIT_FAILURE;
}
unsigned int nbSamples = (argc-3)/sampleSize;
FloatSampleListType::Pointer inputSampleList = FloatSampleListType::New();
......
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