Skip to content
Snippets Groups Projects
Commit 12fba8ef authored by Cédric Traizet's avatar Cédric Traizet
Browse files

BUG: don't copy metadata if the number of bands between source and target has changed

parent 17c1c8b1
No related branches found
No related tags found
No related merge requests found
......@@ -109,9 +109,20 @@ void Image<TPixel, VImageDimension>::CopyInformation(const itk::DataObject* data
this->itk::Object::SetMetaDataDictionary(data->GetMetaDataDictionary());
const ImageCommons* imc = dynamic_cast<const ImageCommons*>(data);
if (imc != nullptr)
{
const auto & imd = imc->GetImageMetadata();
if (imd.Bands.size() > 1)
{
SetImageMetadata(ImageMetadata(imd.GeometryKeys, imd.NumericKeys, imd.StringKeys, imd.LUT1DKeys,
imd.LUT2DKeys, imd.TimeKeys, imd.ExtraKeys, ImageMetadata::ImageMetadataBandsType(1)));
}
else
{
SetImageMetadata(imc->GetImageMetadata());
SetImageMetadata(imd);
}
}
}
template <class TPixel, unsigned int VImageDimension>
......
......@@ -110,9 +110,19 @@ void VectorImage<TPixel, VImageDimension>::CopyInformation(const itk::DataObject
this->itk::Object::SetMetaDataDictionary(data->GetMetaDataDictionary());
const ImageCommons* imc = dynamic_cast<const ImageCommons*>(data);
if (imc != nullptr)
{
const auto & imd = imc->GetImageMetadata();
if (imd.Bands.size() > 0 && imd.Bands.size() != this->GetNumberOfComponentsPerPixel())
{
SetImageMetadata(ImageMetadata(imd.GeometryKeys, imd.NumericKeys, imd.StringKeys, imd.LUT1DKeys,
imd.LUT2DKeys, imd.TimeKeys, imd.ExtraKeys, ImageMetadata::ImageMetadataBandsType(this->GetNumberOfComponentsPerPixel())));
}
else
{
SetImageMetadata(imc->GetImageMetadata());
SetImageMetadata(imd);
}
}
}
template <class TPixel, unsigned int VImageDimension>
......
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