diff --git a/Code/IO/otbDEMReader.cxx b/Code/IO/otbDEMReader.cxx index 6500a1fe4226d8848bbd46e059497d618081cea6..4f280524617757a75a5d1e15a560593a62c7021a 100644 --- a/Code/IO/otbDEMReader.cxx +++ b/Code/IO/otbDEMReader.cxx @@ -39,7 +39,6 @@ DEMReader { // not needed, m_ElevManager created with instance() method // delete m_ElevManager; - } diff --git a/Code/IO/otbDEMReader.h b/Code/IO/otbDEMReader.h index 2b6326a97d4b4a8d44988ad53613bab81d237e36..f0c186a16e54e68049309040864965912a0075b9 100755 --- a/Code/IO/otbDEMReader.h +++ b/Code/IO/otbDEMReader.h @@ -34,7 +34,8 @@ namespace otb * * \brief Class for Reading a DEM data * - * This class is based on ossimElevManager. It takes in input the UL and LR geographic coordinates and the spacing. + * This class is based on ossimElevManager. + * It allows to obtain height above MSL(Mean Sea Level) of a geographic point * Handle DTED and SRTM formats. * \ingroup Images * diff --git a/Code/Projections/otbCompositeTransform.h b/Code/Projections/otbCompositeTransform.h index bd13645b73894ac133dde9f0e4c87e94f7699a5b..ba9e8e4eda3c5da378cd5b817215d06593a03763 100644 --- a/Code/Projections/otbCompositeTransform.h +++ b/Code/Projections/otbCompositeTransform.h @@ -36,6 +36,7 @@ namespace otb * (x,y) -> (x',y') -> (x'',y'') => (x,y) -> (x'',y'') * \ingroup Transform */ + template <class TFirstTransform, class TSecondTransform, class TScalarType=double, diff --git a/Code/Projections/otbCompositeTransform.txx b/Code/Projections/otbCompositeTransform.txx index 4566dec01139e107009d3839e249f98fd8b50ccd..a17b35af34272013aa959da13a3eef285874c902 100644 --- a/Code/Projections/otbCompositeTransform.txx +++ b/Code/Projections/otbCompositeTransform.txx @@ -48,10 +48,11 @@ CompositeTransform<TFirstTransform, TSecondTransform, TScalarType, NInputDimensi SecondTransformOutputPointType point2; pointTmp=m_FirstTransform->TransformPoint(point1); - //pointTmp=utmprojection->TransformPoint(point1); + otbMsgDevMacro(<< "Le point g�ographique correspondant est: ("<< pointTmp[0]<< ","<< pointTmp[1]<< ")"); point2=m_SecondTransform->TransformPoint(pointTmp); + otbMsgDevMacro(<< "Les coordonn�es en pixel sur l'image capteur correspondant � ce point sont:" << std::endl << point2[0] << ","<< point2[1] ); diff --git a/Code/Projections/otbInverseSensorModel.h b/Code/Projections/otbInverseSensorModel.h index 9f8426f32e476787da57480a06134bd4d12cacaa..0d7528bcb9faba3e1a5aa983e93eb25866645c5c 100644 --- a/Code/Projections/otbInverseSensorModel.h +++ b/Code/Projections/otbInverseSensorModel.h @@ -79,10 +79,10 @@ public : itkStaticConstMacro(OutputSpaceDimension, unsigned int, NOutputDimensions); itkStaticConstMacro(ParametersDimension, unsigned int, NParametersDimensions); //A voir!! - // Pour projeter un point g�o sur l'image en g�om�trie capteur. + // Transform of geographic point in image sensor index OutputPointType TransformPoint(const InputPointType &point) const; - // Pour projeter un point g�o connaissant son altitude. - OutputPointType TransformPoint(const InputPointType &point, double height) const; + // Transform of geographic point in image sensor index -- Backward Compatibility +// OutputPointType TransformPoint(const InputPointType &point, double height) const; itkGetMacro(UseDEM, bool); itkSetMacro(UseDEM, bool); @@ -99,14 +99,15 @@ public : } } - virtual void SetDEMDirectory(const std::string& directory) + virtual bool SetDEMDirectory(const std::string& directory) { - m_DEMHandler->OpenDEMDirectory(directory.c_str()); - m_UseDEM = true; + bool b = m_DEMHandler->OpenDEMDirectory(directory.c_str()); + this->UseDEM(true); + + return b; } - void ActiveDEM() { m_UseDEM = true; this->Modified(); } - void DesactiveDEM() { m_UseDEM = false; this->Modified();} + virtual void UseDEM(bool b) { m_UseDEM = b; this->Modified(); } protected: InverseSensorModel(); diff --git a/Code/Projections/otbInverseSensorModel.txx b/Code/Projections/otbInverseSensorModel.txx index b2c8f02e4cdf6d6ed1037f84ad92956ef734bc7e..6f3e87f765ceafe8d62e40dec142c5966f274e8b 100644 --- a/Code/Projections/otbInverseSensorModel.txx +++ b/Code/Projections/otbInverseSensorModel.txx @@ -47,8 +47,7 @@ InverseSensorModel< TScalarType,NInputDimensions,NOutputDimensions,NParametersDi } -///M�thode InverseTransformPoint: -template < class TScalarType, +/*template < class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions, unsigned int NParametersDimensions > @@ -56,13 +55,9 @@ typename InverseSensorModel< TScalarType,NInputDimensions,NOutputDimensions,NPar InverseSensorModel< TScalarType,NInputDimensions,NOutputDimensions,NParametersDimensions> ::TransformPoint(const InputPointType &point, double height) const { -// std::cout << "INVERSESENSORMODEL MIARY" << std::endl; -// std::cout << "InverseSensorModel Before : (" << point[0] << "," << point[1] << ")" << std::endl; - - //On transforme le type "itk::point" en type "ossim::ossimGpt" + // Transformation of "itk::point" in "ossim::ossimGpt" ossimGpt ossimGPoint(point[0], point[1], height); - //On calcule ossimDpt ossimDPoint; if( this->m_Model == NULL) @@ -72,16 +67,13 @@ InverseSensorModel< TScalarType,NInputDimensions,NOutputDimensions,NParametersDi this->m_Model->worldToLineSample(ossimGPoint, ossimDPoint); - //On stocke le resultat dans un "OutputPointType" OutputPointType outputPoint; outputPoint[0]=ossimDPoint.x; outputPoint[1]=ossimDPoint.y; -// std::cout << "InverseSensorModel After : (" << outputPoint[0] << "," << outputPoint[1] << ")" << std::endl; return outputPoint; -} +}*/ -///M�thode InverseTransformPoint en tenant compte de l'altitude: template < class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions, @@ -90,20 +82,17 @@ typename InverseSensorModel< TScalarType,NInputDimensions,NOutputDimensions,NPar InverseSensorModel< TScalarType,NInputDimensions,NOutputDimensions,NParametersDimensions> ::TransformPoint(const InputPointType &point) const { - //On transforme le type "itk::point" en type "ossim::ossimGpt" - ossimGpt ossimGPoint(point[0], point[1]); + // Transformation of "itk::point" in "ossim::ossimGpt" + ossimGpt ossimGPoint(point[0], point[1]); if (m_UseDEM) { otbMsgDebugMacro(<< "USING DEM ! ") ; double height = m_DEMHandler->GetHeightAboveMSL(point); -// ossimGpt ossimGPoint(point[0], point[1], height); otbMsgDebugMacro(<< "height : " << height) ; ossimGPoint.height(height); -// ossimGPoint.height(height); } - //On calcule ossimDpt ossimDPoint; if( this->m_Model == NULL) @@ -112,7 +101,6 @@ InverseSensorModel< TScalarType,NInputDimensions,NOutputDimensions,NParametersDi } this->m_Model->worldToLineSample(ossimGPoint, ossimDPoint); //"worldToLineSample" appelle la m�thode "lineSampleHeightToWorld" pour prendre en compte l'�l�vation. - //On stocke le resultat dans un "OutputPointType" OutputPointType outputPoint; outputPoint[0]=ossimDPoint.x; outputPoint[1]=ossimDPoint.y; diff --git a/Code/Projections/otbOrthoRectificationFilter.h b/Code/Projections/otbOrthoRectificationFilter.h index 3f322bca8778b23457c8b76be4498de9872ae8be..4b002e68f8c83604f773e34c3386d30e1003f433 100644 --- a/Code/Projections/otbOrthoRectificationFilter.h +++ b/Code/Projections/otbOrthoRectificationFilter.h @@ -32,11 +32,15 @@ namespace otb -/**Template otbOrthoRectificationFilter.txx -* Cette classe permet de passer d'une MapProjection � une autre en passant par un point g�ographique. -* Ceci pour �viter TOUTES les combinaisons possibles de passage d'une proj. carto � une autre. -* Template: Pour v�rifier les types. -**/ +/** \class OrthoRectificationFilter +* +* \brief Class for Orthorectifying an image +* +* This class is used to apply map projection and sensor model transformation +* to orthorectify an image, with or without DEM +* +*/ + template <class TInputImage, class TOutputImage, class TMapProjection, @@ -88,23 +92,21 @@ public : itkGetObjectMacro(MapProjection, MapProjectionType); - virtual void SetDEMDirectory(const std::string& directory) + /** Specify where are DEM files, and load useful ones */ + virtual bool SetDEMDirectory(const std::string& directory) { - m_SensorModel->SetDEMDirectory(directory); + bool b = m_SensorModel->SetDEMDirectory(directory); this->Modified(); + + return b; } - virtual void ActiveDEM() - { - m_SensorModel->ActiveDEM(); - } - - virtual void DesactiveDEM() + /** Method to decide to use DEM */ + virtual void UseDEM(bool b) { - m_SensorModel->DesactiveDEM(); + m_SensorModel->UseDEM(b); } - - + protected: OrthoRectificationFilter(); ~OrthoRectificationFilter(); @@ -121,16 +123,18 @@ private: /** Calculate transformation model from sensor model & map projection composition */ void ComputeResampleTransformationModel(); - /** Boolean used to know if transformation model computation is needed */ bool m_IsComputed; + /** Sensor Model used to transform geographic coordinates in image sensor index */ SensorModelPointerType m_SensorModel; + + /** Map Projection used to transform cartographic coordinates in geographic coordinates */ MapProjectionPointerType m_MapProjection; - CompositeTransformPointerType m_CompositeTransform; - - + /** Composite Transform of Sensor Model and Map Projection, used for Resampler */ + CompositeTransformPointerType m_CompositeTransform; + }; diff --git a/Code/Projections/otbOrthoRectificationFilter.txx b/Code/Projections/otbOrthoRectificationFilter.txx index 29a71bc5a5b3a130ab73c740884c2c9497ebfd38..f800ec0ac799f2ca2e0f2cafeca76d96d389b8dc 100644 --- a/Code/Projections/otbOrthoRectificationFilter.txx +++ b/Code/Projections/otbOrthoRectificationFilter.txx @@ -17,30 +17,9 @@ =========================================================================*/ #ifndef _otbOrthoRectificationFilter_txx #define _otbOrthoRectificationFilter_txx -#include "otbOrthoRectificationFilter.h" - -#include "itkLinearInterpolateImageFunction.h" - -/*#include "itkObjectFactory.h" -#include "itkConvertPixelBuffer.h" -#include "itkImageRegion.h" -#include "itkPixelTraits.h" -#include "itkVectorImage.h" -#include "itkMetaDataObject.h" -#include "otbMacro.h" -#include "otbSystem.h" -#include "otbImageIOFactory.h" -#include "otbMetaDataKey.h" -#include "otbImageKeywordlist.h" - -#include "imaging/ossimImageHandlerRegistry.h" -#include "imaging/ossimImageHandler.h" -#include "init/ossimInit.h" -#include "base/ossimKeywordlist.h" +#include "otbOrthoRectificationFilter.h" -#include <itksys/SystemTools.hxx> -#include <fstream>*/ namespace otb { @@ -50,7 +29,6 @@ template <class TInputImage, class TOutputImage, class TMapProjection, class TIn OrthoRectificationFilter<TInputImage, TOutputImage, TMapProjection, TInterpolatorPrecision> ::OrthoRectificationFilter() : otb::StreamingResampleImageFilter<TInputImage, TOutputImage,TInterpolatorPrecision>() { -// m_Resampler = ResamplerType::New(); m_SensorModel = SensorModelType::New(); m_MapProjection = MapProjectionType::New(); m_CompositeTransform = CompositeTransformType::New(); diff --git a/Testing/Code/IO/otbDEMReaderTest.cxx b/Testing/Code/IO/otbDEMReaderTest.cxx index de93d021be20b3a22a9a9ff04c49595ca9d295aa..c59592e34410c06d5c9a02d73f9162b7603e84d5 100644 --- a/Testing/Code/IO/otbDEMReaderTest.cxx +++ b/Testing/Code/IO/otbDEMReaderTest.cxx @@ -52,12 +52,12 @@ int otbDEMReaderTest(int argc, char * argv[]) height=demReader->GetHeightAboveMSL(geoPoint); - std::ofstream file; - file.open(outputfilename); - file << "--- HEIGHT ABOVE MSL TEST ---" << std::endl; - file << " geoPoint: "<<geoPoint[0]<<" ; "<<geoPoint[1]<< std::endl; + std::ofstream file; + file.open(outputfilename); + file << "--- HEIGHT ABOVE MSL TEST ---" << std::endl; + file << " geoPoint: "<<geoPoint[0]<<" ; "<<geoPoint[1]<< std::endl; file << " -> Height: "<<height<< std::endl; - file.close(); + file.close(); std::cout << "Height: "<<height<<std::endl; diff --git a/Testing/Code/Projections/otbOrthoRectificationFilterWithDEM.cxx b/Testing/Code/Projections/otbOrthoRectificationFilterWithDEM.cxx index ee497bc22df1431ed1d9e76178db7ae3a2b03e2d..7ee1327af7cb20121103989d3ecb91afcd7e9426 100644 --- a/Testing/Code/Projections/otbOrthoRectificationFilterWithDEM.cxx +++ b/Testing/Code/Projections/otbOrthoRectificationFilterWithDEM.cxx @@ -73,11 +73,9 @@ int otbOrthoRectificationFilterWithDEM( int argc, char* argv[] ) typedef otb::Image<unsigned int, 2> ImageType; typedef otb::ImageFileReader<ImageType> ReaderType; -// typedef otb::ImageFileWriter<ImageType> WriterType; typedef otb::StreamingImageFileWriter<ImageType> WriterType; typedef itk::Transform<double,2,2> TransformType; -// typedef otb::InverseSensorModel<double> ModelType; typedef itk::LinearInterpolateImageFunction<ImageType, double > InterpolatorType; typedef otb::StreamingResampleImageFilter<ImageType,ImageType> ResamplerType; @@ -88,7 +86,6 @@ int otbOrthoRectificationFilterWithDEM( int argc, char* argv[] ) //Allocate pointer ReaderType::Pointer reader=ReaderType::New(); WriterType::Pointer writer=WriterType::New(); -// ModelType::Pointer model=ModelType::New(); InterpolatorType::Pointer interpolator=InterpolatorType::New(); ModelType::Pointer model= ModelType::New(); @@ -103,8 +100,6 @@ int otbOrthoRectificationFilterWithDEM( int argc, char* argv[] ) reader->GenerateOutputInformation(); model->SetImageGeometry(reader->GetOutput()->GetImageKeywordlist()); -// std::cout << "Model1: " << model << std::endl; - orthoRectifFilter->SetInput(reader->GetOutput()); ImageType::IndexType start; @@ -137,7 +132,7 @@ int otbOrthoRectificationFilterWithDEM( int argc, char* argv[] ) writer->SetInput(orthoRectifFilter->GetOutput()); writer->SetTilingStreamDivisions(); - // writer->SetNumberOfStreamDivisions(1000); + otbGenericMsgDebugMacro(<< "Update writer ..." ); writer->Update(); @@ -160,5 +155,5 @@ int otbOrthoRectificationFilterWithDEM( int argc, char* argv[] ) } return EXIT_SUCCESS; - }//Fin main() + } //End main() diff --git a/Testing/Code/Projections/otbSensorImageDEMToCarto.cxx b/Testing/Code/Projections/otbSensorImageDEMToCarto.cxx index 37373db5f7a5f80faf9ab17dc83ed1ae79d5e512..90266781974c1c96b4450960178093d5aeaf2f9f 100755 --- a/Testing/Code/Projections/otbSensorImageDEMToCarto.cxx +++ b/Testing/Code/Projections/otbSensorImageDEMToCarto.cxx @@ -219,7 +219,7 @@ int max_x, max_y, min_x, min_y; ImageType::IndexType iterationRegionStart; ImageType::SizeType iteratorRegionSize; ImageType::RegionType iteratorRegion; -if (otbElevManager->OpenDEMDirectory(argv[8])) +if (model->SetDEMDirectory(argv[8])) { for(count=0;count<NumberOfStreamDivisions;count++) {//d�but boucle principale @@ -265,10 +265,10 @@ geoPoint= utmprojection->TransformPoint(outputpoint); otbMsgDevMacro(<< "Le point g�ographique correspondant est: ("<< geoPoint[0]<< ","<< geoPoint[1]<< ")"); //on calcule son altitude -height=otbElevManager->GetHeightAboveMSL(geoPoint); +//height=otbElevManager->GetHeightAboveMSL(geoPoint); //On calcule les coordonn�es pixeliques sur l'image capteur -inputpoint = model->TransformPoint(geoPoint, height); +inputpoint = model->TransformPoint(geoPoint/*, height*/); otbMsgDevMacro(<< "Les coordonn�es en pixel sur l'image capteur correspondant � ce point sont:" << std::endl << inputpoint[0] << ","<< inputpoint[1] ); inputimage->TransformPhysicalPointToIndex(inputpoint,pixelindex);