Commit 295829f6 authored by Cédric Traizet's avatar Cédric Traizet

ENH: implement GetCorner() methods in Image and VectorImage

parent b4e73c1b
......@@ -199,6 +199,14 @@ public:
/** Get the six coefficients of affine geoTtransform. */
virtual VectorType GetGeoTransform(void) const;
/** Get image corners. */
// TODO: GenericRSTransform should be instanciated to translate from physical
// space to EPSG:4328 ?
VectorType GetUpperLeftCorner(void) const;
VectorType GetUpperRightCorner(void) const;
VectorType GetLowerLeftCorner(void) const;
VectorType GetLowerRightCorner(void) const;
/** Get signed spacing */
SpacingType GetSignedSpacing() const;
......
......@@ -153,6 +153,54 @@ typename Image<TPixel, VImageDimension>::VectorType Image<TPixel, VImageDimensio
}
template <class TPixel, unsigned int VImageDimension>
typename Image<TPixel, VImageDimension>::VectorType
Image<TPixel, VImageDimension>::GetUpperLeftCorner(void) const
{
PointType physicalPoint;
itk::ContinuousIndex<double, VImageDimension> index;
index.Fill(-0.5);
this->TransformContinuousIndexToPhysicalPoint (index, physicalPoint) ;
return {physicalPoint[0],physicalPoint[1]};
}
template <class TPixel, unsigned int VImageDimension>
typename Image<TPixel, VImageDimension>::VectorType
Image<TPixel, VImageDimension>::GetUpperRightCorner(void) const
{
PointType physicalPoint;
itk::ContinuousIndex<double, VImageDimension> index;
index.Fill(-0.5);
index[0] = -0.5 + this->GetLargestPossibleRegion().GetSize()[0];
this->TransformContinuousIndexToPhysicalPoint (index, physicalPoint) ;
return {physicalPoint[0],physicalPoint[1]};
}
template <class TPixel, unsigned int VImageDimension>
typename Image<TPixel, VImageDimension>::VectorType
Image<TPixel, VImageDimension>::GetLowerLeftCorner(void) const
{
PointType physicalPoint;
itk::ContinuousIndex<double, VImageDimension> index;
index.Fill(-0.5);
index[1] = -0.5 + this->GetLargestPossibleRegion().GetSize()[1];
this->TransformContinuousIndexToPhysicalPoint (index, physicalPoint) ;
return {physicalPoint[0],physicalPoint[1]};
}
template <class TPixel, unsigned int VImageDimension>
typename Image<TPixel, VImageDimension>::VectorType
Image<TPixel, VImageDimension>::GetLowerRightCorner(void) const
{
PointType physicalPoint;
itk::ContinuousIndex<double, VImageDimension> index;
index.Fill(-0.5);
index[0] = -0.5 + this->GetLargestPossibleRegion().GetSize()[0];
index[1] = -0.5 + this->GetLargestPossibleRegion().GetSize()[1];
this->TransformContinuousIndexToPhysicalPoint (index, physicalPoint) ;
return {physicalPoint[0],physicalPoint[1]};
}
template <class TPixel, unsigned int VImageDimension>
void Image<TPixel, VImageDimension>::PrintSelf(std::ostream& os, itk::Indent indent) const
{
......
......@@ -63,15 +63,6 @@ public:
double GetGCPY(unsigned int GCPnum) const;
double GetGCPZ(unsigned int GCPnum) const;
/** Get image corners. */
// TODO: move back to Image and VectorImage, compute corners in physical space,
// Then a GenericRSTransform should be instanciated to translate from physical
// space to EPSG:4328
ImageMetadataInterfaceBase::VectorType GetUpperLeftCorner(void) const;
ImageMetadataInterfaceBase::VectorType GetUpperRightCorner(void) const;
ImageMetadataInterfaceBase::VectorType GetLowerLeftCorner(void) const;
ImageMetadataInterfaceBase::VectorType GetLowerRightCorner(void) const;
/** Returns true if a sensor geometric model is present */
bool HasSensorGeometry() const;
......
......@@ -125,6 +125,15 @@ public:
/** Get the six coefficients of affine geoTtransform. */
virtual VectorType GetGeoTransform(void) const;
/** Get image corners. */
// TODO: GenericRSTransform should be instanciated to translate from physical
// space to EPSG:4328 ?
VectorType GetUpperLeftCorner(void) const;
VectorType GetUpperRightCorner(void) const;
VectorType GetLowerLeftCorner(void) const;
VectorType GetLowerRightCorner(void) const;
/** Get signed spacing */
SpacingType GetSignedSpacing() const;
......
......@@ -112,7 +112,7 @@ void VectorImage<TPixel, VImageDimension>::CopyInformation(const itk::DataObject
if (imc != nullptr)
{
const auto & imd = imc->GetImageMetadata();
std::cout << "hello " << this->GetNumberOfComponentsPerPixel() << std::endl;
if (imd.Bands.size() > 0 && imd.Bands.size() != this->GetNumberOfComponentsPerPixel())
{
SetImageMetadata(ImageMetadata(imd.GeometryKeys, imd.NumericKeys, imd.StringKeys, imd.LUT1DKeys,
......@@ -157,6 +157,55 @@ typename VectorImage<TPixel, VImageDimension>::VectorType VectorImage<TPixel, VI
return (geoTransform);
}
template <class TPixel, unsigned int VImageDimension>
typename VectorImage<TPixel, VImageDimension>::VectorType
VectorImage<TPixel, VImageDimension>::GetUpperLeftCorner(void) const
{
PointType physicalPoint;
itk::ContinuousIndex<double, VImageDimension> index;
index.Fill(-0.5);
this->TransformContinuousIndexToPhysicalPoint (index, physicalPoint) ;
return {physicalPoint[0],physicalPoint[1]};
}
template <class TPixel, unsigned int VImageDimension>
typename VectorImage<TPixel, VImageDimension>::VectorType
VectorImage<TPixel, VImageDimension>::GetUpperRightCorner(void) const
{
PointType physicalPoint;
itk::ContinuousIndex<double, VImageDimension> index;
index.Fill(-0.5);
index[0] = -0.5 + this->GetLargestPossibleRegion().GetSize()[0];
this->TransformContinuousIndexToPhysicalPoint (index, physicalPoint) ;
return {physicalPoint[0],physicalPoint[1]};
}
template <class TPixel, unsigned int VImageDimension>
typename VectorImage<TPixel, VImageDimension>::VectorType
VectorImage<TPixel, VImageDimension>::GetLowerLeftCorner(void) const
{
PointType physicalPoint;
itk::ContinuousIndex<double, VImageDimension> index;
index.Fill(-0.5);
index[1] = -0.5 + this->GetLargestPossibleRegion().GetSize()[1];
this->TransformContinuousIndexToPhysicalPoint (index, physicalPoint) ;
return {physicalPoint[0],physicalPoint[1]};
}
template <class TPixel, unsigned int VImageDimension>
typename VectorImage<TPixel, VImageDimension>::VectorType
VectorImage<TPixel, VImageDimension>::GetLowerRightCorner(void) const
{
PointType physicalPoint;
itk::ContinuousIndex<double, VImageDimension> index;
index.Fill(-0.5);
index[0] = -0.5 + this->GetLargestPossibleRegion().GetSize()[0];
index[1] = -0.5 + this->GetLargestPossibleRegion().GetSize()[1];
this->TransformContinuousIndexToPhysicalPoint (index, physicalPoint) ;
return {physicalPoint[0],physicalPoint[1]};
}
template <class TPixel, unsigned int VImageDimension>
typename VectorImage<TPixel, VImageDimension>::ImageMetadataInterfacePointerType VectorImage<TPixel, VImageDimension>::GetMetaDataInterface() const
{
......
......@@ -121,13 +121,6 @@ double ImageCommons::GetGCPZ(unsigned int GCPnum) const
}
ImageMetadataInterfaceBase::VectorType ImageCommons::GetUpperLeftCorner(void) const
{
//~ return {m_Imd.ULX, m_Imd.ULY};
return {};
}
ImageMetadataInterfaceBase::VectorType ImageCommons::GetUpperRightCorner(void) const
{
//~ return {m_Imd.URX, m_Imd.URY};
......
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