Image Component Library (ICL)
Parable.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLCore/src/ICLCore/Parable.h **
10 ** Module : ICLCore **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLUtils/Point32f.h>
35 #include <stdio.h>
36 
37 namespace icl{
38  namespace core{
39 
41 
48  struct Parable{
49 
51  Parable():a(0),b(0),c(0){}
52 
54  Parable(float a, float b,float c):a(a),b(b),c(c){}
55 
57 
65  p1.x+=0.00000001; // avoid numerical problems
66  p2.x+=0.00000002;
67  p3.x+=0.00000003;
68 
69  float xx1 = p1.x * p1.x;
70  float xx2 = p2.x * p2.x;
71  float xx3 = p3.x * p3.x;
72  b = ((p3.y-p1.y)/(xx3-xx1)-(p2.y-p1.y)/(xx2-xx1)) /
73  ((p1.x-p2.x)/(xx2-xx1)-(p1.x-p3.x)/(xx3-xx1));
74 
75  a = (b*(p1.x-p2.x)+(p2.y-p1.y)) / (xx2-xx1);
76 
77  c = p1.y-a*xx1-b*p1.x;
78  }
79 
80  float a;
81  float b;
82  float c;
84  float operator()(float x) const{ return a*x*x+b*x+c; }
86 
88  void show()const{
89  printf("Parable:\n");
90  printf("f(x)=%f*x²+%fx+%f\n",a,b,c);
91  }
92  };
93 
94  } // namespace core
95 }
96 
undocument this line if you encounter any issues!
Definition: Any.h:37
Utility class for the parable-based chromaticity segmentation.
Definition: Parable.h:48
float y
y position of this point
Definition: Point32f.h:48
Parable(utils::Point32f p1, utils::Point32f p2, utils::Point32f p3)
create a parable with given 3 points
Definition: Parable.h:64
Single precission 3D Vectors Point class of the ICL.
Definition: Point32f.h:41
float operator()(float x) const
Evaluate this parable at a given location x.
Definition: Parable.h:85
Parable()
create an empty parable (a=b=c=0)
Definition: Parable.h:51
float a
Definition: Parable.h:80
float x
x position of this point
Definition: Point32f.h:45
Parable(float a, float b, float c)
create a parable with given parameters a,b and c
Definition: Parable.h:54
void show() const
shows this parable to std::out
Definition: Parable.h:88
float c
Definition: Parable.h:82
float b
Definition: Parable.h:81