The Fib multimedia system
Fib is a system for storing multimedia data (like images or films).
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cColorDistance.h
Go to the documentation of this file.
1 /**
2  * @class cColorDistance
3  * file name: cColorDistance.h
4  * @author Betti Oesterholz
5  * @date 18.03.2011
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This file contains the implementation for evaluing a distance of two colors.
11  * Copyright (C) @c LGPL3 2011 Betti Oesterholz
12  *
13  * This program is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU Lesser General Public License (LGPL) as
15  * published by the Free Software Foundation, either version 3 of the
16  * License, or any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public License
24  * along with this program. If not, see <http://www.gnu.org/licenses/>.
25  *
26  *
27  * This file contains the implementation for evaluing a distance of two colors.
28  * The distance of two colors is the sum of ther element distances.
29  */
30 /*
31 History:
32 18.03.2011 Oesterholz created
33 */
34 
35 #ifndef ___C_COLOR_DISTANCE__
36 #define ___C_COLOR_DISTANCE__
37 
38 #include "version.h"
39 #include "iDistFunction.h"
40 
41 
42 namespace nConvertToFib{
43 
44 
45 class cColorDistance: public fib::algorithms::nCluster::iDistFunction< vector< unsigned int > >{
46 public:
47 
48  /**
49  * destructor
50  */
51  virtual ~cColorDistance(){
52  //nothing to do
53  }
54 
55  /**
56  * This function evalue the distance of two colors.
57  * The distance of two colors is the sum of ther element distances.
58  *
59  * @param color1 the first color to evalue the distance to
60  * @param color2 the second color to evalue the distance from
61  * @return a value for the distance betwean color1 and color2
62  */
63  virtual double operator() ( const vector< unsigned int > & color1,
64  const vector< unsigned int > & color2 ) const{
65 
66  const unsigned int uiDimensions = min( color1.size(), color2.size() );
67 
68  unsigned long ulDistance = 0;
69  for ( unsigned int uiActualDimension = 0;
70  uiActualDimension < uiDimensions; uiActualDimension++ ){
71 
72  ulDistance += std::abs( ((int)(color1[ uiActualDimension ])) -
73  ((int)(color2[ uiActualDimension ])) );
74  }
75  return ulDistance;
76  }
77 
78 
79 };//class cColorDistance
80 
81 
82 };//end namespace nConvertToFib
83 
84 
85 #endif //___C_COLOR_DISTANCE__
86 
87 
88