diff --git a/Code/Projections/otbOrthoRectificationFilter.h b/Code/Projections/otbOrthoRectificationFilter.h index 3ba1f67e087f741cbd1bfac93328087fb9fe465d..e4f33b8bf9359aaf6cd6377c59e999e90241a998 100644 --- a/Code/Projections/otbOrthoRectificationFilter.h +++ b/Code/Projections/otbOrthoRectificationFilter.h @@ -55,6 +55,7 @@ class ITK_EXPORT OrthoRectificationFilter : public itk::ImageToImageFilter< TInp typedef typename ChangeInfoFilterType::Pointer ChangeInfoFilterPointer; typedef typename OrthoRectificationFilterBaseType::InputImageType InputImageType; + typedef typename OrthoRectificationFilterBaseType::OutputImageType OutputImageType; typedef typename OrthoRectificationFilterBaseType::MapProjectionType MapProjectionType; typedef typename OrthoRectificationFilterBaseType::InterpolatorType InterpolatorType; typedef typename OrthoRectificationFilterBaseType::IndexType IndexType; @@ -148,9 +149,11 @@ class ITK_EXPORT OrthoRectificationFilter : public itk::ImageToImageFilter< TInp /** Main computation method */ virtual void GenerateData(void); - + /** Generate Output Information */ - virtual void GenerateOutputInformation(); + virtual void GenerateOutputInformation(void); + + virtual void GenerateInputRequestedRegion(void); private: OrthoRectificationFilter(const Self&); //purposely not implemented diff --git a/Code/Projections/otbOrthoRectificationFilter.txx b/Code/Projections/otbOrthoRectificationFilter.txx index aa941fce5e9b36f643b62c12da51d6196b3fbab4..4970a6cb539385fd591cc675886dc2b65ce205d2 100644 --- a/Code/Projections/otbOrthoRectificationFilter.txx +++ b/Code/Projections/otbOrthoRectificationFilter.txx @@ -91,7 +91,22 @@ OrthoRectificationFilter< TInputImage, m_OrthoRectificationFilter->GenerateOutputInformation(); this->GetOutput()->CopyInformation(m_OrthoRectificationFilter->GetOutput()); } - +template < class TInputImage, + class TOutputImage, + class TMapProjection, + class TInterpolatorPrecision> +void +OrthoRectificationFilter< TInputImage, + TOutputImage, + TMapProjection, + TInterpolatorPrecision> +::GenerateInputRequestedRegion(void) +{ + Superclass::GenerateInputRequestedRegion(); + m_OrthoRectificationFilter->GetOutput()->UpdateOutputInformation(); + m_OrthoRectificationFilter->GetOutput()->SetRequestedRegion(this->GetOutput()->GetRequestedRegion()); + m_OrthoRectificationFilter->GetOutput()->PropagateRequestedRegion(); +} @@ -108,12 +123,12 @@ OrthoRectificationFilter< TInputImage, { // This is done here instead of inside the GenerateData() method so that the pipeline negociation // use the minipipeline instead of default ITK methods. - m_OrthoRectificationFilter->GraftOutput(this->GetOutput()); - //m_OrthoRectificationFilter->GetOutput()->UpdateOutputInformation(); - //m_OrthoRectificationFilter->GetOutput()->PropagateRequestedRegion(); - //m_OrthoRectificationFilter->GetOutput()->UpdateOutputData(); - m_OrthoRectificationFilter->Update(); - this->GraftOutput(m_OrthoRectificationFilter->GetOutput()); + m_OrthoRectificationFilter->GraftOutput(this->GetOutput()); +// m_OrthoRectificationFilter->GetOutput()->UpdateOutputInformation(); +// m_OrthoRectificationFilter->GetOutput()->PropagateRequestedRegion(); +// m_OrthoRectificationFilter->GetOutput()->UpdateOutputData(); + m_OrthoRectificationFilter->Update(); + this->GraftOutput(m_OrthoRectificationFilter->GetOutput()); //m_OrthoRectificationFilter->Update(); } diff --git a/Examples/Projections/OrthoRectificationExample.cxx b/Examples/Projections/OrthoRectificationExample.cxx index 4e9a0856401aec55844ae32cb31ab7f3fc970549..cbf59c680a8076e13fc8feb548c235264970a8ca 100644 --- a/Examples/Projections/OrthoRectificationExample.cxx +++ b/Examples/Projections/OrthoRectificationExample.cxx @@ -32,7 +32,6 @@ #include "otbImageFileReader.h" #include "otbStreamingImageFileWriter.h" -#include "itkChangeInformationImageFilter.h" #include "otbPerBandVectorImageFilter.h" #include "init/ossimInit.h" @@ -63,11 +62,11 @@ int main( int argc, char* argv[] ) { - ossimInit::instance()->initialize(argc, argv); + //ossimInit::instance()->initialize(argc, argv); if(argc!=9) { - std::cout << argv[0] <<" <input_filename> <output_filename> <x_ground_upper_left_corner> <y_ground_upper_left_corner> <x_Size> <y_Size> <x_groundSamplingDistance> <y_groundSamplingDistance (should be negative since origin is upper left)>" + std::cout << argv[0] <<" <input_filename> <output_filename> <x_ground_upper_left_corner> <y_ground_upper_left_corner> <x_Size> <y_Size> <x_groundSamplingDistance> <y_groundSamplingDistance> (should be negative since origin is upper left)>" << std::endl; return EXIT_FAILURE; @@ -149,38 +148,13 @@ int main( int argc, char* argv[] ) // Software Guide : EndCodeSnippet // Software Guide : BeginLatex -// -// Since the size of the output image will be fixed by the user and we -// are working with a stream-capable, synchronized pipeline, the -// ortho-rectification filter needs to know the input image size -// before the reader actually accesses the pixels. In order to make -// the pipeline aware of the input image size we execute the -// \code{GenerateOutputInformation()} method of the reader. Then we -// can plug the pipeline as usual. +// +// Wiring the orthorectification filter into a PerBandImageFilter allows +// to orthrectify images with multiple bands seamlesly. // // Software Guide : EndLatex - - - - - -// reader->GenerateOutputInformation(); -// -// typedef itk::ChangeInformationImageFilter<VectorImageType > ChangeInfoFilterType; -// ChangeInfoFilterType::Pointer changeInfo = ChangeInfoFilterType::New(); -// changeInfo->SetInput(reader->GetOutput()); -// changeInfo->ChangeOriginOn(); -// ImageType::PointType originNull; -// originNull[0]=0; -// originNull[1]=0; -// changeInfo->SetOutputOrigin(originNull); -// -// changeInfo->GenerateOutputInformation(); - -// orthoRectifFilter->SetInput(changeInfo->GetOutput()); - -// Software Guide : BeginCodeSnippet +// Software Guide : BeginCodeSnippet typedef otb::PerBandVectorImageFilter<VectorImageType, VectorImageType, OrthoRectifFilterType> PerBandFilterType; PerBandFilterType::Pointer perBandFilter=PerBandFilterType::New(); perBandFilter->SetFilter(orthoRectifFilter);