Skip to content

Commit

Permalink
Merge pull request #33 from ngageoint/add_pixel_to_image_point
Browse files Browse the repository at this point in the history
Adding convenience pixelToImagePoint() methods
  • Loading branch information
asylvest committed Nov 30, 2015
2 parents efef573 + 4f4080f commit 11a5419
Show file tree
Hide file tree
Showing 9 changed files with 276 additions and 89 deletions.
50 changes: 2 additions & 48 deletions modules/c++/samples/test_image_to_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,52 +38,6 @@

namespace
{
types::RowCol<double> pixelToImagePoint(const six::sicd::ComplexData& data,
const types::RowCol<double>& pixelLoc)
{
const six::sicd::ImageData& imageData(*data.imageData);
const types::RowCol<double> scpPixel(imageData.scpPixel);
const types::RowCol<double> aoiOffset(imageData.firstRow,
imageData.firstCol);

const types::RowCol<double> offset(scpPixel - aoiOffset);

const types::RowCol<double> sampleSpacing(
data.grid->row->sampleSpacing,
data.grid->col->sampleSpacing);

const types::RowCol<double> imagePt(
(pixelLoc.row - offset.row) * sampleSpacing.row,
(pixelLoc.col - offset.col) * sampleSpacing.col);

return imagePt;
}

types::RowCol<double> pixelToImagePoint(const six::sidd::DerivedData& data,
const types::RowCol<double>& pixelLoc)
{
const types::RowCol<double> posRC(pixelLoc);
types::RowCol<double> fullScenePos;
if (data.downstreamReprocessing.get() &&
data.downstreamReprocessing->geometricChip.get())
{
fullScenePos = data.downstreamReprocessing->geometricChip->
getFullImageCoordinateFromChip(posRC);
}
else
{
fullScenePos = posRC;
}

const six::sidd::MeasurableProjection* projection(reinterpret_cast<six::sidd::MeasurableProjection*>(
data.measurement->projection.get()));
const types::RowCol<double> ctrPt = projection->referencePoint.rowCol;

return types::RowCol<double>(
(fullScenePos.row - ctrPt.row) * projection->sampleSpacing.row,
(fullScenePos.col - ctrPt.col) * projection->sampleSpacing.col);
}

std::ostream& operator<<(std::ostream& os, const scene::LatLonAlt& lla)
{
os << "(" << lla.getLat() << ", " << lla.getLon() << ", "
Expand Down Expand Up @@ -138,7 +92,7 @@ int main(int argc, char** argv)
geom.reset(six::sicd::Utilities::getSceneGeometry(data));
projection.reset(six::sicd::Utilities::getProjectionModel(
data, geom.get()));
imagePt = pixelToImagePoint(*data, pixelLoc);
imagePt = data->pixelToImagePoint(pixelLoc);
}
else if (container->getDataType() == six::DataType::DERIVED)
{
Expand All @@ -148,7 +102,7 @@ int main(int argc, char** argv)
projection = six::sidd::Utilities::getProjectionModel(data);
geom = six::sidd::Utilities::getSceneGeometry(data);
std::cout << geom->getReferencePosition() << std::endl;
imagePt = pixelToImagePoint(*data, pixelLoc);
imagePt = data->pixelToImagePoint(pixelLoc);
}
else
{
Expand Down
6 changes: 6 additions & 0 deletions modules/c++/six.sicd/include/six/sicd/ComplexData.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,12 @@ class ComplexData: public Data
types::RowCol<size_t>& offset,
types::RowCol<size_t>& extent) const;

/*
* Convert the slant plane pixel location into meters from the SCP
*/
types::RowCol<double>
pixelToImagePoint(const types::RowCol<double>& pixelLoc) const;

private:
static const char VENDOR_ID[];

Expand Down
19 changes: 19 additions & 0 deletions modules/c++/six.sicd/source/ComplexData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,24 @@ void ComplexData::getOutputPlaneOffsetAndExtent(
}
}
}

types::RowCol<double>
ComplexData::pixelToImagePoint(const types::RowCol<double>& pixelLoc) const
{
const types::RowCol<double> scpPixel(imageData->scpPixel);
const types::RowCol<double> aoiOffset(imageData->firstRow,
imageData->firstCol);

const types::RowCol<double> offset(scpPixel - aoiOffset);

const types::RowCol<double> sampleSpacing(grid->row->sampleSpacing,
grid->col->sampleSpacing);

const types::RowCol<double> imagePt(
(pixelLoc.row - offset.row) * sampleSpacing.row,
(pixelLoc.col - offset.col) * sampleSpacing.col);

return imagePt;
}
}
}
9 changes: 8 additions & 1 deletion modules/c++/six.sidd/include/six/sidd/DerivedData.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,14 @@ struct DerivedData: public Data
virtual void setVersion(const std::string& version)
{
mVersion = version;
}
}

/*
* Convert the output plane pixel location into meters from the reference
* point
*/
types::RowCol<double>
pixelToImagePoint(const types::RowCol<double>& pixelLoc) const;

private:
static const char VENDOR_ID[];
Expand Down
36 changes: 35 additions & 1 deletion modules/c++/six.sidd/source/DerivedData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
* see <http://www.gnu.org/licenses/>.
*
*/
#include "six/sidd/DerivedData.h"
#include <sys/Conf.h>
#include <except/Exception.h>
#include <six/sidd/DerivedData.h>

namespace six
{
Expand Down Expand Up @@ -47,6 +49,38 @@ DateTime DerivedData::getCollectionStartDateTime() const
}

return exploitationFeatures->collections[0]->information->collectionDateTime;
}

types::RowCol<double>
DerivedData::pixelToImagePoint(const types::RowCol<double>& pixelLoc) const
{
const types::RowCol<double> posRC(pixelLoc);
types::RowCol<double> fullScenePos;
if (downstreamReprocessing.get() &&
downstreamReprocessing->geometricChip.get())
{
fullScenePos = downstreamReprocessing->geometricChip->
getFullImageCoordinateFromChip(posRC);
}
else
{
fullScenePos = posRC;
}

if (!measurement->projection->isMeasurable())
{
throw except::Exception(Ctxt(
"Currently require a measurable projection type"));
}

const six::sidd::MeasurableProjection* projection =
reinterpret_cast<six::sidd::MeasurableProjection*>(
measurement->projection.get());
const types::RowCol<double> ctrPt = projection->referencePoint.rowCol;

return types::RowCol<double>(
(fullScenePos.row - ctrPt.row) * projection->sampleSpacing.row,
(fullScenePos.col - ctrPt.col) * projection->sampleSpacing.col);
}
}
}
2 changes: 1 addition & 1 deletion modules/python/scene/source/generated/scene.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.5
# Version 3.0.7
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
Expand Down
Loading

0 comments on commit 11a5419

Please sign in to comment.