Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleInterpolateLuT.cpp
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 
26 /** @example ExampleInterpolateLuT.cpp
27  @relates Interpolator
28  @ingroup g_examples
29  @brief Example for Interpolator with look up table (LuT)
30  @author MIP
31 */
32 
33 #include <Base/Common/BIASpragma.hh>
34 
35 #include <MathAlgo/Interpolator.hh>
36 #include <iostream>
37 #include <vector>
38 
39 using namespace BIAS;
40 using namespace std;
41 
42 //int main(int argc, char *argv[])
43 int main()
44 {
45  Interpolator spline;
46 
47  vector<double> AngleCorrX,AngleCorrY;
48 
49  AngleCorrX.push_back(0); AngleCorrY.push_back(0);
50  AngleCorrX.push_back(0.138); AngleCorrY.push_back(0.138);
51  AngleCorrX.push_back(0.424); AngleCorrY.push_back(0.421032);
52  AngleCorrX.push_back(0.757); AngleCorrY.push_back(0.737318);
53  AngleCorrX.push_back(1.045); AngleCorrY.push_back(0.983345);
54  AngleCorrX.push_back(1.342); AngleCorrY.push_back(1.20646);
55  AngleCorrX.push_back(1.436); AngleCorrY.push_back(1.26512);
56  AngleCorrX.push_back(1.652); AngleCorrY.push_back(1.36786);
57 
58 
59  spline.SetKnotPoints(AngleCorrX);
60  spline.SetControlPoints(AngleCorrY);
61  spline.InitSpline();
62  double MinAngle;
63  spline.Spline(MinAngle, AngleCorrX[0],4);
64  double MaxCamAngle = AngleCorrX[AngleCorrX.size()-1];
65 
66  cout <<"CamAngle range: ["<<MinAngle<<" , "<<MaxCamAngle*180.0/M_PI<<"]"<<endl;
67 
68  spline.PrepareLuTSpline(MinAngle-1, MaxCamAngle, 20);
69  double ang;
70  int res = spline.SplineFromLuT(ang, -0.5 );
71  if (res <0) cout <<"Out of range"<<endl;
72 
73  return 0;
74 }
void InitSpline()
call this for restart at t= first knot point initiates recalculation of all polynom coefficients at f...
void SetKnotPoints(const std::vector< double > &kPnt)
set the additional knot points, if you want nonuniform interpolation.
this class interpolates a function y=f(t) between given control points (the y-values) ...
Definition: Interpolator.hh:71
int SplineFromLuT(double &res, double t) const
Get spline interpolation using Look-up-Table.
int Spline(double &res, double t, unsigned int k=3)
these functions do the Spline interpolation which reaches each control point.
void SetControlPoints(const std::vector< double > &cPnt1)
set the control points, which control the interpolating curve
Definition: Interpolator.hh:87
int PrepareLuTSpline(double min, double max, unsigned int N, unsigned int k=3)
Prepare Look-up-Table in range [min,max] with N samples.