diff --git a/Examples/Projections/test/CMakeLists.txt b/Examples/Projections/test/CMakeLists.txt index d1ad300506a769e19cf24ed9747982cd7a4c5048..768d49630df27a20cf546cbf0dc2e9422ec8640a 100644 --- a/Examples/Projections/test/CMakeLists.txt +++ b/Examples/Projections/test/CMakeLists.txt @@ -48,7 +48,7 @@ otb_add_test(NAME prTeVectorDataProjectionExampleTest COMMAND ${OTB_TEST_DRIVER} ${BASELINE}/vectorDataProjectionExample.shp ${TEMP}/vectorDataProjectionExample.shp Execute $<TARGET_FILE:VectorDataProjectionExample> - ${INPUTDATA}/Capitole-Shadows.kml + ${OTB_DATA_ROOT}/Examples/Capitole-Shadows.kml LARGEINPUT{QUICKBIRD/TOULOUSE/000000128955_01_P001_PAN/02APR01105228-P1BS-000000128955_01_P001.TIF} ${TEMP}/vectorDataProjectionExample.shp ) @@ -58,7 +58,7 @@ otb_add_test(NAME prTeGeometriesProjectionTest COMMAND ${OTB_TEST_DRIVER} ${BASELINE}/geometriesProjectionExample.shp ${TEMP}/geometriesProjectionExample.shp Execute $<TARGET_FILE:GeometriesProjectionExample> - ${INPUTDATA}/Capitole-Shadows.shp + ${OTB_DATA_ROOT}/Examples/Capitole-Shadows.shp LARGEINPUT{QUICKBIRD/TOULOUSE/000000128955_01_P001_PAN/02APR01105228-P1BS-000000128955_01_P001.TIF} ${TEMP}/geometriesProjectionExample.shp ) diff --git a/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.h index 841117429ac4d12b5f4a3a83dae272d5164816ba..71230c936c8dc49e53e2903af502c169a1830078 100644 --- a/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.h @@ -171,6 +171,9 @@ public: m_DisplacementFilter->SetNumberOfThreads(nbThread); } + /** Override itk::ProcessObject method to let the internal filter do the propagation */ + virtual void PropagateRequestedRegion(itk::DataObject *output); + protected: StreamingResampleImageFilter(); @@ -181,8 +184,6 @@ protected: virtual void GenerateOutputInformation(); - virtual void GenerateInputRequestedRegion(); - void PrintSelf(std::ostream& os, itk::Indent indent) const; private: diff --git a/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.txx b/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.txx index 03ad4382b8651617bc2104bf0b3c89d22010afa4..8543b9e8881d3f3fe80db35cff33602cbc7eae74 100644 --- a/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.txx +++ b/Modules/Filtering/ImageManipulation/include/otbStreamingResampleImageFilter.txx @@ -50,7 +50,7 @@ StreamingResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecisionTy progress->RegisterInternalFilter(m_WarpFilter, 1.f); m_WarpFilter->GraftOutput(this->GetOutput()); - m_WarpFilter->Update(); + m_WarpFilter->UpdateOutputData(m_WarpFilter->GetOutput()); this->GraftOutput(m_WarpFilter->GetOutput()); } @@ -62,41 +62,14 @@ void StreamingResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecisionType> ::GenerateOutputInformation() { - // call the superclass's implementation of this method - Superclass::GenerateOutputInformation(); - - typename OutputImageType::Pointer outputPtr = this->GetOutput(); - - outputPtr->SetSpacing( this->GetOutputSpacing() ); - outputPtr->SetOrigin( this->GetOutputOrigin() ); - - typename OutputImageType::RegionType region; - region.SetSize( this->GetOutputSize() ); - region.SetIndex(this->GetOutputStartIndex() ); - - outputPtr->SetLargestPossibleRegion(region); - // check the output spacing of the displacement field if(this->GetDisplacementFieldSpacing()== itk::NumericTraits<SpacingType>::ZeroValue()) { this->SetDisplacementFieldSpacing(2.*this->GetOutputSpacing()); } -} - -template <class TInputImage, class TOutputImage, class TInterpolatorPrecisionType> -void -StreamingResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecisionType> -::GenerateInputRequestedRegion() -{ - // Retrieve output pointer - OutputImageType * outputPtr = this->GetOutput(); - // Retrieve input pointer - const InputImageType * inputPtr = this->GetInput(); - - // Retrieve output requested region - RegionType requestedRegion = outputPtr->GetRequestedRegion(); - SizeType largestSize = outputPtr->GetLargestPossibleRegion().GetSize(); + // Retrieve output largest region + SizeType largestSize = this->GetOutputSize(); // Set up displacement field filter SizeType displacementFieldLargestSize; @@ -117,10 +90,20 @@ StreamingResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecisionTy m_DisplacementFilter->SetOutputSize(displacementFieldLargestSize); m_DisplacementFilter->SetOutputIndex(this->GetOutputStartIndex()); - // Generate input requested region - m_WarpFilter->SetInput(inputPtr); - m_WarpFilter->GetOutput()->UpdateOutputInformation(); - m_WarpFilter->GetOutput()->SetRequestedRegion(requestedRegion); + m_WarpFilter->SetInput(this->GetInput()); + m_WarpFilter->GraftOutput(this->GetOutput()); + m_WarpFilter->UpdateOutputInformation(); + this->GraftOutput(m_WarpFilter->GetOutput()); +} + +template <class TInputImage, class TOutputImage, class TInterpolatorPrecisionType> +void +StreamingResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecisionType> +::PropagateRequestedRegion(itk::DataObject *output) +{ + if (this->m_Updating) return; + + m_WarpFilter->GetOutput()->SetRequestedRegion(output); m_WarpFilter->GetOutput()->PropagateRequestedRegion(); } diff --git a/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.h b/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.h index 2b5c5a7f4d7c5c2af5f873172a490d6ca4c1db68..9442c163080f9e2770395788828ccfacdee21dae 100644 --- a/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.h +++ b/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.h @@ -264,6 +264,9 @@ public: m_Resampler->SetDisplacementFilterNumberOfThreads(nbThread); } + /** Override itk::ProcessObject method to let the internal filter do the propagation */ + virtual void PropagateRequestedRegion(itk::DataObject *output); + protected: GenericRSResampleImageFilter(); /** Destructor */ @@ -273,8 +276,6 @@ protected: virtual void GenerateOutputInformation(); - virtual void GenerateInputRequestedRegion(); - virtual void UpdateTransform(); void PrintSelf(std::ostream& os, itk::Indent indent) const; diff --git a/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx b/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx index 42eedb9ba479812413b7fae52aacad766fc6a243..a18dabf09aa8fb846a47750566db9bc813af35b7 100644 --- a/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx +++ b/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx @@ -67,7 +67,7 @@ GenericRSResampleImageFilter<TInputImage, TOutputImage> progress->RegisterInternalFilter(m_Resampler, 1.f); m_Resampler->GraftOutput(this->GetOutput()); - m_Resampler->Update(); + m_Resampler->UpdateOutputData(m_Resampler->GetOutput()); this->GraftOutput(m_Resampler->GetOutput()); } @@ -82,20 +82,8 @@ void GenericRSResampleImageFilter<TInputImage, TOutputImage> ::GenerateOutputInformation() { - // call the superclass's implementation of this method - Superclass::GenerateOutputInformation(); - typename OutputImageType::Pointer outputPtr = this->GetOutput(); - outputPtr->SetSpacing( this->GetOutputSpacing() ); - outputPtr->SetOrigin( this->GetOutputOrigin() ); - - typename OutputImageType::RegionType region; - region.SetSize(this->GetOutputSize()); - region.SetIndex(this->GetOutputStartIndex() ); - - outputPtr->SetLargestPossibleRegion(region); - // Get the Output MetaData Dictionary itk::MetaDataDictionary& dict = outputPtr->GetMetaDataDictionary(); @@ -112,6 +100,13 @@ GenericRSResampleImageFilter<TInputImage, TOutputImage> // Estimate the output rpc Model if needed if (m_EstimateOutputRpcModel) this->EstimateOutputRpcModel(); + + m_Resampler->SetInput(this->GetInput()); + m_Resampler->SetTransform(m_Transform); + m_Resampler->SetDisplacementFieldSpacing(this->GetDisplacementFieldSpacing()); + m_Resampler->GraftOutput(this->GetOutput()); + m_Resampler->UpdateOutputInformation(); + this->GraftOutput(m_Resampler->GetOutput()); } /** @@ -128,7 +123,11 @@ GenericRSResampleImageFilter<TInputImage, TOutputImage> // Temp image : not allocated but with the same metadata than the // output typename OutputImageType::Pointer tempPtr = OutputImageType::New(); - tempPtr->SetRegions(this->GetOutput()->GetLargestPossibleRegion()); + + typename OutputImageType::RegionType region; + region.SetSize(this->GetOutputSize()); + region.SetIndex(this->GetOutputStartIndex() ); + tempPtr->SetRegions(region); // Encapsulate the output metadata in the temp image itk::MetaDataDictionary& tempDict = tempPtr->GetMetaDataDictionary(); @@ -171,41 +170,26 @@ GenericRSResampleImageFilter<TInputImage, TOutputImage> m_Transform->InstanciateTransform(); } - /** - * Generate Input requested region does only propagate the output - * requested region. - */ - template <class TInputImage, class TOutputImage> - void - GenericRSResampleImageFilter<TInputImage, TOutputImage> - ::GenerateInputRequestedRegion() - { - // Retrieve output pointer - OutputImageType * outputPtr = this->GetOutput(); - - // Retrieve input pointer - const InputImageType * inputPtr = this->GetInput(); - - // Retrieve output requested region - RegionType requestedRegion = outputPtr->GetRequestedRegion(); - - // Estimate the input rpc model if it is needed - if (m_EstimateInputRpcModel && !m_RpcEstimationUpdated) - { - this->EstimateInputRpcModel(); - } - - // Instanciate the RS transform - this->UpdateTransform(); - - // Generate input requested region - m_Resampler->SetInput(inputPtr); - m_Resampler->SetTransform(m_Transform); - m_Resampler->SetDisplacementFieldSpacing(this->GetDisplacementFieldSpacing()); - m_Resampler->GetOutput()->UpdateOutputInformation(); - m_Resampler->GetOutput()->SetRequestedRegion(requestedRegion); - m_Resampler->GetOutput()->PropagateRequestedRegion(); - } +template <class TInputImage, class TOutputImage> +void +GenericRSResampleImageFilter<TInputImage, TOutputImage> +::PropagateRequestedRegion(itk::DataObject *output) +{ + if (this->m_Updating) return; + + // Estimate the input rpc model if it is needed + if (m_EstimateInputRpcModel && !m_RpcEstimationUpdated) + { + this->EstimateInputRpcModel(); + } + + // Instanciate the RS transform + this->UpdateTransform(); + + // Retrieve output requested region + m_Resampler->GetOutput()->SetRequestedRegion(output); + m_Resampler->GetOutput()->PropagateRequestedRegion(); +} /**