OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Private Attributes | List of all members
ossimLeastSquaresBilin Class Reference


Provide 2D Least Squares Bilinear model fitting The math model is that of a bilinear surface of the form: More...

#include <ossimLeastSquaresBilin.h>

Public Member Functions

 ossimLeastSquaresBilin (const ossimLeastSquaresBilin &)
 
 ossimLeastSquaresBilin ()
 Instantiate as zero surface. More...
 
ossimLeastSquaresBilinoperator= (const ossimLeastSquaresBilin &)
 
virtual ~ossimLeastSquaresBilin ()
 Free internal storage. More...
 
virtual void clear ()
 Will clear everything and set it up to for another solve. More...
 
virtual void addSample (double x, double yy, double zmea)
 add a single data sample. More...
 
virtual bool getLSParms (double &pa, double &pb_x, double &pc_y, double &pd_xy) const
 return LS solution parameters. More...
 
virtual void setLSParams (double pa, double pb_x, double pc_y, double pd_xy)
 
virtual double lsFitValue (double xx, double yy) const
 interpolate LS-fit value at location (xx,yy) - returns z(xx,yy). More...
 
bool solveLS ()
 compute least squares parameter solution - true if succesfull. More...
 

Private Attributes

double bl_a
 constant term. More...
 
double bl_b
 linear-X term. More...
 
double bl_c
 linear-Y term. More...
 
double bl_d
 cross-XY term More...
 
NEWMAT::Matrix * AtA
 Normal system coefficient matrix. More...
 
NEWMAT::Matrix * Atb
 Normal system RHS vector. More...
 

Detailed Description


Provide 2D Least Squares Bilinear model fitting The math model is that of a bilinear surface of the form:

z(x,y) = a + b*x + c*y + d*x*y

The getLSParms() method returns parameter values which are the least squares solution associated with the samples added via addSample(). Note that it is necessary to add at least four sample to obtain a solution.

Definition at line 27 of file ossimLeastSquaresBilin.h.

Constructor & Destructor Documentation

◆ ossimLeastSquaresBilin() [1/2]

ossimLeastSquaresBilin::ossimLeastSquaresBilin ( const ossimLeastSquaresBilin rhs)

Definition at line 34 of file ossimLeastSquaresBilin.cpp.

References AtA, Atb, bl_a, bl_b, bl_c, and bl_d.

35 {
36  // allocate normal system accumulation matrices
37  AtA = new NEWMAT::Matrix(4,4);
38  Atb = new NEWMAT::Matrix(4,1);
39 
40  bl_a = rhs.bl_a;
41  bl_b = rhs.bl_b;
42  bl_c = rhs.bl_c;
43  bl_d = rhs.bl_d;
44 
45  *AtA = *rhs.AtA;
46  *Atb = *rhs.Atb;
47 }
double bl_c
linear-Y term.
double bl_a
constant term.
NEWMAT::Matrix * AtA
Normal system coefficient matrix.
double bl_b
linear-X term.
NEWMAT::Matrix * Atb
Normal system RHS vector.

◆ ossimLeastSquaresBilin() [2/2]

ossimLeastSquaresBilin::ossimLeastSquaresBilin ( )

Instantiate as zero surface.

Definition at line 16 of file ossimLeastSquaresBilin.cpp.

References AtA, and Atb.

17  : bl_a(0.0)
18  , bl_b(0.0)
19  , bl_c(0.0)
20  , bl_d(0.0)
21  , AtA(NULL)
22  , Atb(NULL)
23 {
24  // allocate normal system accumulation matrices
25  AtA = new NEWMAT::Matrix(4,4);
26  Atb = new NEWMAT::Matrix(4,1);
27 
28  // ensure initilization to zero
29  *AtA = 0.0;
30  *Atb = 0.0;
31 
32  return;
33 }
double bl_c
linear-Y term.
double bl_a
constant term.
NEWMAT::Matrix * AtA
Normal system coefficient matrix.
double bl_b
linear-X term.
NEWMAT::Matrix * Atb
Normal system RHS vector.

◆ ~ossimLeastSquaresBilin()

ossimLeastSquaresBilin::~ossimLeastSquaresBilin ( )
virtual

Free internal storage.

Definition at line 49 of file ossimLeastSquaresBilin.cpp.

References AtA, and Atb.

50 {
51  if(AtA)
52  {
53  delete AtA;
54  AtA = NULL;
55  }
56  if(Atb)
57  {
58  delete Atb;
59  Atb = NULL;
60  }
61 }
NEWMAT::Matrix * AtA
Normal system coefficient matrix.
NEWMAT::Matrix * Atb
Normal system RHS vector.

Member Function Documentation

◆ addSample()

void ossimLeastSquaresBilin::addSample ( double  x,
double  yy,
double  zmea 
)
virtual

add a single data sample.

Parameters
xx"x" coordinate of sample location.
yy"y" "y" coordinate of sample location.
zmeasample value measured at (xx,yy)

Definition at line 85 of file ossimLeastSquaresBilin.cpp.

References AtA, and Atb.

Referenced by ossimBilinearProjection::initializeBilinear(), ossim2dBilinearTransform::setFromPoints(), and ossim2dTo2dMatrixTransform::setFromPoints().

86 {
87  // form normal system layer
88  NEWMAT::Matrix AtA_layer(4,1);
89  AtA_layer(1,1) = 1.0;
90  AtA_layer(2,1) = xx;
91  AtA_layer(3,1) = yy;
92  AtA_layer(4,1) = xx*yy;
93 
94  // accumulate layer into normal system
95  *AtA += AtA_layer * AtA_layer.t();
96  *Atb += AtA_layer * zmea;
97 
98 }
NEWMAT::Matrix * AtA
Normal system coefficient matrix.
NEWMAT::Matrix * Atb
Normal system RHS vector.

◆ clear()

void ossimLeastSquaresBilin::clear ( )
virtual

Will clear everything and set it up to for another solve.

Just add points and call the solve method.

Definition at line 75 of file ossimLeastSquaresBilin.cpp.

References AtA, Atb, bl_a, bl_b, bl_c, and bl_d.

Referenced by ossimBilinearProjection::initializeBilinear().

76 {
77  *AtA = 0.0;
78  *Atb = 0.0;
79  bl_a = 0.0;
80  bl_b = 0.0;
81  bl_c = 0.0;
82  bl_d = 0.0;
83 }
double bl_c
linear-Y term.
double bl_a
constant term.
NEWMAT::Matrix * AtA
Normal system coefficient matrix.
double bl_b
linear-X term.
NEWMAT::Matrix * Atb
Normal system RHS vector.

◆ getLSParms()

bool ossimLeastSquaresBilin::getLSParms ( double &  pa,
double &  pb_x,
double &  pc_y,
double &  pd_xy 
) const
virtual

return LS solution parameters.

Parameters
paset to constant coefficient.
pb_xset to linear coefficient of "x"
pc_yset to linear coefficient of "y"
pd_xyset to cross coefficient of "x*y"

Definition at line 113 of file ossimLeastSquaresBilin.cpp.

References bl_a, bl_b, bl_c, and bl_d.

Referenced by ossim2dBilinearTransform::setFromPoints(), and ossim2dTo2dMatrixTransform::setFromPoints().

117 {
118  pa = bl_a;
119  pb_x = bl_b;
120  pc_y = bl_c;
121  pd_xy = bl_d;
122 
123  return true;
124 }
double bl_c
linear-Y term.
double bl_a
constant term.
double bl_b
linear-X term.

◆ lsFitValue()

virtual double ossimLeastSquaresBilin::lsFitValue ( double  xx,
double  yy 
) const
inlinevirtual

interpolate LS-fit value at location (xx,yy) - returns z(xx,yy).

Parameters
xx"x" coordinate at which to interpolate.
yy"y" "y" coordinate at which to interpolate.

Definition at line 89 of file ossimLeastSquaresBilin.h.

Referenced by ossimBilinearProjection::lineSampleHeightToWorld(), ossimBilinearProjection::setTiePoints(), and ossimBilinearProjection::worldToLineSample().

90  {
91  return (bl_a + bl_b*xx + bl_c*yy + bl_d*xx*yy);
92  }
double bl_c
linear-Y term.
double bl_a
constant term.
double bl_b
linear-X term.

◆ operator=()

ossimLeastSquaresBilin & ossimLeastSquaresBilin::operator= ( const ossimLeastSquaresBilin rhs)

