Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleInterpolateLuT.cpp

Example for Interpolator with look up table (LuT)

Author
MIP
/*
This file is part of the BIAS library (Basic ImageAlgorithmS).
Copyright (C) 2003-2009 (see file CONTACT for details)
Multimediale Systeme der Informationsverarbeitung
Institut fuer Informatik
Christian-Albrechts-Universitaet Kiel
BIAS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
BIAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with BIAS; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/** @example ExampleInterpolateLuT.cpp
@relates Interpolator
@ingroup g_examples
@brief Example for Interpolator with look up table (LuT)
@author MIP
*/
#include <Base/Common/BIASpragma.hh>
#include <MathAlgo/Interpolator.hh>
#include <iostream>
#include <vector>
using namespace BIAS;
using namespace std;
//int main(int argc, char *argv[])
int main()
{
Interpolator spline;
vector<double> AngleCorrX,AngleCorrY;
AngleCorrX.push_back(0); AngleCorrY.push_back(0);
AngleCorrX.push_back(0.138); AngleCorrY.push_back(0.138);
AngleCorrX.push_back(0.424); AngleCorrY.push_back(0.421032);
AngleCorrX.push_back(0.757); AngleCorrY.push_back(0.737318);
AngleCorrX.push_back(1.045); AngleCorrY.push_back(0.983345);
AngleCorrX.push_back(1.342); AngleCorrY.push_back(1.20646);
AngleCorrX.push_back(1.436); AngleCorrY.push_back(1.26512);
AngleCorrX.push_back(1.652); AngleCorrY.push_back(1.36786);
spline.SetKnotPoints(AngleCorrX);
spline.SetControlPoints(AngleCorrY);
spline.InitSpline();
double MinAngle;
spline.Spline(MinAngle, AngleCorrX[0],4);
double MaxCamAngle = AngleCorrX[AngleCorrX.size()-1];
cout <<"CamAngle range: ["<<MinAngle<<" , "<<MaxCamAngle*180.0/M_PI<<"]"<<endl;
spline.PrepareLuTSpline(MinAngle-1, MaxCamAngle, 20);
double ang;
int res = spline.SplineFromLuT(ang, -0.5 );
if (res <0) cout <<"Out of range"<<endl;
return 0;
}