diff --git a/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.txx b/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.txx index 922d831dbda55ce2389ec9e0a6726dbf13be58ce..c1927f0cba3c827246f0b80bdb6f54453fb94d1b 100644 --- a/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.txx +++ b/Modules/Segmentation/Conversion/include/otbOGRDataSourceToLabelImageFilter.txx @@ -117,21 +117,13 @@ void OGRDataSourceToLabelImageFilter<TOutputImage> ::SetOutputParametersFromImage(const ImageBaseType * image) { - if (dynamic_cast<const OutputImageType*>(image)) - { - const OutputImageType * src = dynamic_cast<const OutputImageType*>(image); - - this->SetOutputOrigin ( src->GetOrigin() ); - this->SetOutputSpacing ( src->GetSpacing() ); - //this->SetOutputStartIndex ( src->GetLargestPossibleRegion().GetIndex() ); - this->SetOutputSize ( src->GetLargestPossibleRegion().GetSize() ); - this->SetOutputProjectionRef(src->GetProjectionRef()); - //this->SetOutputKeywordList(src->GetImageKeywordlist()); - } - else - { - itkExceptionMacro(<< "Image can't be casted to output image type."); - } + this->SetOutputOrigin ( image->GetOrigin() ); + this->SetOutputSpacing ( image->GetSpacing() ); + this->SetOutputSize ( image->GetLargestPossibleRegion().GetSize() ); + + ImageMetadataInterfaceBase::Pointer imi = ImageMetadataInterfaceFactory::CreateIMI(image->GetMetaDataDictionary()); + + this->SetOutputProjectionRef(imi->GetProjectionRef()); } template< class TOutputImage>