Skip to content
Snippets Groups Projects
Commit 533a9d5d authored by Manuel Grizonnet's avatar Manuel Grizonnet
Browse files

ENH: display estimated ground spacing instead of pixel spacing in dataset property

parent 434fcb7e
No related branches found
No related tags found
No related merge requests found
......@@ -222,6 +222,12 @@ public:
*/
inline const SpacingType& GetNativeSpacing() const;
/**
* \return The estimated spacing of the native image at full resolution
*
*/
inline const SpacingType& GetEstimatedGroundSpacing() const;
/** */
inline CountType GetNbComponents() const;
......@@ -322,6 +328,12 @@ protected:
*/
SpacingType m_NativeSpacing;
/**
* The estimated spacing of the native image at full resolution which is, by
* default, display in image info.
*/
SpacingType m_EstimatedGroundSpacing;
/*-[ PRIVATE SECTION ]-----------------------------------------------------*/
//
......@@ -491,6 +503,16 @@ AbstractImageModel
return m_NativeSpacing;
}
/*****************************************************************************/
inline
const SpacingType&
AbstractImageModel
::GetEstimatedGroundSpacing() const
{
return m_EstimatedGroundSpacing;
}
/*****************************************************************************/
inline
CountType
......
......@@ -629,9 +629,9 @@ DatasetModel
porigin.second = ToStdString( viModel->ToImageBase()->GetOrigin() );
//
pspacing.first = ToStdString ( tr("Pixels size") );
pspacing.second = ToStdString( viModel->GetNativeSpacing() );
pspacing.first = ToStdString ( tr("Estimated ground spacing") );
pspacing.second = ToStdString( viModel->GetEstimatedGroundSpacing() );
//
pnbcomp.first = ToStdString ( tr("Number of components") );
pnbcomp.second = ToStdString( viModel->ToImageBase()->GetNumberOfComponentsPerPixel() );
......
......@@ -33,6 +33,7 @@
// ITK includes (sorted by alphabetic order)
#include "itkImageRegionConstIteratorWithIndex.h"
#include "itksys/SystemTools.hxx"
#include "vnl/vnl_random.h"
//
// OTB includes (sorted by alphabetic order)
......@@ -42,6 +43,7 @@
#include "otbGeoInformationConversion.h"
#include "otbCoordinateToName.h"
#include "otbDEMHandler.h"
#include "otbGroundSpacingImageFunction.h"
//
// Monteverdi includes (sorted by alphabetic order)
......@@ -124,12 +126,35 @@ VectorImageModel
// Remember native spacing
m_NativeSpacing = m_ImageFileReader->GetOutput()->GetSpacing();
// Setup GenericRSTransform
m_GenericRSTransform = otb::GenericRSTransform<>::New();
m_GenericRSTransform->SetInputDictionary(m_ImageFileReader->GetOutput()->GetMetaDataDictionary());
m_GenericRSTransform->SetOutputProjectionRef(otb::GeoInformationConversion::ToWKT(4326));
m_GenericRSTransform->InstanciateTransform();
//Compute estimated spacing here
//m_EstimatedGroundSpacing
m_EstimatedGroundSpacing = m_NativeSpacing;
typedef otb::GroundSpacingImageFunction<VectorImageType> GroundSpacingImageType;
GroundSpacingImageType::Pointer GroundSpacing = GroundSpacingImageType::New();
GroundSpacing->SetInputImage(m_ImageFileReader->GetOutput());
if (m_GenericRSTransform->IsUpToDate())
{
if (m_GenericRSTransform->GetTransformAccuracy() != otb::Projection::UNKNOWN)
{
IndexType index;
vnl_random rand;
index[0] = static_cast<IndexType::IndexValueType>(rand.lrand32(0, m_ImageFileReader->GetOutput()->GetLargestPossibleRegion().GetSize()[0]));
index[1] = static_cast<IndexType::IndexValueType>(rand.lrand32(0, m_ImageFileReader->GetOutput()->GetLargestPossibleRegion().GetSize()[1]));
m_EstimatedGroundSpacing = GroundSpacing->EvaluateAtIndex(index);
}
}
//
// 2. Setup file-reader.
SetupCurrentLodImage(w, h);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment