bazar  1.3.1
mcv.h
Go to the documentation of this file.
1 /*
2 Copyright 2005, 2006 Computer Vision Lab,
3 Ecole Polytechnique Federale de Lausanne (EPFL), Switzerland.
4 All rights reserved.
5 
6 This file is part of BazAR.
7 
8 BazAR is free software; you can redistribute it and/or modify it under the
9 terms of the GNU General Public License as published by the Free Software
10 Foundation; either version 2 of the License, or (at your option) any later
11 version.
12 
13 BazAR is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15 PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License along with
18 BazAR; if not, write to the Free Software Foundation, Inc., 51 Franklin
19 Street, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21 #ifndef MCV_H
22 #define MCV_H
23 
24 #include <cv.h>
25 
28 
29 
30 #define mcvRow(image, y, type) ( (type *)( (image)->imageData + (y) * (image)->widthStep ) )
31 #define mcvGet2D(image, x, y, type) ( (type *)( (image)->imageData + (y) * (image)->widthStep ) )[x]
32 #define mcvGet2D_32f(image, x, y) ( (float *)( (image)->imageData + (y) * (image)->widthStep ) )[x]
33 
35 
36 CvSize mcvSize(IplImage * image);
37 IplImage * mcvResize(IplImage * original_image, int new_width, int new_height = -1);
38 
40 
41 void mcvSmooth(IplImage * image, IplImage * smoothed_image, int smooth_type, int aperture);
42 
43 float mcvGaussianDerivative(IplImage * image, int x, int y, int order_x, int order_y, float sigma);
44 
45 IplImage * mcvGradientNorm2(IplImage * image, int aperture);
46 
47 void mcvSetBorder(IplImage * image, int border_size, int value);
48 void mcvSetBorder(IplImage * image, int border_size);
49 
51 
52 // Color <-> Gray conversions with creation:
53 IplImage * mcvColorToGray(IplImage * colorImage);
54 IplImage * mcvGrayToColor(IplImage * grayImage);
55 
56 // Swap Red in Blue channels:
57 void mcvSwapRandB(IplImage * image);
58 
59 IplImage * showLocalMinima(IplImage * image);
60 IplImage * showLocalMaxima(IplImage * image);
61 
62 // convert scale between 0 & 255:
63 void mcvScaleTo0_255(IplImage * original, IplImage * scaled);
64 
65 void mcvReplace(IplImage * image, int old_value, int new_value);
66 
68 
69 int mcvSaveImage(const char * filename, IplImage * image, bool verbose = true);
70 int mcvSaveImage(const char * generic_filename, int index, IplImage * image, bool verbose = true);
71 
72 IplImage * mcvLoadImage(const char * filename, int code, bool verbose = true);
73 IplImage * mcvLoadImage(const char * generic_filename, int index, int code, bool verbose = true);
74 
76 
77 // Crop & Zoom:
78 IplImage * mcvCrop(IplImage * image, int x, int y, int width, int height);
79 void mcvCrop(IplImage * image, int x, int y, IplImage * croppedImage);
80 
81 IplImage * mcvZoom(IplImage * source, int xc, int yc, float zoom);
82 
83 void mcvPut(IplImage * destImage, IplImage * imageToCopy, int x, int y);
84 
85 void mcvDeinterlace(IplImage * image);
86 
88 
89 // Colors
90 // with 0 <= index <= 5, or index == MCV_RANDOM_COLOR == -1 for a random index:
91 #define MCV_RANDOM_COLOR (-1)
92 
93 CvScalar mcvRainbowColor(int index, float coeff = 1);
94 
96 
97 // Drawing functions for visualization:
98 
99 void mcvCross(IplImage * image, int x, int y, int size, CvScalar color, int thickness=1);
100 void mcvSquare(IplImage * image, int x, int y, int size, CvScalar color, int thickness=1);
101 void mcvCircle(IplImage * image, int x, int y, int size, CvScalar color, int thickness=1);
102 
103 void mcvVisibleLine(IplImage * image, int x1, int y1, int x2, int y2, int thickness=1);
104 
106 
107 // Noise:
108 void mcvAddWhiteNoise(const IplImage * image, const int minNoise, const int maxNoise);
109 void mcvAddWhiteNoise(const IplImage * image, const int maxNoise);
110 IplImage * createTwoLevelsWhiteNoiseImage(int width, int height, float percentageOf0);
111 
112 IplImage * mcvCreateRandomImage(CvSize size, int depth, int nChannels);
113 
114 void mcvReplace(IplImage * image, int value, int new_value);
115 void mcvReplaceByNoise(IplImage * image, int value);
116 
117 void mcvChangeGamma(IplImage * image, float gamma); // I -> 255 * (I / 255) ^ gamma
118 
120 
121 // Patches:
122 IplImage * mcvGetPatch(IplImage * image, int u, int v, int width, int height);
123 void mcvGetPatch(IplImage * image, IplImage * patch, int u, int v);
124 
125 void mcvComputeAffineTransfo(float * a,
126  int u, int v,
127  float theta, float phi, float lambda1, float lambda2, float tx, float ty);
128 
129 #endif // MCV_H