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

#include <ossim2dLinearRegression.h>

Public Member Functions

 ossim2dLinearRegression ()
 
void getEquation (double &slope, double &intercept)
 
void addPoint (const ossimDpt &pt)
 
void clear ()
 
void solve ()
 
ossim_uint32 getNumberOfPoints () const
 

Protected Attributes

ossim_uint32 theNumberOfPoints
 
double theSumX
 
double theSumY
 
double theSumXX
 
double theSumYY
 
double theSumXY
 
double theIntercept
 
double theSlope
 
bool theSolvedFlag
 

Friends

OSSIM_DLL std::ostream & operator<< (std::ostream &out, const ossim2dLinearRegression &data)
 

Detailed Description

Definition at line 16 of file ossim2dLinearRegression.h.

Constructor & Destructor Documentation

◆ ossim2dLinearRegression()

ossim2dLinearRegression::ossim2dLinearRegression ( )

Definition at line 11 of file ossim2dLinearRegression.cpp.

References clear().

12 {
13  clear();
14 }

Member Function Documentation

◆ addPoint()

void ossim2dLinearRegression::addPoint ( const ossimDpt pt)
inline

Definition at line 33 of file ossim2dLinearRegression.h.

References ossimDpt::x, and ossimDpt::y.

Referenced by ossimLocalCorrelationFusion::computeRegression().

34  {
35 // thePoints.push_back(pt);
37  theSumX += pt.x;
38  theSumY += pt.y;
39  theSumXX += pt.x*pt.x;
40  theSumYY += pt.y*pt.y;
41  theSumXY += pt.x*pt.y;
42  theSolvedFlag = false;
43  }
double y
Definition: ossimDpt.h:165
double x
Definition: ossimDpt.h:164

◆ clear()

void ossim2dLinearRegression::clear ( )
inline

Definition at line 44 of file ossim2dLinearRegression.h.

Referenced by ossim2dLinearRegression().

◆ getEquation()

void ossim2dLinearRegression::getEquation ( double &  slope,
double &  intercept 
)
inline

Definition at line 27 of file ossim2dLinearRegression.h.

Referenced by ossimLocalCorrelationFusion::computeRegression().

29  {
30  slope = theSlope;
31  intercept = theIntercept;
32  }

◆ getNumberOfPoints()

ossim_uint32 ossim2dLinearRegression::getNumberOfPoints ( ) const
inline

Definition at line 58 of file ossim2dLinearRegression.h.

59  {
60  return theNumberOfPoints;
61 // return thePoints.size();
62  }

◆ solve()

void ossim2dLinearRegression::solve ( )

Definition at line 16 of file ossim2dLinearRegression.cpp.

References FLT_EPSILON, theIntercept, theNumberOfPoints, theSlope, theSolvedFlag, theSumX, theSumXX, theSumXY, and theSumY.

Referenced by ossimLocalCorrelationFusion::computeRegression().

17 {
18 
19 // theSumX = 0.0;
20 // theSumXX = 0.0;
21 // theSumY = 0.0;
22 // theSumYY = 0.0;
23 // theIntercept = 0.0;
24 // theSlope = 0.0;
25 // theSumXY = 0.0;
26 // ossim_uint32 idx = 0;
27 // for(idx = 0; idx < thePoints.size(); ++idx)
28 // {
29 // theSumX += thePoints[idx].x;
30 // theSumY += thePoints[idx].y;
31 // theSumXX += thePoints[idx].x*thePoints[idx].x;
32 // theSumYY += thePoints[idx].y*thePoints[idx].y;
33 // theSumXY += thePoints[idx].x*thePoints[idx].y;
34 
35 // }
36 
37  double numberOfPoints = (double)theNumberOfPoints;
38 
39  if(numberOfPoints < 1)
40  {
41  theSlope = 0.0;
42  theIntercept = 0.0;
43  return;
44  }
45  double Sxx = theSumXX - ((theSumX*theSumX)/numberOfPoints);
46  double Sxy = theSumXY - ((theSumX*theSumY)/numberOfPoints);
47 
48  if(fabs(Sxx) < FLT_EPSILON)
49  {
50  theSlope = 0.0;
51  theIntercept = 0.0;
52  return;
53  }
54 
55  theSlope = Sxy/Sxx;
56  theIntercept = (theSumY - theSlope*theSumX)/numberOfPoints;
57 
58  theSolvedFlag = true;
59 }
#define FLT_EPSILON

Friends And Related Function Documentation

◆ operator<<

OSSIM_DLL std::ostream& operator<< ( std::ostream &  out,
const ossim2dLinearRegression data 
)
friend

Definition at line 19 of file ossim2dLinearRegression.h.

21  {
22  out << "y = " << data.theSlope << "*x + " << data.theIntercept;
23 
24  return out;
25  }

Member Data Documentation

◆ theIntercept

double ossim2dLinearRegression::theIntercept
protected

Definition at line 72 of file ossim2dLinearRegression.h.

Referenced by solve().

◆ theNumberOfPoints

ossim_uint32 ossim2dLinearRegression::theNumberOfPoints
protected

Definition at line 65 of file ossim2dLinearRegression.h.

Referenced by solve().

◆ theSlope

double ossim2dLinearRegression::theSlope
protected

Definition at line 73 of file ossim2dLinearRegression.h.

Referenced by solve().

◆ theSolvedFlag

bool ossim2dLinearRegression::theSolvedFlag
protected

Definition at line 74 of file ossim2dLinearRegression.h.

Referenced by solve().

◆ theSumX

double ossim2dLinearRegression::theSumX
protected

Definition at line 66 of file ossim2dLinearRegression.h.

Referenced by solve().

◆ theSumXX

double ossim2dLinearRegression::theSumXX
protected

Definition at line 68 of file ossim2dLinearRegression.h.

Referenced by solve().

◆ theSumXY

double ossim2dLinearRegression::theSumXY
protected

Definition at line 70 of file ossim2dLinearRegression.h.

Referenced by solve().

◆ theSumY

double ossim2dLinearRegression::theSumY
protected

Definition at line 67 of file ossim2dLinearRegression.h.

Referenced by solve().

◆ theSumYY

double ossim2dLinearRegression::theSumYY
protected

Definition at line 69 of file ossim2dLinearRegression.h.


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