OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimTangentialRadialLensDistortion.h
Go to the documentation of this file.
1 #ifndef ossimTangentialRadialLensDistortion_HEADER
2 #define ossimTangentialRadialLensDistortion_HEADER 1
3 #include <vector>
4 #include <ossim/base/ossimDpt.h>
6 
7 /***
8 This is taken from the site:
9 
10 http://www.mathworks.com/products/symbolic/code-examples.html?file=/products/demos/symbolictlbx/Pixel_location/Camera_Lens_Undistortion.html
11 
12 Developing an Algorithm to Undistort Pixel Locations of an Image
13 This example uses Symbolic Math Toolbox to develop an algorithm that undistorts pixel locations of an image.
14 
15 Background
16 
17 When a camera captures an image, it does not precisely capture
18 the real points, but rather a slightly distorted version of the real points that can be denoted (x2, y2). The distorted pixel locations can be described using the following equations:
19 
20 x2 = x1(1 + k1*r^2 + k2*r^4 + k3*r^6) +2*p1*x1*y1 + p2*(r^2 + 2*x1^2)
21 y2 = y1(1 + k1*r^2 + k2*r^4 + k3*r^6) +2*p2*x1*y1 + p1*(r^2 + 2*y1^2)
22 
23 
24 where:
25 x1, y2 = undistorted pixel locations
26 k1, k2, k3 = radial distortion coefficients of the lens
27 p1, p2 = tangential distortion coefficients of the lens
28 r = sqrt(x1^2 + y1^2)
29 
30 
31 ***/
32 
34 {
35 public:
37 
38  ossimTangentialRadialLensDistortion(const ossimDpt& calibratedCenter,
39  double k1 = 0.0, double k2 = 0.0, double k3 = 0.0,
40  double p1 = 0.0, double p2 = 0.0);
41  ossimTangentialRadialLensDistortion(const ossimDpt& calibratedCenter,
42  std::vector<double> k,
43  std::vector<double> p);
44 
45 // ossimDpt adjustPoint(const ossimDpt &position)const;
46  virtual std::ostream& print(std::ostream& out) const
47  {return out;}
48 
49  virtual void undistort(const ossimDpt& input, ossimDpt& output)const;
50 
51 
52  virtual bool saveState(ossimKeywordlist& kwl,
53  const char* prefix = 0)const;
54 
55  virtual bool loadState(const ossimKeywordlist& kwl,
56  const char* prefix = 0);
57 
58 protected:
59 
60  std::vector<ossim_float64> m_k;
61  std::vector<ossim_float64> m_p;
62 
63 TYPE_DATA
64 };
65 
66 #endif
Represents serializable keyword/value map.
virtual void undistort(const ossimDpt &input, ossimDpt &output) const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
#define TYPE_DATA
Definition: ossimRtti.h:339
virtual std::ostream & print(std::ostream &out) const
Generic print method.
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23