Skip to content
Snippets Groups Projects
Commit fae31275 authored by Patrick Imbo's avatar Patrick Imbo
Browse files

ENH: add condition when GetNumberOfBands ==0 than R =0 G = 1 B = 2

parent 494b0625
No related branches found
No related tags found
No related merge requests found
......@@ -162,13 +162,22 @@ public:
unsigned int i = 0;
std::vector<unsigned int> rgb(3);
unsigned int min;
min = std::min(this->GetNumberOfBands(), static_cast<unsigned int>(3));
while( i < min )
if (this->GetNumberOfBands() == 0)
{
rgb[0] = 0;
rgb[1] = 1;
rgb[2] = 2;
}
else
{
rgb[i] = i;
++i;
unsigned int min;
min = std::min(this->GetNumberOfBands(), static_cast<unsigned int> (3));
while (i < min)
{
rgb[i] = i;
++i;
}
}
return rgb;
}
......
......@@ -331,12 +331,6 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
{
std::cout << "ExceptionObject caught for CanRead() !" << std::endl;
std::cout << err << std::endl;
hasRisedException =true;
}
if(!hasRisedException)
{
std::cerr << " Should has raise an exception !"<< std::endl;
return EXIT_FAILURE;
}
......@@ -344,30 +338,21 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
try
{
std::vector<unsigned int> rgb(3);
rgb = obj->GetDefaultDisplay();
std::vector<unsigned int> rgb(3);
rgb = obj->GetDefaultDisplay();
if( rgb[0] != 0 || rgb[1] != 0 || rgb[2] != 0 )
{
std::cout << "wrong value for GetDefaultDisplay() method!" << std::endl;
return EXIT_FAILURE;
}
if (obj->GetNumberOfBands() != 0 && rgb[0] != 0 && rgb[1] != 1 && rgb[2] != 2)
{
std::cout << "wrong value for GetDefaultDisplay() method!" << std::endl;
return EXIT_FAILURE;
}
}
catch (itk::ExceptionObject& err)
{
std::cout << "ExceptionObject caught for GetDefaultDisplay() !" << std::endl;
std::cout << err << std::endl;
hasRisedException =true;
}
if(!hasRisedException)
{
std::cerr << " Should has raise an exception !"<< std::endl;
return EXIT_FAILURE;
}
hasRisedException = false;
return EXIT_SUCCESS;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment