Commit eb97ca86 authored by Antoine Regimbeau's avatar Antoine Regimbeau

BUG: protect operation in DoUpdate with HasValue(in)

parent dede77ae
...@@ -192,26 +192,30 @@ private: ...@@ -192,26 +192,30 @@ private:
void DoUpdateParameters() ITK_OVERRIDE void DoUpdateParameters() ITK_OVERRIDE
{ {
// Read information // Read information
typedef otb::ImageMetadataInterfaceBase ImageMetadataInterfaceType; if ( HasValue("in") )
ImageMetadataInterfaceType::Pointer metadataInterface = {
typedef otb::ImageMetadataInterfaceBase ImageMetadataInterfaceType;
ImageMetadataInterfaceType::Pointer metadataInterface =
ImageMetadataInterfaceFactory::CreateIMI(GetParameterImage("in")->GetMetaDataDictionary()); ImageMetadataInterfaceFactory::CreateIMI(GetParameterImage("in")->GetMetaDataDictionary());
int nbBand = GetParameterImage("in")->GetNumberOfComponentsPerPixel(); int nbBand = GetParameterImage("in")->GetNumberOfComponentsPerPixel();
SetMaximumParameterIntValue("channels.grayscale.channel", nbBand); SetMaximumParameterIntValue("channels.grayscale.channel", nbBand);
SetMaximumParameterIntValue("channels.rgb.red", nbBand); SetMaximumParameterIntValue("channels.rgb.red", nbBand);
SetMaximumParameterIntValue("channels.rgb.green", nbBand); SetMaximumParameterIntValue("channels.rgb.green", nbBand);
SetMaximumParameterIntValue("channels.rgb.blue", nbBand); SetMaximumParameterIntValue("channels.rgb.blue", nbBand);
if (nbBand > 1) if (nbBand > 1)
{ {
// get band index : Red/Green/Blue // get band index : Red/Green/Blue
int bandRed = metadataInterface->GetDefaultDisplay()[0] + 1; int bandRed = metadataInterface->GetDefaultDisplay()[0] + 1;
int bandGreen = metadataInterface->GetDefaultDisplay()[1] + 1; int bandGreen = metadataInterface->GetDefaultDisplay()[1] + 1;
int bandBlue = metadataInterface->GetDefaultDisplay()[2] + 1; int bandBlue = metadataInterface->GetDefaultDisplay()[2] + 1;
SetDefaultParameterInt("channels.rgb.red", bandRed); SetDefaultParameterInt("channels.rgb.red", bandRed);
SetDefaultParameterInt("channels.rgb.green", bandGreen); SetDefaultParameterInt("channels.rgb.green", bandGreen);
SetDefaultParameterInt("channels.rgb.blue", bandBlue); SetDefaultParameterInt("channels.rgb.blue", bandBlue);
} }
}
} }
......
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