OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimTangentialRadialLensDistortion.cpp
Go to the documentation of this file.
4 
5 RTTI_DEF1(ossimTangentialRadialLensDistortion, "ossimTangentialRadialLensDistortion",
9 {
10  m_k.resize(3);
11  m_p.resize(2);
12  m_k[0] = m_k[1] = m_k[2] = 0.0;
13  m_p[0] = m_p[1];
14 }
16  double k1, double k2, double k3,
17  double p1, double p2)
18  :ossimLensDistortion(calibratedCenter)
19  {
20 
21  m_k.resize(3);
22  m_p.resize(2);
23 
24  m_k[0] = k1;
25  m_k[1] = k2;
26  m_k[2] = k3;
27 
28  m_p[0] = p1;
29  m_p[1] = p2;
30 
31 
32 }
34  std::vector<double> k,
35  std::vector<double> p)
36  :ossimLensDistortion(calibratedCenter),
37  m_k(k),
38  m_p(p)
39 {
40 }
41 
43  ossimDpt& output)const
44 {
45  // make relative to calibrated center
46  //ossimDpt deltaPosition(input.x - theCenter.x,
47  // input.y - theCenter.y);
48 
49  double r = sqrt(input.x*input.x +
50  input.y*input.y);
51  double r2 = r*r;
52  double rMultiplier = r2;
53  ossim_uint32 idx = 0;
54  // comnpute the radial portion of the equation of the form
55  // 1 + k0*r^2 + k1*r^4 + .......
56  double tempRadial = 1.0;
57  for(idx = 0; idx < m_k.size();++idx)
58  {
59  tempRadial += m_k[idx]*rMultiplier;
60  rMultiplier*=r2;
61  }
62  // now apply the radial to the input point and then
63  // shift and apply the tangential coefficients along x and y.
64  output.x = (input.x*tempRadial) +
65  (2.0*m_p[0]*input.x*input.y) +
66  (m_p[1]*(r2 + 2*input.x*input.x));
67 
68  output.y = (input.y*tempRadial) +
69  (2.0*m_p[1]*input.x*input.y) +
70  (m_p[0]*(r2 + 2*input.y*input.y));
71 
72 // output.x += theCenter.x;
73 // output.y += theCenter.y;
74 }
76  const char* prefix )const
77 {
78  bool result = ossimLensDistortion::saveState(kwl, prefix);
79  ossimString kValues;
80  ossimString pValues;
83 
84  kwl.add(prefix, "k", kValues);
85  kwl.add(prefix, "p", pValues);
86 
87  return result;
88 }
89 
91  const char* prefix)
92 {
93  bool result = ossimLensDistortion::loadState(kwl, prefix);
94  ossimString k = kwl.find(prefix, "k");
95  ossimString p = kwl.find(prefix, "p");
96 
97  m_k.clear();
98  m_p.clear();
101 
102  return result;
103 }
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Represents serializable keyword/value map.
const char * find(const char *key) const
virtual void undistort(const ossimDpt &input, ossimDpt &output) const
double y
Definition: ossimDpt.h:165
void toSimpleStringList(ossimString &result, const std::vector< T > &valuesList)
This will output a vector of values inst a string.
Definition: ossimCommon.h:484
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
bool toSimpleVector(std::vector< T > &result, const ossimString &stringOfPoints)
Definition: ossimCommon.h:537
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
unsigned int ossim_uint32
double x
Definition: ossimDpt.h:164
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
RTTI_DEF1(ossimTangentialRadialLensDistortion, "ossimTangentialRadialLensDistortion", ossimLensDistortion)