Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
UnVignette.hh
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 #ifndef __UnVignette_hh__
26 #define __UnVignette_hh__
27 
28 #include <Base/Common/BIASpragmaStart.hh>
29 
30 #include <Base/Image/Image.hh>
31 #include <Base/Geometry/HomgPoint2D.hh>
32 #include <Base/Geometry/KMatrix.hh>
33 #include <MathAlgo/Interpolator.hh>
34 #include <Image/CameraParam.hh>
35 #include <Base/Math/Matrix.hh>
36 #include <Base/Math/Vector.hh>
37 
38 #include <vector>
39 #include <string>
40 
41 #define UNDIST_EPS 1e-9
42 
43 namespace BIAS{
44 
45  enum BIASImage_EXPORT INTERPOLATION_METHOD
46  {
47  LEAST_SQUARES =1,
48  SPLINE_WITH_LUT,
49  SPLINE_WITHOUT_LUT
50  };
51 
52 
53  /** @class UnVignette
54  @ingroup g_image
55  @brief Unvignette algorithm for images. Measure the vignetting of images
56  and correct the vignetting of images
57 
58  @author ischiller
59  @date 02/2006
60  */
61  class BIASImage_EXPORT UnVignette{
62 
63  public:
64  UnVignette();
65  UnVignette(CameraParam &cParam, INTERPOLATION_METHOD method = LEAST_SQUARES, bool bUseLuT = true);
66 
67  ~UnVignette();
68 
69  inline bool IsInitialized(){return bIsInitialized_;};
70 
71  void Compute(BIAS::Image<unsigned char> &Image);
72 
73  /**
74  Init the Unvignette algorithm
75  give ControlPoints in image as offset from Principal Point in pixel
76  give percentage values in second vector
77  vectors have to be of same size
78  @author ischiller
79  @date 02/06
80  */
81  int Init(const std::vector<double> ControlPoints,
82  std::vector<double> PercentageValues,
83  unsigned int dImageWidth , unsigned int dImageHeight,
84  int dPPX, int dPPY,INTERPOLATION_METHOD method = LEAST_SQUARES,bool bUseLuT = true);
85  /**
86  Init the Unvignette algorithm with CameraParam object
87  CameraParameter objcect has to contain ControlPoints and PercentageValues
88  vectors have to be of same size
89  @author ischiller
90  @date 02/06
91  */
92  int Init(BIAS::CameraParam cParam, INTERPOLATION_METHOD method = LEAST_SQUARES, bool bUseLuT = true);
93 
94  private:
95  INTERPOLATION_METHOD dInterPolationMethod_;
96  double CalcRadius_(double x, double y);
97  int PrepareLuImage_();
98  int PrepareLeastSquaresMin_();
99  int LeastSquares_(double &res, double radius);
100  int Init_();
101  private:
102  std::vector<double> ControlPoints_;
103  std::vector<double> PercentageValues_;
104 
105  BIAS::Matrix<double> A_; //matrix for least squares computation (measured percentages)
106  BIAS::Vector<double> Y_; //vector with measurement points
107  BIAS::Vector<double> X_; //result vector of least squares polynomial fitting
108 
109  bool bLeastSquaresPrepared_;
110 
111 
112  double dWidthHalfMPPX_;
113  double dHeightHalfMPPY_;
114  BIAS::Image<float> LuImage_;
115 
116  bool bUseLuT_;
117 
118  double PrinciplePointX_;
119  double PrinciplePointY_;
120  unsigned int dWidth_;
121  unsigned int dHeight_;
122  unsigned int dChannelCount_;
123 
124  bool bIsInitialized_;
125  BIAS::Interpolator InterpolatorIllu_;
126 
127  // illumination vignette correction
128  // x is distance in pixel from principal point
129  // y is illumination correction factor
130  std::vector<int> IlluCorrX_;
131  std::vector<double> IlluCorrY_;
132  };
133 }
134 
135 #include <Base/Common/BIASpragmaEnd.hh>
136 
137 #endif
Unvignette algorithm for images.
Definition: UnVignette.hh:61
this class interpolates a function y=f(t) between given control points (the y-values) ...
Definition: Interpolator.hh:71
bool IsInitialized()
Definition: UnVignette.hh:69