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
nConvertToFib.h
Go to the documentation of this file.
1 /**
2  * @file nConvertToFib
3  * file name: nConvertToFib.h
4  * @author Betti Oesterholz
5  * @date 23.02.2010
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This header specifies functions with which multimediaobjects in non fib
11  * multimediaformats can be converted into fib -objects.
12  * Copyright (C) @c GPL3 2010 Betti Oesterholz
13  *
14  * This program is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License (GPL) as
16  * published by the Free Software Foundation, either version 3 of the
17  * License, or any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program. If not, see <http://www.gnu.org/licenses/>.
26  *
27  *
28  * This header specifies functions with which multimediaobjects in non fib
29  * multimediaformats can be converted into fib -objects.
30  *
31  */
32 /*
33 History:
34 23.02.2010 Oesterholz created
35 07.03.2011 Oesterholz function convertOptimized() added
36 */
37 
38 #ifndef ___N_CONVERT_TO_FIB_H__
39 #define ___N_CONVERT_TO_FIB_H__
40 
41 #include "version.h"
42 
43 #include "cFibElement.h"
44 #ifdef FEATURE_OWN_FREE_IMAGE_WARPER
45  //no FreeImagePlus wraper for windows -> use own
46  #include "fipImage.h"
47 #else //WINDOWS
48  #include <FreeImagePlus.h>
49 #endif //WINDOWS
50 
51 
52 #include <map>
53 
54 
55 using namespace std;
56 using namespace fib;
57 
58 namespace nConvertToFib{
59 
60  /**
61  * This function converts the given multimediaobject into a fib -object.
62  *
63  * @param multimediaObject the multimedaobject to convert into fib;
64  * the inputformat is in the FreeImagePlus fipImage object
65  * @return the created fib -object
66  */
67  cFibElement * convert( const fipImage & multimediaObject );
68 
69  /**
70  * This function converts the given multimediaobject into a fib -object.
71  * It creats a fib -object with one master root -element which contains a
72  * listelement as main -fib -object.
73  * the function will try to compress the pictur data. It will:
74  * - sperate the points in respect of ther colors (properties)
75  * - will create area fib-objects, for areas with the same color
76  * if bCreatebackground is true;
77  * - will set a background color, if non is given
78  *
79  * @see convert()
80  * @param multimediaObject the multimedaobject to convert into fib;
81  * the inputformat is in the FreeImagePlus fipImage object
82  * @param bCreatebackground if true, this function will set a background
83  * color, if non is given
84  * @param bCorrectPoints if wrong points should be corrected, in the
85  * last compressing step
86  * @return the created fib -object
87  */
88  cFibElement * convertOptimized( const fipImage & multimediaObject,
89  bool bCreatebackground=true, const bool bCorrectPoints=false );
90 
91  /**
92  * This function converts the given multimediaobject into a fib -object.
93  * It will reduce the data to compress, so not all points in the created
94  * fib-object will have the correct color.
95  * It creats a fib -object with one master root -element which contains a
96  * listelement as main -fib -object.
97  * the function will try to compress the pictur data. It will:
98  * - sperate the points in respect of ther colors (properties)
99  * - will create area fib-objects, for areas with the similar color
100  * if bCreatebackground is true;
101  * - will set a background color, if non is given
102  *
103  * @see convert()
104  * @param multimediaObject the multimedaobject to convert into fib;
105  * the inputformat is in the FreeImagePlus fipImage object
106  * @param bCreatebackground if true, this function will set a background
107  * color, if non is given
108  * @param ulMaxAreaDiff the maximal difference of color values in an area
109  * (as the sum of the color vector element distances)
110  * @param ulMinPoints if an area with less than ulMinPoints points exists and
111  * it layes beside an area with a color, wich has a less difference as
112  * ulMaxDiff to the color of the first area, both areas will be
113  * combinde with the color of the second area (if the first area has
114  * more than one area as a neibour, which fulfill ulMaxDiff, the one
115  * with the minimum color distance is taken)
116  * @param ulMaxDiff @see ulMinPoints
117  * @param uiMinPointsNeighbourAreas all neighbour areas with less than
118  * this number of points, will be subsumed by the area
119  * @param bCorrectPoints if wrong points should be corrected, in the
120  * last compressing step
121  * @param bCorrectMissingPoints correct points, wich are missing in the
122  * created area fib-objects
123  * @param bAddNeighbours add to the areas ther neigbours and remove not needed areas
124  * @param bReduceFunctionDomains reduce the bits to store the function (values)
125  * @param bReplaceAreasWithPoints rreplace areas, which need more bits
126  * to store than ther points, with ther points
127  * @param uiInMinPointsForArea the minimal number of points an area
128  * should have, to create an area object for it;
129  * if 0 the standad value will be taken
130  * @param maxError the maximal error for the area border polynoms to find;
131  * the error on the interpolated polynoms for the borders of the areas
132  * will beequal or less than maxError
133  * @return the created fib -object
134  */
135  cFibElement * convertReduced( const fipImage & multimediaObject,
136  bool bCreatebackground=true, const unsigned long ulMaxAreaDiff=3,
137  const unsigned long ulMinPoints=4, const unsigned long ulMaxDiff=16,
138  const unsigned int uiMinPointsNeighbourAreas=0,
139  const bool bCorrectPoints=false, const bool bCorrectMissingPoints=false,
140  const bool bAddNeighbours=false, const bool bReduceFunctionDomains=false,
141  const bool bReplaceAreasWithPoints=false, const unsigned int uiInMinPointsForArea=0,
142  const double maxError=0 );
143 
144 
145  /**
146  * This function conts how oftern the different colors occure in the
147  * given pictur.
148  *
149  * @param multimediaObject the multimedaobject wher to count the colors
150  * @return a map with the color values and ther counts
151  */
152  map< vector< unsigned int >, unsigned long > countColors(
153  const fipImage & multimediaObject );
154 
155 
156  /**
157  * This function maps the colors of the given pictur accordingly to the
158  * given mapping.
159  * Colors not in the map won't be changed.
160  *
161  * @param multimediaObject the multimedaobject wher to change the colors
162  * @param mapColorMapping the mapping for the colors:
163  * key: the source color
164  * value: to which color the color should be mapped
165  * (BEWARE: all color vectors of the map should have the correct size.)
166  */
167  void mapColors( fipImage & multimediaObject,
168  const map< vector< unsigned int >, vector< unsigned int > > & mapColorMapping );
169 
170 }//end namespace nConvertToFib
171 
172 
173 #endif //___N_CONVERT_TO_FIB_H__
174 
175 
176 
177 
178 
179 
180