OSSIM - Open Source Software Image Map
Version 1.9.0 (20180803)
|
This currently only support Rational poilynomial B format. More...
#include <ossimRpcSolver.h>
Public Member Functions | |
ossimRpcSolver (bool useElevation=false, bool useHeightAboveMSLFlag=false) | |
The use elvation flag will deterimne if we force the height t be 0. More... | |
virtual | ~ossimRpcSolver () |
void | solveCoefficients (const ossimDrect &imageBounds, ossimProjection *imageProj, ossim_uint32 xSamples=8, ossim_uint32 ySamples=8) |
This will convert any projector to an RPC model. More... | |
void | solveCoefficients (const ossimDrect &imageBounds, ossimImageGeometry *geom, ossim_uint32 xSamples=8, ossim_uint32 ySamples=8) |
bool | solve (const ossimDrect &aoiBounds, ossimImageGeometry *geom, const double &pixel_tolerance=0.5) |
Similar to the other solve methods except that the final grid size is established iteratively so that the error at the midpoints between grid nodes falls below tolerance. More... | |
bool | solve (const ossimFilename &imageFilename, const double &pixel_tolerance=0.5) |
Performs iterative solve using the other solve method, but uses an image filename to initialize, and computes RPC over entire image rect. More... | |
void | solveCoefficients (const std::vector< ossimDpt > &imagePoints, const std::vector< ossimGpt > &groundControlPoints) |
takes associated image points and ground points and solves the coefficents for the rational polynomial for line and sample calculations from world points. More... | |
const ossimRefPtr< ossimRpcModel > | getRpcModel () const |
Fetches the solved-for RPC model. More... | |
double | getRmsError () const |
double | getMaxError () const |
ossimRefPtr< ossimNitfRegisteredTag > | getNitfRpcBTag () const |
void | setValidImageRect (const ossimIrect &imageRect) |
Sets the image rect over which to compute the RPCs. More... | |
![]() | |
ossimReferenced () | |
ossimReferenced (const ossimReferenced &) | |
ossimReferenced & | operator= (const ossimReferenced &) |
void | ref () const |
increment the reference count by one, indicating that this object has another pointer which is referencing it. More... | |
void | unref () const |
decrement the reference count by one, indicating that a pointer to this object is referencing it. More... | |
void | unref_nodelete () const |
decrement the reference count by one, indicating that a pointer to this object is referencing it. More... | |
int | referenceCount () const |
Protected Member Functions | |
virtual void | solveInitialCoefficients (NEWMAT::ColumnVector &coeff, const std::vector< double > &f, const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z) const |
virtual void | solveCoefficients (NEWMAT::ColumnVector &coeff, const std::vector< double > &f, const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z) const |
double | eval (const std::vector< double > &coeff, const double &x, const double &y, const double &z) const |
void | evalPoint (const ossimGpt &gpt, ossimDpt &ipt) const |
NEWMAT::Matrix | invert (const NEWMAT::Matrix &m) const |
Inverts using the SVD method. More... | |
void | setupSystemOfEquations (NEWMAT::Matrix &equations, const NEWMAT::ColumnVector &f, const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z) const |
void | setupWeightMatrix (NEWMAT::DiagonalMatrix &result, const NEWMAT::ColumnVector &coefficients, const NEWMAT::ColumnVector &f, const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z) const |
![]() | |
virtual | ~ossimReferenced () |
Protected Attributes | |
bool | theUseElevationFlag |
bool | theHeightAboveMSLFlag |
ossim_float64 | theMeanResidual |
ossim_float64 | theMaxResidual |
ossimRefPtr< ossimImageGeometry > | theRefGeom |
ossimRefPtr< ossimRpcModel > | theRpcModel |
This currently only support Rational poilynomial B format.
This can be found in the NITF registered commercial tag document.
Format is: coeff[ 0] + coeff[ 1]*x + coeff[ 2]*y + coeff[ 3]*z + coeff[ 4]*x*y + coeff[ 5]*x*z + coeff[ 6]*y*z + coeff[ 7]*x*x + coeff[ 8]*y*y + coeff[ 9]*z*z + coeff[10]*x*y*z + coeff[11]*x*x*x + coeff[12]*x*y*y + coeff[13]*x*z*z + coeff[14]*x*x*y + coeff[15]*y*y*y + coeff[16]*y*z*z + coeff[17]*x*x*z + coeff[18]*y*y*z + coeff[19]*z*z*z;where coeff is one of XNum, XDen, YNum, and YDen. So there are 80 coefficients all together.
Currently we use a linear least squares fit to solve the coefficients. This is the simplest to implement. We probably relly need a nonlinear minimizer to fit the coefficients but I don't have time to experiment. Levenberg Marquardt might be a solution to look into.
HOW TO USE:ossimRpcSolver solver; solver.solveCoefficients(rect, *proj.get());
We can also call solve coefficients with a list of ground control points. First is the list of image points followed by the ground points. NOTE: Thes must be equal in size.solver.solveCoefficients(imagePoints, groundPoints);
Once you call solveCoefficients you can create the projector:ossimRefPtr<ossimRpcProjection> rpc = solver.createRpcProjection();
Note that a sub-image bounding rect can be passed into the solve methods. This constrains the solution fit to cover only that rectangle in the original image space, but the image coordinates used are still based on the full image. If the intent is to generate an RPC that will work for an image chip in that chip's local image coordinate system (i.e., the UL corner of the chip is 0, 0), then you'll need to call rpcModel->setImageOffset(chip_offset) on the output RPC model.
Definition at line 72 of file ossimRpcSolver.h.
ossimRpcSolver::ossimRpcSolver | ( | bool | useElevation = false , |
bool | useHeightAboveMSLFlag = false |
||
) |
The use elvation flag will deterimne if we force the height t be 0.
If the elevation is enabled then we use the height field of the control points to determine the coefficients of the RPC00 polynomial. If its false then we will ignore the height by setting the height field to 0.0.
Note: even if the elevation is enabled all NAN heights are set to 0.0.
Definition at line 21 of file ossimRpcSolver.cpp.
|
inlinevirtual |
Definition at line 86 of file ossimRpcSolver.h.
|
protected |
Definition at line 677 of file ossimRpcSolver.cpp.
References ossimDpt::makeNan(), theRpcModel, and ossimRpcModel::worldToLineSample().
Referenced by solveCoefficients().
double ossimRpcSolver::getMaxError | ( | ) | const |
ossimRefPtr< ossimNitfRegisteredTag > ossimRpcSolver::getNitfRpcBTag | ( | ) | const |
Definition at line 689 of file ossimRpcSolver.cpp.
References ossimNitfRpcBase::setRpcModelParams(), and theRpcModel.
Referenced by ossimNitfWriterBase::addRpcbTag().
double ossimRpcSolver::getRmsError | ( | ) | const |
Definition at line 421 of file ossimRpcSolver.cpp.
References theMeanResidual.
Referenced by ossimRpcProjection::optimizeFit().
|
inline |
Fetches the solved-for RPC model.
See note in header above on setting the image offset if this model will be applied to a sub-image chip.
Definition at line 138 of file ossimRpcSolver.h.
Referenced by ossimDemTool::doASP(), ossimSubImageTool::execute(), and ossimRpcProjection::optimizeFit().
|
protected |
Inverts using the SVD method.
Definition at line 544 of file ossimRpcSolver.cpp.
References FLT_EPSILON, and SVD().
Referenced by solveCoefficients(), and solveInitialCoefficients().
|
protected |
Definition at line 576 of file ossimRpcSolver.cpp.
Referenced by solveCoefficients(), and solveInitialCoefficients().
|
protected |
Definition at line 629 of file ossimRpcSolver.cpp.
References FLT_EPSILON, x, and y.
Referenced by solveCoefficients().
void ossimRpcSolver::setValidImageRect | ( | const ossimIrect & | imageRect | ) |
Sets the image rect over which to compute the RPCs.
The Resulting RPC will only be valid over that range of image space.
bool ossimRpcSolver::solve | ( | const ossimDrect & | aoiBounds, |
ossimImageGeometry * | geom, | ||
const double & | pixel_tolerance = 0.5 |
||
) |
Similar to the other solve methods except that the final grid size is established iteratively so that the error at the midpoints between grid nodes falls below tolerance.
The RPC is computed for the specified image bounds range only, not the full image. The expectation here (when the imageBounds is less than the full valid image rect) is to generate an RPC to accompany a subimage that will be written to disk.
imageBounds | The AOI in image space for the RPC computation. |
geom | Represents the geometry of the input image |
pixel_tolerance | Maximum error in pixels (typically fraction of a pixel) to achieve. |
Definition at line 290 of file ossimRpcSolver.cpp.
References ossimDrect::height(), theRefGeom, ossimDrect::ul(), and ossimDrect::width().
Referenced by ossimDemTool::doASP(), ossimSubImageTool::execute(), and solve().
bool ossimRpcSolver::solve | ( | const ossimFilename & | imageFilename, |
const double & | pixel_tolerance = 0.5 |
||
) |
Performs iterative solve using the other solve method, but uses an image filename to initialize, and computes RPC over entire image rect.
Definition at line 406 of file ossimRpcSolver.cpp.
References ossimRefPtr< T >::get(), ossimImageHandler::getBoundingRect(), ossimImageHandler::getImageGeometry(), ossimImageHandlerRegistry::instance(), ossimImageHandlerRegistry::open(), solve(), and ossimRefPtr< T >::valid().
void ossimRpcSolver::solveCoefficients | ( | const ossimDrect & | imageBounds, |
ossimProjection * | imageProj, | ||
ossim_uint32 | xSamples = 8 , |
||
ossim_uint32 | ySamples = 8 |
||
) |
This will convert any projector to an RPC model.
Definition at line 29 of file ossimRpcSolver.cpp.
References ossimRefPtr< T >::get(), and ossimImageGeometry::setProjection().
Referenced by ossimNitfWriterBase::addRpcbTag(), ossimRpcProjection::optimizeFit(), and solveCoefficients().
void ossimRpcSolver::solveCoefficients | ( | const ossimDrect & | imageBounds, |
ossimImageGeometry * | geom, | ||
ossim_uint32 | xSamples = 8 , |
||
ossim_uint32 | ySamples = 8 |
||
) |
Definition at line 39 of file ossimRpcSolver.cpp.
References ossimImageGeometry::getProjection(), theRefGeom, x, and y.
void ossimRpcSolver::solveCoefficients | ( | const std::vector< ossimDpt > & | imagePoints, |
const std::vector< ossimGpt > & | groundControlPoints | ||
) |
takes associated image points and ground points and solves the coefficents for the rational polynomial for line and sample calculations from world points.
Note: All data will be normalized between -1 and 1 for numerical robustness.
Definition at line 93 of file ossimRpcSolver.cpp.
References ossimRpcModel::B, DBL_EPSILON, evalPoint(), FLT_EPSILON, ossimGpt::height(), ossimDrect::height(), ossim::isnan(), ossimDrect::midPoint(), solveCoefficients(), ossimRpcModel::theHgtOffset, ossimRpcModel::theHgtScale, ossimRpcModel::theLatOffset, ossimRpcModel::theLatScale, ossimRpcModel::theLineDenCoef, ossimRpcModel::theLineNumCoef, ossimRpcModel::theLineOffset, ossimRpcModel::theLineScale, ossimRpcModel::theLonOffset, ossimRpcModel::theLonScale, theMaxResidual, theMeanResidual, ossimRpcModel::thePolyType, theRpcModel, ossimRpcModel::theSampDenCoef, ossimRpcModel::theSampNumCoef, ossimRpcModel::theSampOffset, ossimRpcModel::theSampScale, theUseElevationFlag, ossimDrect::width(), ossimDpt::x, x, ossimDpt::y, and y.
|
protectedvirtual |
Definition at line 449 of file ossimRpcSolver.cpp.
References FLT_EPSILON, invert(), setupSystemOfEquations(), setupWeightMatrix(), x, and y.
|
protectedvirtual |
Definition at line 431 of file ossimRpcSolver.cpp.
References invert(), setupSystemOfEquations(), x, and y.
|
protected |
Definition at line 192 of file ossimRpcSolver.h.
|
protected |
Definition at line 194 of file ossimRpcSolver.h.
Referenced by getMaxError(), and solveCoefficients().
|
protected |
Definition at line 193 of file ossimRpcSolver.h.
Referenced by getRmsError(), and solveCoefficients().
|
protected |
Definition at line 195 of file ossimRpcSolver.h.
Referenced by solve(), and solveCoefficients().
|
protected |
Definition at line 196 of file ossimRpcSolver.h.
Referenced by evalPoint(), getNitfRpcBTag(), and solveCoefficients().
|
protected |
Definition at line 191 of file ossimRpcSolver.h.
Referenced by solveCoefficients().