Definition at line 62 of file ossimLeastSquaresBilin.cpp.

References AtA, Atb, bl_a, bl_b, bl_c, and bl_d.

63 {
64  bl_a = rhs.bl_a;
65  bl_b = rhs.bl_b;
66  bl_c = rhs.bl_c;
67  bl_d = rhs.bl_d;
68 
69  *AtA = *rhs.AtA;
70  *Atb = *rhs.Atb;
71 
72  return *this;
73 }
double bl_c
linear-Y term.
double bl_a
constant term.
NEWMAT::Matrix * AtA
Normal system coefficient matrix.
double bl_b
linear-X term.
NEWMAT::Matrix * Atb
Normal system RHS vector.

◆ setLSParams()

void ossimLeastSquaresBilin::setLSParams ( double  pa,
double  pb_x,
double  pc_y,
double  pd_xy 
)
virtual
Parameters
paset to constant coefficient.
pb_xset to linear coefficient of "x"
pc_yset to linear coefficient of "y"
pd_xyset to cross coefficient of "x*y"

Definition at line 126 of file ossimLeastSquaresBilin.cpp.

References bl_a, bl_b, bl_c, and bl_d.

130 {
131  bl_a = pa;
132  bl_b = pb_x;
133  bl_c = pc_y;
134  bl_d = pd_xy;
135 }
double bl_c
linear-Y term.
double bl_a
constant term.
double bl_b
linear-X term.

◆ solveLS()

bool ossimLeastSquaresBilin::solveLS ( )

compute least squares parameter solution - true if succesfull.

Definition at line 100 of file ossimLeastSquaresBilin.cpp.

References AtA, bl_a, bl_b, bl_c, and bl_d.

Referenced by ossimBilinearProjection::initializeBilinear(), ossim2dBilinearTransform::setFromPoints(), and ossim2dTo2dMatrixTransform::setFromPoints().

101 {
102  NEWMAT::Matrix Soln(4,1);
103  Soln = AtA->i() * (*Atb);
104  bl_a = Soln(1,1);
105  bl_b = Soln(2,1);
106  bl_c = Soln(3,1);
107  bl_d = Soln(4,1);
108 
109 
110  return true;
111 }
double bl_c
linear-Y term.
double bl_a
constant term.
NEWMAT::Matrix * AtA
Normal system coefficient matrix.
double bl_b
linear-X term.

Member Data Documentation

◆ AtA

NEWMAT::Matrix* ossimLeastSquaresBilin::AtA
private

Normal system coefficient matrix.

Definition at line 123 of file ossimLeastSquaresBilin.h.

Referenced by addSample(), clear(), operator=(), ossimLeastSquaresBilin(), solveLS(), and ~ossimLeastSquaresBilin().

◆ Atb

NEWMAT::Matrix* ossimLeastSquaresBilin::Atb
private

Normal system RHS vector.

Definition at line 128 of file ossimLeastSquaresBilin.h.

Referenced by addSample(), clear(), operator=(), ossimLeastSquaresBilin(), and ~ossimLeastSquaresBilin().

◆ bl_a

double ossimLeastSquaresBilin::bl_a
private

constant term.

Definition at line 103 of file ossimLeastSquaresBilin.h.

Referenced by clear(), getLSParms(), operator=(), ossimLeastSquaresBilin(), setLSParams(), and solveLS().

◆ bl_b

double ossimLeastSquaresBilin::bl_b
private

linear-X term.

Definition at line 108 of file ossimLeastSquaresBilin.h.

Referenced by clear(), getLSParms(), operator=(), ossimLeastSquaresBilin(), setLSParams(), and solveLS().

◆ bl_c

double ossimLeastSquaresBilin::bl_c
private

linear-Y term.

Definition at line 113 of file ossimLeastSquaresBilin.h.

Referenced by clear(), getLSParms(), operator=(), ossimLeastSquaresBilin(), setLSParams(), and solveLS().

◆ bl_d

double ossimLeastSquaresBilin::bl_d
private

cross-XY term

Definition at line 118 of file ossimLeastSquaresBilin.h.

Referenced by clear(), getLSParms(), operator=(), ossimLeastSquaresBilin(), setLSParams(), and solveLS().


The documentation for this class was generated from the following files: