Commit fb3a4718 authored by Romain Garrigues's avatar Romain Garrigues
Browse files

MàJ de commentaires sur la partie Orthorectification

parent c6a476a6
......@@ -39,7 +39,6 @@ DEMReader
{
// not needed, m_ElevManager created with instance() method
// delete m_ElevManager;
}
......
......@@ -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
*
......
......@@ -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,
......
......@@ -48,10 +48,11 @@ CompositeTransform<TFirstTransform, TSecondTransform, TScalarType, NInputDimensi
SecondTransformOutputPointType point2;
pointTmp=m_FirstTransform->TransformPoint(point1);
//pointTmp=utmprojection->TransformPoint(point1);
otbMsgDevMacro(<< "Le point gographique correspondant est: ("<< pointTmp[0]<< ","<< pointTmp[1]<< ")");
point2=m_SecondTransform->TransformPoint(pointTmp);
otbMsgDevMacro(<< "Les coordonnes en pixel sur l'image capteur correspondant ce point sont:" << std::endl
<< point2[0] << ","<< point2[1] );
......
......@@ -79,10 +79,10 @@ public :
itkStaticConstMacro(OutputSpaceDimension, unsigned int, NOutputDimensions);
itkStaticConstMacro(ParametersDimension, unsigned int, NParametersDimensions); //A voir!!
// Pour projeter un point go sur l'image en gomtrie capteur.
// Transform of geographic point in image sensor index
OutputPointType TransformPoint(const InputPointType &point) const;
// Pour projeter un point go 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();
......
......@@ -47,8 +47,7 @@ InverseSensorModel< TScalarType,NInputDimensions,NOutputDimensions,NParametersDi
}
///Mthode 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;
}
}*/
///Mthode 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 mthode "lineSampleHeightToWorld" pour prendre en compte l'lvation.
//On stocke le resultat dans un "OutputPointType"
OutputPointType outputPoint;
outputPoint[0]=ossimDPoint.x;
outputPoint[1]=ossimDPoint.y;
......
......@@ -32,11 +32,15 @@ namespace otb
/**Template otbOrthoRectificationFilter.txx
* Cette classe permet de passer d'une MapProjection une autre en passant par un point gographique.
* Ceci pour viter TOUTES les combinaisons possibles de passage d'une proj. carto une autre.
* Template: Pour vrifier 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;
};
......
......@@ -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();
......
......@@ -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;
......
......@@ -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()
......@@ -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++)
{//dbut boucle principale
......@@ -265,10 +265,10 @@ geoPoint= utmprojection->TransformPoint(outputpoint);
otbMsgDevMacro(<< "Le point gographique correspondant est: ("<< geoPoint[0]<< ","<< geoPoint[1]<< ")");
//on calcule son altitude
height=otbElevManager->GetHeightAboveMSL(geoPoint);
//height=otbElevManager->GetHeightAboveMSL(geoPoint);
//On calcule les coordonnes pixeliques sur l'image capteur
inputpoint = model->TransformPoint(geoPoint, height);
inputpoint = model->TransformPoint(geoPoint/*, height*/);
otbMsgDevMacro(<< "Les coordonnes en pixel sur l'image capteur correspondant ce point sont:" << std::endl
<< inputpoint[0] << ","<< inputpoint[1] );
inputimage->TransformPhysicalPointToIndex(inputpoint,pixelindex);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment