imagecore 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +24 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/ext/imagecore/analyze_image.cxx +58 -0
- data/ext/imagecore/analyze_image.h +6 -0
- data/ext/imagecore/extconf.rb +9 -0
- data/ext/imagecore/imagecore.cxx +34 -0
- data/ext/opencv/core/___.c +3 -0
- data/ext/opencv/core/alloc.cpp +697 -0
- data/ext/opencv/core/array.cpp +3206 -0
- data/ext/opencv/core/datastructs.cpp +4064 -0
- data/ext/opencv/core/extconf.rb +22 -0
- data/ext/opencv/core/matrix.cpp +3777 -0
- data/ext/opencv/core/precomp.hpp +216 -0
- data/ext/opencv/core/system.cpp +832 -0
- data/ext/opencv/core/tables.cpp +3512 -0
- data/ext/opencv/highgui/___.c +3 -0
- data/ext/opencv/highgui/bitstrm.cpp +582 -0
- data/ext/opencv/highgui/bitstrm.hpp +182 -0
- data/ext/opencv/highgui/extconf.rb +28 -0
- data/ext/opencv/highgui/grfmt_base.cpp +128 -0
- data/ext/opencv/highgui/grfmt_base.hpp +113 -0
- data/ext/opencv/highgui/grfmt_bmp.cpp +564 -0
- data/ext/opencv/highgui/grfmt_bmp.hpp +99 -0
- data/ext/opencv/highgui/grfmt_exr.hpp +113 -0
- data/ext/opencv/highgui/grfmt_imageio.hpp +56 -0
- data/ext/opencv/highgui/grfmt_jpeg.cpp +622 -0
- data/ext/opencv/highgui/grfmt_jpeg.hpp +90 -0
- data/ext/opencv/highgui/grfmt_jpeg2000.cpp +529 -0
- data/ext/opencv/highgui/grfmt_jpeg2000.hpp +95 -0
- data/ext/opencv/highgui/grfmt_png.cpp +406 -0
- data/ext/opencv/highgui/grfmt_png.hpp +101 -0
- data/ext/opencv/highgui/grfmt_pxm.cpp +513 -0
- data/ext/opencv/highgui/grfmt_pxm.hpp +92 -0
- data/ext/opencv/highgui/grfmt_sunras.cpp +425 -0
- data/ext/opencv/highgui/grfmt_sunras.hpp +105 -0
- data/ext/opencv/highgui/grfmt_tiff.cpp +718 -0
- data/ext/opencv/highgui/grfmt_tiff.hpp +136 -0
- data/ext/opencv/highgui/grfmts.hpp +56 -0
- data/ext/opencv/highgui/loadsave.cpp +535 -0
- data/ext/opencv/highgui/precomp.hpp +223 -0
- data/ext/opencv/highgui/utils.cpp +689 -0
- data/ext/opencv/highgui/utils.hpp +128 -0
- data/ext/opencv/imgproc/___.c +3 -0
- data/ext/opencv/imgproc/_geom.h +72 -0
- data/ext/opencv/imgproc/color.cpp +3179 -0
- data/ext/opencv/imgproc/contours.cpp +1780 -0
- data/ext/opencv/imgproc/extconf.rb +11 -0
- data/ext/opencv/imgproc/filter.cpp +3063 -0
- data/ext/opencv/imgproc/precomp.hpp +159 -0
- data/ext/opencv/imgproc/shapedescr.cpp +1306 -0
- data/ext/opencv/imgproc/smooth.cpp +1566 -0
- data/ext/opencv/imgproc/tables.cpp +214 -0
- data/ext/opencv/imgproc/thresh.cpp +636 -0
- data/ext/opencv/imgproc/utils.cpp +242 -0
- data/ext/opencv/include/opencv2/core/core.hpp +4344 -0
- data/ext/opencv/include/opencv2/core/core_c.h +1885 -0
- data/ext/opencv/include/opencv2/core/internal.hpp +710 -0
- data/ext/opencv/include/opencv2/core/mat.hpp +2557 -0
- data/ext/opencv/include/opencv2/core/operations.hpp +3623 -0
- data/ext/opencv/include/opencv2/core/types_c.h +1875 -0
- data/ext/opencv/include/opencv2/core/version.hpp +58 -0
- data/ext/opencv/include/opencv2/highgui/highgui.hpp +198 -0
- data/ext/opencv/include/opencv2/highgui/highgui_c.h +506 -0
- data/ext/opencv/include/opencv2/imgproc/imgproc.hpp +1139 -0
- data/ext/opencv/include/opencv2/imgproc/imgproc_c.h +783 -0
- data/ext/opencv/include/opencv2/imgproc/types_c.h +538 -0
- data/imagecore.gemspec +20 -0
- data/lib/imagecore.rb +16 -0
- data/lib/imagecore/version.rb +3 -0
- metadata +119 -0
@@ -0,0 +1,223 @@
|
|
1
|
+
/*M///////////////////////////////////////////////////////////////////////////////////////
|
2
|
+
//
|
3
|
+
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
4
|
+
//
|
5
|
+
// By downloading, copying, installing or using the software you agree to this license.
|
6
|
+
// If you do not agree to this license, do not download, install,
|
7
|
+
// copy or use the software.
|
8
|
+
//
|
9
|
+
//
|
10
|
+
// Intel License Agreement
|
11
|
+
// For Open Source Computer Vision Library
|
12
|
+
//
|
13
|
+
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
14
|
+
// Third party copyrights are property of their respective owners.
|
15
|
+
//
|
16
|
+
// Redistribution and use in source and binary forms, with or without modification,
|
17
|
+
// are permitted provided that the following conditions are met:
|
18
|
+
//
|
19
|
+
// * Redistribution's of source code must retain the above copyright notice,
|
20
|
+
// this list of conditions and the following disclaimer.
|
21
|
+
//
|
22
|
+
// * Redistribution's in binary form must reproduce the above copyright notice,
|
23
|
+
// this list of conditions and the following disclaimer in the documentation
|
24
|
+
// and/or other materials provided with the distribution.
|
25
|
+
//
|
26
|
+
// * The name of Intel Corporation may not be used to endorse or promote products
|
27
|
+
// derived from this software without specific prior written permission.
|
28
|
+
//
|
29
|
+
// This software is provided by the copyright holders and contributors "as is" and
|
30
|
+
// any express or implied warranties, including, but not limited to, the implied
|
31
|
+
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
32
|
+
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
33
|
+
// indirect, incidental, special, exemplary, or consequential damages
|
34
|
+
// (including, but not limited to, procurement of substitute goods or services;
|
35
|
+
// loss of use, data, or profits; or business interruption) however caused
|
36
|
+
// and on any theory of liability, whether in contract, strict liability,
|
37
|
+
// or tort (including negligence or otherwise) arising in any way out of
|
38
|
+
// the use of this software, even if advised of the possibility of such damage.
|
39
|
+
//
|
40
|
+
//M*/
|
41
|
+
|
42
|
+
#ifndef __HIGHGUI_H_
|
43
|
+
#define __HIGHGUI_H_
|
44
|
+
|
45
|
+
#if _MSC_VER >= 1200
|
46
|
+
#pragma warning( disable: 4251 )
|
47
|
+
#endif
|
48
|
+
|
49
|
+
#include "cvconfig.h"
|
50
|
+
|
51
|
+
#include "opencv2/highgui/highgui.hpp"
|
52
|
+
#include "opencv2/highgui/highgui_c.h"
|
53
|
+
#include "opencv2/imgproc/imgproc_c.h"
|
54
|
+
#include "opencv2/core/internal.hpp"
|
55
|
+
|
56
|
+
#include <stdlib.h>
|
57
|
+
#include <stdio.h>
|
58
|
+
#include <string.h>
|
59
|
+
#include <limits.h>
|
60
|
+
#include <ctype.h>
|
61
|
+
#include <assert.h>
|
62
|
+
|
63
|
+
#ifdef HAVE_TEGRA_OPTIMIZATION
|
64
|
+
#include "opencv2/highgui/highgui_tegra.hpp"
|
65
|
+
#endif
|
66
|
+
|
67
|
+
#if defined WIN32 || defined _WIN32
|
68
|
+
|
69
|
+
#define WIN32_LEAN_AND_MEAN
|
70
|
+
#include <windows.h>
|
71
|
+
#undef min
|
72
|
+
#undef max
|
73
|
+
|
74
|
+
void FillBitmapInfo( BITMAPINFO* bmi, int width, int height, int bpp, int origin );
|
75
|
+
#endif
|
76
|
+
|
77
|
+
/* Errors */
|
78
|
+
#define HG_OK 0 /* Don't bet on it! */
|
79
|
+
#define HG_BADNAME -1 /* Bad window or file name */
|
80
|
+
#define HG_INITFAILED -2 /* Can't initialize HigHGUI */
|
81
|
+
#define HG_WCFAILED -3 /* Can't create a window */
|
82
|
+
#define HG_NULLPTR -4 /* The null pointer where it should not appear */
|
83
|
+
#define HG_BADPARAM -5
|
84
|
+
|
85
|
+
#define __BEGIN__ __CV_BEGIN__
|
86
|
+
#define __END__ __CV_END__
|
87
|
+
#define EXIT __CV_EXIT__
|
88
|
+
|
89
|
+
#define CV_WINDOW_MAGIC_VAL 0x00420042
|
90
|
+
#define CV_TRACKBAR_MAGIC_VAL 0x00420043
|
91
|
+
|
92
|
+
/***************************** CvCapture structure ******************************/
|
93
|
+
|
94
|
+
struct CvCapture
|
95
|
+
{
|
96
|
+
virtual ~CvCapture() {}
|
97
|
+
virtual double getProperty(int) { return 0; }
|
98
|
+
virtual bool setProperty(int, double) { return 0; }
|
99
|
+
virtual bool grabFrame() { return true; }
|
100
|
+
virtual IplImage* retrieveFrame(int) { return 0; }
|
101
|
+
virtual int getCaptureDomain() { return CV_CAP_ANY; } // Return the type of the capture object: CV_CAP_VFW, etc...
|
102
|
+
};
|
103
|
+
|
104
|
+
/*************************** CvVideoWriter structure ****************************/
|
105
|
+
|
106
|
+
struct CvVideoWriter
|
107
|
+
{
|
108
|
+
virtual ~CvVideoWriter() {}
|
109
|
+
virtual bool writeFrame(const IplImage*) { return false; }
|
110
|
+
};
|
111
|
+
|
112
|
+
#if defined WIN32 || defined _WIN32
|
113
|
+
#define HAVE_VFW 1
|
114
|
+
|
115
|
+
/* uncomment to enable CMUCamera1394 fireware camera module */
|
116
|
+
//#define HAVE_CMU1394 1
|
117
|
+
#endif
|
118
|
+
|
119
|
+
|
120
|
+
CvCapture * cvCreateCameraCapture_V4L( int index );
|
121
|
+
CvCapture * cvCreateCameraCapture_DC1394( int index );
|
122
|
+
CvCapture * cvCreateCameraCapture_DC1394_2( int index );
|
123
|
+
CvCapture* cvCreateCameraCapture_MIL( int index );
|
124
|
+
CvCapture * cvCreateCameraCapture_CMU( int index );
|
125
|
+
CV_IMPL CvCapture * cvCreateCameraCapture_TYZX( int index );
|
126
|
+
CvCapture* cvCreateFileCapture_Win32( const char* filename );
|
127
|
+
CvCapture* cvCreateCameraCapture_VFW( int index );
|
128
|
+
CvCapture* cvCreateFileCapture_VFW( const char* filename );
|
129
|
+
CvVideoWriter* cvCreateVideoWriter_Win32( const char* filename, int fourcc,
|
130
|
+
double fps, CvSize frameSize, int is_color );
|
131
|
+
CvVideoWriter* cvCreateVideoWriter_VFW( const char* filename, int fourcc,
|
132
|
+
double fps, CvSize frameSize, int is_color );
|
133
|
+
CvCapture* cvCreateCameraCapture_DShow( int index );
|
134
|
+
CvCapture* cvCreateCameraCapture_OpenNI( int index );
|
135
|
+
CvCapture* cvCreateCameraCapture_Android( int index );
|
136
|
+
CvCapture* cvCreateCameraCapture_XIMEA( int index );
|
137
|
+
|
138
|
+
CVAPI(int) cvHaveImageReader(const char* filename);
|
139
|
+
CVAPI(int) cvHaveImageWriter(const char* filename);
|
140
|
+
|
141
|
+
CvCapture* cvCreateFileCapture_Images(const char* filename);
|
142
|
+
CvVideoWriter* cvCreateVideoWriter_Images(const char* filename);
|
143
|
+
|
144
|
+
CvCapture* cvCreateFileCapture_XINE (const char* filename);
|
145
|
+
|
146
|
+
#define CV_CAP_GSTREAMER_1394 0
|
147
|
+
#define CV_CAP_GSTREAMER_V4L 1
|
148
|
+
#define CV_CAP_GSTREAMER_V4L2 2
|
149
|
+
#define CV_CAP_GSTREAMER_FILE 3
|
150
|
+
|
151
|
+
CvCapture* cvCreateCapture_GStreamer(int type, const char *filename);
|
152
|
+
CvCapture* cvCreateFileCapture_FFMPEG_proxy(const char* filename);
|
153
|
+
|
154
|
+
|
155
|
+
CvVideoWriter* cvCreateVideoWriter_FFMPEG_proxy( const char* filename, int fourcc,
|
156
|
+
double fps, CvSize frameSize, int is_color );
|
157
|
+
|
158
|
+
CvCapture * cvCreateFileCapture_QT (const char * filename);
|
159
|
+
CvCapture * cvCreateCameraCapture_QT (const int index);
|
160
|
+
|
161
|
+
CvVideoWriter* cvCreateVideoWriter_QT ( const char* filename, int fourcc,
|
162
|
+
double fps, CvSize frameSize, int is_color );
|
163
|
+
|
164
|
+
CvCapture * cvCreateCameraCapture_Unicap (const int index);
|
165
|
+
CvCapture * cvCreateCameraCapture_PvAPI (const int index);
|
166
|
+
CvVideoWriter* cvCreateVideoWriter_GStreamer( const char* filename, int fourcc,
|
167
|
+
double fps, CvSize frameSize, int is_color );
|
168
|
+
|
169
|
+
//Yannick Verdie 2010
|
170
|
+
double cvGetModeWindow_W32(const char* name);
|
171
|
+
double cvGetModeWindow_GTK(const char* name);
|
172
|
+
double cvGetModeWindow_CARBON(const char* name);
|
173
|
+
|
174
|
+
void cvSetModeWindow_W32(const char* name, double prop_value);
|
175
|
+
void cvSetModeWindow_GTK(const char* name, double prop_value);
|
176
|
+
void cvSetModeWindow_CARBON(const char* name, double prop_value);
|
177
|
+
|
178
|
+
//for QT
|
179
|
+
#if defined (HAVE_QT)
|
180
|
+
double cvGetModeWindow_QT(const char* name);
|
181
|
+
void cvSetModeWindow_QT(const char* name, double prop_value);
|
182
|
+
double cvGetPropWindow_QT(const char* name);
|
183
|
+
void cvSetPropWindow_QT(const char* name,double prop_value);
|
184
|
+
double cvGetRatioWindow_QT(const char* name);
|
185
|
+
void cvSetRatioWindow_QT(const char* name,double prop_value);
|
186
|
+
#endif
|
187
|
+
|
188
|
+
/*namespace cv
|
189
|
+
{
|
190
|
+
|
191
|
+
class CV_EXPORTS BaseWindow
|
192
|
+
{
|
193
|
+
public:
|
194
|
+
BaseWindow(const String& name, int flags=0);
|
195
|
+
virtual ~BaseWindow();
|
196
|
+
virtual void close();
|
197
|
+
virtual void show(const Mat& mat);
|
198
|
+
virtual void resize(Size size);
|
199
|
+
virtual void move(Point topleft);
|
200
|
+
virtual Size size() const;
|
201
|
+
virtual Point topLeft() const;
|
202
|
+
virtual void setGeometry(Point topLeft, Size size);
|
203
|
+
virtual void getGeometry(Point& topLeft, Size& size) const;
|
204
|
+
virtual String getTitle() const;
|
205
|
+
virtual void setTitle(const String& str);
|
206
|
+
virtual String getName() const;
|
207
|
+
virtual void setScaleMode(int mode);
|
208
|
+
virtual int getScaleMode();
|
209
|
+
virtual void setScrollPos(double pos);
|
210
|
+
virtual double getScrollPos() const;
|
211
|
+
virtual void setScale(double scale);
|
212
|
+
virtual double getScale() const;
|
213
|
+
virtual Point getImageCoords(Point pos) const;
|
214
|
+
virtual Scalar getPixelValue(Point pos, const String& colorspace=String()) const;
|
215
|
+
|
216
|
+
virtual void addTrackbar( const String& trackbar, int low, int high, int step );
|
217
|
+
};
|
218
|
+
|
219
|
+
typedef Ptr<BaseWindow> Window;
|
220
|
+
|
221
|
+
}*/
|
222
|
+
|
223
|
+
#endif /* __HIGHGUI_H_ */
|
@@ -0,0 +1,689 @@
|
|
1
|
+
/*M///////////////////////////////////////////////////////////////////////////////////////
|
2
|
+
//
|
3
|
+
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
4
|
+
//
|
5
|
+
// By downloading, copying, installing or using the software you agree to this license.
|
6
|
+
// If you do not agree to this license, do not download, install,
|
7
|
+
// copy or use the software.
|
8
|
+
//
|
9
|
+
//
|
10
|
+
// Intel License Agreement
|
11
|
+
// For Open Source Computer Vision Library
|
12
|
+
//
|
13
|
+
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
14
|
+
// Third party copyrights are property of their respective owners.
|
15
|
+
//
|
16
|
+
// Redistribution and use in source and binary forms, with or without modification,
|
17
|
+
// are permitted provided that the following conditions are met:
|
18
|
+
//
|
19
|
+
// * Redistribution's of source code must retain the above copyright notice,
|
20
|
+
// this list of conditions and the following disclaimer.
|
21
|
+
//
|
22
|
+
// * Redistribution's in binary form must reproduce the above copyright notice,
|
23
|
+
// this list of conditions and the following disclaimer in the documentation
|
24
|
+
// and/or other materials provided with the distribution.
|
25
|
+
//
|
26
|
+
// * The name of Intel Corporation may not be used to endorse or promote products
|
27
|
+
// derived from this software without specific prior written permission.
|
28
|
+
//
|
29
|
+
// This software is provided by the copyright holders and contributors "as is" and
|
30
|
+
// any express or implied warranties, including, but not limited to, the implied
|
31
|
+
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
32
|
+
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
33
|
+
// indirect, incidental, special, exemplary, or consequential damages
|
34
|
+
// (including, but not limited to, procurement of substitute goods or services;
|
35
|
+
// loss of use, data, or profits; or business interruption) however caused
|
36
|
+
// and on any theory of liability, whether in contract, strict liability,
|
37
|
+
// or tort (including negligence or otherwise) arising in any way out of
|
38
|
+
// the use of this software, even if advised of the possibility of such damage.
|
39
|
+
//
|
40
|
+
//M*/
|
41
|
+
|
42
|
+
#include "precomp.hpp"
|
43
|
+
#include "utils.hpp"
|
44
|
+
|
45
|
+
#define SCALE 14
|
46
|
+
#define cR (int)(0.299*(1 << SCALE) + 0.5)
|
47
|
+
#define cG (int)(0.587*(1 << SCALE) + 0.5)
|
48
|
+
#define cB ((1 << SCALE) - cR - cG)
|
49
|
+
|
50
|
+
void icvCvt_BGR2Gray_8u_C3C1R( const uchar* rgb, int rgb_step,
|
51
|
+
uchar* gray, int gray_step,
|
52
|
+
CvSize size, int _swap_rb )
|
53
|
+
{
|
54
|
+
int i;
|
55
|
+
int swap_rb = _swap_rb ? 2 : 0;
|
56
|
+
for( ; size.height--; gray += gray_step )
|
57
|
+
{
|
58
|
+
for( i = 0; i < size.width; i++, rgb += 3 )
|
59
|
+
{
|
60
|
+
int t = descale( rgb[swap_rb]*cB + rgb[1]*cG + rgb[swap_rb^2]*cR, SCALE );
|
61
|
+
gray[i] = (uchar)t;
|
62
|
+
}
|
63
|
+
|
64
|
+
rgb += rgb_step - size.width*3;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
|
69
|
+
void icvCvt_BGRA2Gray_16u_CnC1R( const ushort* rgb, int rgb_step,
|
70
|
+
ushort* gray, int gray_step,
|
71
|
+
CvSize size, int ncn, int _swap_rb )
|
72
|
+
{
|
73
|
+
int i;
|
74
|
+
int swap_rb = _swap_rb ? 2 : 0;
|
75
|
+
for( ; size.height--; gray += gray_step )
|
76
|
+
{
|
77
|
+
for( i = 0; i < size.width; i++, rgb += ncn )
|
78
|
+
{
|
79
|
+
int t = descale( rgb[swap_rb]*cB + rgb[1]*cG + rgb[swap_rb^2]*cR, SCALE );
|
80
|
+
gray[i] = (ushort)t;
|
81
|
+
}
|
82
|
+
|
83
|
+
rgb += rgb_step - size.width*ncn;
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
void icvCvt_BGRA2Gray_8u_C4C1R( const uchar* rgba, int rgba_step,
|
89
|
+
uchar* gray, int gray_step,
|
90
|
+
CvSize size, int _swap_rb )
|
91
|
+
{
|
92
|
+
int i;
|
93
|
+
int swap_rb = _swap_rb ? 2 : 0;
|
94
|
+
for( ; size.height--; gray += gray_step )
|
95
|
+
{
|
96
|
+
for( i = 0; i < size.width; i++, rgba += 4 )
|
97
|
+
{
|
98
|
+
int t = descale( rgba[swap_rb]*cB + rgba[1]*cG + rgba[swap_rb^2]*cR, SCALE );
|
99
|
+
gray[i] = (uchar)t;
|
100
|
+
}
|
101
|
+
|
102
|
+
rgba += rgba_step - size.width*4;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
|
107
|
+
void icvCvt_Gray2BGR_8u_C1C3R( const uchar* gray, int gray_step,
|
108
|
+
uchar* bgr, int bgr_step, CvSize size )
|
109
|
+
{
|
110
|
+
int i;
|
111
|
+
for( ; size.height--; gray += gray_step )
|
112
|
+
{
|
113
|
+
for( i = 0; i < size.width; i++, bgr += 3 )
|
114
|
+
{
|
115
|
+
bgr[0] = bgr[1] = bgr[2] = gray[i];
|
116
|
+
}
|
117
|
+
bgr += bgr_step - size.width*3;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
|
122
|
+
void icvCvt_Gray2BGR_16u_C1C3R( const ushort* gray, int gray_step,
|
123
|
+
ushort* bgr, int bgr_step, CvSize size )
|
124
|
+
{
|
125
|
+
int i;
|
126
|
+
for( ; size.height--; gray += gray_step/sizeof(gray[0]) )
|
127
|
+
{
|
128
|
+
for( i = 0; i < size.width; i++, bgr += 3 )
|
129
|
+
{
|
130
|
+
bgr[0] = bgr[1] = bgr[2] = gray[i];
|
131
|
+
}
|
132
|
+
bgr += bgr_step/sizeof(bgr[0]) - size.width*3;
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
|
137
|
+
void icvCvt_BGRA2BGR_8u_C4C3R( const uchar* bgra, int bgra_step,
|
138
|
+
uchar* bgr, int bgr_step,
|
139
|
+
CvSize size, int _swap_rb )
|
140
|
+
{
|
141
|
+
int i;
|
142
|
+
int swap_rb = _swap_rb ? 2 : 0;
|
143
|
+
for( ; size.height--; )
|
144
|
+
{
|
145
|
+
for( i = 0; i < size.width; i++, bgr += 3, bgra += 4 )
|
146
|
+
{
|
147
|
+
uchar t0 = bgra[swap_rb], t1 = bgra[1];
|
148
|
+
bgr[0] = t0; bgr[1] = t1;
|
149
|
+
t0 = bgra[swap_rb^2]; bgr[2] = t0;
|
150
|
+
}
|
151
|
+
bgr += bgr_step - size.width*3;
|
152
|
+
bgra += bgra_step - size.width*4;
|
153
|
+
}
|
154
|
+
}
|
155
|
+
|
156
|
+
|
157
|
+
void icvCvt_BGRA2BGR_16u_C4C3R( const ushort* bgra, int bgra_step,
|
158
|
+
ushort* bgr, int bgr_step,
|
159
|
+
CvSize size, int _swap_rb )
|
160
|
+
{
|
161
|
+
int i;
|
162
|
+
int swap_rb = _swap_rb ? 2 : 0;
|
163
|
+
for( ; size.height--; )
|
164
|
+
{
|
165
|
+
for( i = 0; i < size.width; i++, bgr += 3, bgra += 4 )
|
166
|
+
{
|
167
|
+
ushort t0 = bgra[swap_rb], t1 = bgra[1];
|
168
|
+
bgr[0] = t0; bgr[1] = t1;
|
169
|
+
t0 = bgra[swap_rb^2]; bgr[2] = t0;
|
170
|
+
}
|
171
|
+
bgr += bgr_step/sizeof(bgr[0]) - size.width*3;
|
172
|
+
bgra += bgra_step/sizeof(bgra[0]) - size.width*4;
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
176
|
+
|
177
|
+
void icvCvt_BGRA2RGBA_8u_C4R( const uchar* bgra, int bgra_step,
|
178
|
+
uchar* rgba, int rgba_step, CvSize size )
|
179
|
+
{
|
180
|
+
int i;
|
181
|
+
for( ; size.height--; )
|
182
|
+
{
|
183
|
+
for( i = 0; i < size.width; i++, bgra += 4, rgba += 4 )
|
184
|
+
{
|
185
|
+
uchar t0 = bgra[0], t1 = bgra[1];
|
186
|
+
uchar t2 = bgra[2], t3 = bgra[3];
|
187
|
+
rgba[0] = t2; rgba[1] = t1;
|
188
|
+
rgba[2] = t0; rgba[3] = t3;
|
189
|
+
}
|
190
|
+
bgra += bgra_step - size.width*4;
|
191
|
+
rgba += rgba_step - size.width*4;
|
192
|
+
}
|
193
|
+
}
|
194
|
+
|
195
|
+
void icvCvt_BGRA2RGBA_16u_C4R( const ushort* bgra, int bgra_step,
|
196
|
+
ushort* rgba, int rgba_step, CvSize size )
|
197
|
+
{
|
198
|
+
int i;
|
199
|
+
for( ; size.height--; )
|
200
|
+
{
|
201
|
+
for( i = 0; i < size.width; i++, bgra += 4, rgba += 4 )
|
202
|
+
{
|
203
|
+
ushort t0 = bgra[0], t1 = bgra[1];
|
204
|
+
ushort t2 = bgra[2], t3 = bgra[3];
|
205
|
+
|
206
|
+
rgba[0] = t2; rgba[1] = t1;
|
207
|
+
rgba[2] = t0; rgba[3] = t3;
|
208
|
+
}
|
209
|
+
bgra += bgra_step/sizeof(bgra[0]) - size.width*4;
|
210
|
+
rgba += rgba_step/sizeof(rgba[0]) - size.width*4;
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
|
215
|
+
void icvCvt_BGR2RGB_8u_C3R( const uchar* bgr, int bgr_step,
|
216
|
+
uchar* rgb, int rgb_step, CvSize size )
|
217
|
+
{
|
218
|
+
int i;
|
219
|
+
for( ; size.height--; )
|
220
|
+
{
|
221
|
+
for( i = 0; i < size.width; i++, bgr += 3, rgb += 3 )
|
222
|
+
{
|
223
|
+
uchar t0 = bgr[0], t1 = bgr[1], t2 = bgr[2];
|
224
|
+
rgb[2] = t0; rgb[1] = t1; rgb[0] = t2;
|
225
|
+
}
|
226
|
+
bgr += bgr_step - size.width*3;
|
227
|
+
rgb += rgb_step - size.width*3;
|
228
|
+
}
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
void icvCvt_BGR2RGB_16u_C3R( const ushort* bgr, int bgr_step,
|
233
|
+
ushort* rgb, int rgb_step, CvSize size )
|
234
|
+
{
|
235
|
+
int i;
|
236
|
+
for( ; size.height--; )
|
237
|
+
{
|
238
|
+
for( i = 0; i < size.width; i++, bgr += 3, rgb += 3 )
|
239
|
+
{
|
240
|
+
ushort t0 = bgr[0], t1 = bgr[1], t2 = bgr[2];
|
241
|
+
rgb[2] = t0; rgb[1] = t1; rgb[0] = t2;
|
242
|
+
}
|
243
|
+
bgr += bgr_step - size.width*3;
|
244
|
+
rgb += rgb_step - size.width*3;
|
245
|
+
}
|
246
|
+
}
|
247
|
+
|
248
|
+
|
249
|
+
typedef unsigned short ushort;
|
250
|
+
|
251
|
+
void icvCvt_BGR5552Gray_8u_C2C1R( const uchar* bgr555, int bgr555_step,
|
252
|
+
uchar* gray, int gray_step, CvSize size )
|
253
|
+
{
|
254
|
+
int i;
|
255
|
+
for( ; size.height--; gray += gray_step, bgr555 += bgr555_step )
|
256
|
+
{
|
257
|
+
for( i = 0; i < size.width; i++ )
|
258
|
+
{
|
259
|
+
int t = descale( ((((ushort*)bgr555)[i] << 3) & 0xf8)*cB +
|
260
|
+
((((ushort*)bgr555)[i] >> 2) & 0xf8)*cG +
|
261
|
+
((((ushort*)bgr555)[i] >> 7) & 0xf8)*cR, SCALE );
|
262
|
+
gray[i] = (uchar)t;
|
263
|
+
}
|
264
|
+
}
|
265
|
+
}
|
266
|
+
|
267
|
+
|
268
|
+
void icvCvt_BGR5652Gray_8u_C2C1R( const uchar* bgr565, int bgr565_step,
|
269
|
+
uchar* gray, int gray_step, CvSize size )
|
270
|
+
{
|
271
|
+
int i;
|
272
|
+
for( ; size.height--; gray += gray_step, bgr565 += bgr565_step )
|
273
|
+
{
|
274
|
+
for( i = 0; i < size.width; i++ )
|
275
|
+
{
|
276
|
+
int t = descale( ((((ushort*)bgr565)[i] << 3) & 0xf8)*cB +
|
277
|
+
((((ushort*)bgr565)[i] >> 3) & 0xfc)*cG +
|
278
|
+
((((ushort*)bgr565)[i] >> 8) & 0xf8)*cR, SCALE );
|
279
|
+
gray[i] = (uchar)t;
|
280
|
+
}
|
281
|
+
}
|
282
|
+
}
|
283
|
+
|
284
|
+
|
285
|
+
void icvCvt_BGR5552BGR_8u_C2C3R( const uchar* bgr555, int bgr555_step,
|
286
|
+
uchar* bgr, int bgr_step, CvSize size )
|
287
|
+
{
|
288
|
+
int i;
|
289
|
+
for( ; size.height--; bgr555 += bgr555_step )
|
290
|
+
{
|
291
|
+
for( i = 0; i < size.width; i++, bgr += 3 )
|
292
|
+
{
|
293
|
+
int t0 = (((ushort*)bgr555)[i] << 3) & 0xf8;
|
294
|
+
int t1 = (((ushort*)bgr555)[i] >> 2) & 0xf8;
|
295
|
+
int t2 = (((ushort*)bgr555)[i] >> 7) & 0xf8;
|
296
|
+
bgr[0] = (uchar)t0; bgr[1] = (uchar)t1; bgr[2] = (uchar)t2;
|
297
|
+
}
|
298
|
+
bgr += bgr_step - size.width*3;
|
299
|
+
}
|
300
|
+
}
|
301
|
+
|
302
|
+
|
303
|
+
void icvCvt_BGR5652BGR_8u_C2C3R( const uchar* bgr565, int bgr565_step,
|
304
|
+
uchar* bgr, int bgr_step, CvSize size )
|
305
|
+
{
|
306
|
+
int i;
|
307
|
+
for( ; size.height--; bgr565 += bgr565_step )
|
308
|
+
{
|
309
|
+
for( i = 0; i < size.width; i++, bgr += 3 )
|
310
|
+
{
|
311
|
+
int t0 = (((ushort*)bgr565)[i] << 3) & 0xf8;
|
312
|
+
int t1 = (((ushort*)bgr565)[i] >> 3) & 0xfc;
|
313
|
+
int t2 = (((ushort*)bgr565)[i] >> 8) & 0xf8;
|
314
|
+
bgr[0] = (uchar)t0; bgr[1] = (uchar)t1; bgr[2] = (uchar)t2;
|
315
|
+
}
|
316
|
+
bgr += bgr_step - size.width*3;
|
317
|
+
}
|
318
|
+
}
|
319
|
+
|
320
|
+
|
321
|
+
void icvCvt_CMYK2BGR_8u_C4C3R( const uchar* cmyk, int cmyk_step,
|
322
|
+
uchar* bgr, int bgr_step, CvSize size )
|
323
|
+
{
|
324
|
+
int i;
|
325
|
+
for( ; size.height--; )
|
326
|
+
{
|
327
|
+
for( i = 0; i < size.width; i++, bgr += 3, cmyk += 4 )
|
328
|
+
{
|
329
|
+
int c = cmyk[0], m = cmyk[1], y = cmyk[2], k = cmyk[3];
|
330
|
+
c = k - ((255 - c)*k>>8);
|
331
|
+
m = k - ((255 - m)*k>>8);
|
332
|
+
y = k - ((255 - y)*k>>8);
|
333
|
+
bgr[2] = (uchar)c; bgr[1] = (uchar)m; bgr[0] = (uchar)y;
|
334
|
+
}
|
335
|
+
bgr += bgr_step - size.width*3;
|
336
|
+
cmyk += cmyk_step - size.width*4;
|
337
|
+
}
|
338
|
+
}
|
339
|
+
|
340
|
+
|
341
|
+
void icvCvt_CMYK2Gray_8u_C4C1R( const uchar* cmyk, int cmyk_step,
|
342
|
+
uchar* gray, int gray_step, CvSize size )
|
343
|
+
{
|
344
|
+
int i;
|
345
|
+
for( ; size.height--; )
|
346
|
+
{
|
347
|
+
for( i = 0; i < size.width; i++, cmyk += 4 )
|
348
|
+
{
|
349
|
+
int c = cmyk[0], m = cmyk[1], y = cmyk[2], k = cmyk[3];
|
350
|
+
c = k - ((255 - c)*k>>8);
|
351
|
+
m = k - ((255 - m)*k>>8);
|
352
|
+
y = k - ((255 - y)*k>>8);
|
353
|
+
int t = descale( y*cB + m*cG + c*cR, SCALE );
|
354
|
+
gray[i] = (uchar)t;
|
355
|
+
}
|
356
|
+
gray += gray_step;
|
357
|
+
cmyk += cmyk_step - size.width*4;
|
358
|
+
}
|
359
|
+
}
|
360
|
+
|
361
|
+
|
362
|
+
void CvtPaletteToGray( const PaletteEntry* palette, uchar* grayPalette, int entries )
|
363
|
+
{
|
364
|
+
int i;
|
365
|
+
for( i = 0; i < entries; i++ )
|
366
|
+
{
|
367
|
+
icvCvt_BGR2Gray_8u_C3C1R( (uchar*)(palette + i), 0, grayPalette + i, 0, cvSize(1,1) );
|
368
|
+
}
|
369
|
+
}
|
370
|
+
|
371
|
+
|
372
|
+
void FillGrayPalette( PaletteEntry* palette, int bpp, bool negative )
|
373
|
+
{
|
374
|
+
int i, length = 1 << bpp;
|
375
|
+
int xor_mask = negative ? 255 : 0;
|
376
|
+
|
377
|
+
for( i = 0; i < length; i++ )
|
378
|
+
{
|
379
|
+
int val = (i * 255/(length - 1)) ^ xor_mask;
|
380
|
+
palette[i].b = palette[i].g = palette[i].r = (uchar)val;
|
381
|
+
palette[i].a = 0;
|
382
|
+
}
|
383
|
+
}
|
384
|
+
|
385
|
+
|
386
|
+
bool IsColorPalette( PaletteEntry* palette, int bpp )
|
387
|
+
{
|
388
|
+
int i, length = 1 << bpp;
|
389
|
+
|
390
|
+
for( i = 0; i < length; i++ )
|
391
|
+
{
|
392
|
+
if( palette[i].b != palette[i].g ||
|
393
|
+
palette[i].b != palette[i].r )
|
394
|
+
return true;
|
395
|
+
}
|
396
|
+
|
397
|
+
return false;
|
398
|
+
}
|
399
|
+
|
400
|
+
|
401
|
+
uchar* FillUniColor( uchar* data, uchar*& line_end,
|
402
|
+
int step, int width3,
|
403
|
+
int& y, int height,
|
404
|
+
int count3, PaletteEntry clr )
|
405
|
+
{
|
406
|
+
do
|
407
|
+
{
|
408
|
+
uchar* end = data + count3;
|
409
|
+
|
410
|
+
if( end > line_end )
|
411
|
+
end = line_end;
|
412
|
+
|
413
|
+
count3 -= (int)(end - data);
|
414
|
+
|
415
|
+
for( ; data < end; data += 3 )
|
416
|
+
{
|
417
|
+
WRITE_PIX( data, clr );
|
418
|
+
}
|
419
|
+
|
420
|
+
if( data >= line_end )
|
421
|
+
{
|
422
|
+
line_end += step;
|
423
|
+
data = line_end - width3;
|
424
|
+
if( ++y >= height ) break;
|
425
|
+
}
|
426
|
+
}
|
427
|
+
while( count3 > 0 );
|
428
|
+
|
429
|
+
return data;
|
430
|
+
}
|
431
|
+
|
432
|
+
|
433
|
+
uchar* FillUniGray( uchar* data, uchar*& line_end,
|
434
|
+
int step, int width,
|
435
|
+
int& y, int height,
|
436
|
+
int count, uchar clr )
|
437
|
+
{
|
438
|
+
do
|
439
|
+
{
|
440
|
+
uchar* end = data + count;
|
441
|
+
|
442
|
+
if( end > line_end )
|
443
|
+
end = line_end;
|
444
|
+
|
445
|
+
count -= (int)(end - data);
|
446
|
+
|
447
|
+
for( ; data < end; data++ )
|
448
|
+
{
|
449
|
+
*data = clr;
|
450
|
+
}
|
451
|
+
|
452
|
+
if( data >= line_end )
|
453
|
+
{
|
454
|
+
line_end += step;
|
455
|
+
data = line_end - width;
|
456
|
+
if( ++y >= height ) break;
|
457
|
+
}
|
458
|
+
}
|
459
|
+
while( count > 0 );
|
460
|
+
|
461
|
+
return data;
|
462
|
+
}
|
463
|
+
|
464
|
+
|
465
|
+
uchar* FillColorRow8( uchar* data, uchar* indices, int len, PaletteEntry* palette )
|
466
|
+
{
|
467
|
+
uchar* end = data + len*3;
|
468
|
+
while( (data += 3) < end )
|
469
|
+
{
|
470
|
+
*((PaletteEntry*)(data-3)) = palette[*indices++];
|
471
|
+
}
|
472
|
+
PaletteEntry clr = palette[indices[0]];
|
473
|
+
WRITE_PIX( data - 3, clr );
|
474
|
+
return data;
|
475
|
+
}
|
476
|
+
|
477
|
+
|
478
|
+
uchar* FillGrayRow8( uchar* data, uchar* indices, int len, uchar* palette )
|
479
|
+
{
|
480
|
+
int i;
|
481
|
+
for( i = 0; i < len; i++ )
|
482
|
+
{
|
483
|
+
data[i] = palette[indices[i]];
|
484
|
+
}
|
485
|
+
return data + len;
|
486
|
+
}
|
487
|
+
|
488
|
+
|
489
|
+
uchar* FillColorRow4( uchar* data, uchar* indices, int len, PaletteEntry* palette )
|
490
|
+
{
|
491
|
+
uchar* end = data + len*3;
|
492
|
+
|
493
|
+
while( (data += 6) < end )
|
494
|
+
{
|
495
|
+
int idx = *indices++;
|
496
|
+
*((PaletteEntry*)(data-6)) = palette[idx >> 4];
|
497
|
+
*((PaletteEntry*)(data-3)) = palette[idx & 15];
|
498
|
+
}
|
499
|
+
|
500
|
+
int idx = indices[0];
|
501
|
+
PaletteEntry clr = palette[idx >> 4];
|
502
|
+
WRITE_PIX( data - 6, clr );
|
503
|
+
|
504
|
+
if( data == end )
|
505
|
+
{
|
506
|
+
clr = palette[idx & 15];
|
507
|
+
WRITE_PIX( data - 3, clr );
|
508
|
+
}
|
509
|
+
return end;
|
510
|
+
}
|
511
|
+
|
512
|
+
|
513
|
+
uchar* FillGrayRow4( uchar* data, uchar* indices, int len, uchar* palette )
|
514
|
+
{
|
515
|
+
uchar* end = data + len;
|
516
|
+
while( (data += 2) < end )
|
517
|
+
{
|
518
|
+
int idx = *indices++;
|
519
|
+
data[-2] = palette[idx >> 4];
|
520
|
+
data[-1] = palette[idx & 15];
|
521
|
+
}
|
522
|
+
|
523
|
+
int idx = indices[0];
|
524
|
+
uchar clr = palette[idx >> 4];
|
525
|
+
data[-2] = clr;
|
526
|
+
|
527
|
+
if( data == end )
|
528
|
+
{
|
529
|
+
clr = palette[idx & 15];
|
530
|
+
data[-1] = clr;
|
531
|
+
}
|
532
|
+
return end;
|
533
|
+
}
|
534
|
+
|
535
|
+
|
536
|
+
uchar* FillColorRow1( uchar* data, uchar* indices, int len, PaletteEntry* palette )
|
537
|
+
{
|
538
|
+
uchar* end = data + len*3;
|
539
|
+
|
540
|
+
while( (data += 24) < end )
|
541
|
+
{
|
542
|
+
int idx = *indices++;
|
543
|
+
*((PaletteEntry*)(data - 24)) = palette[(idx & 128) != 0];
|
544
|
+
*((PaletteEntry*)(data - 21)) = palette[(idx & 64) != 0];
|
545
|
+
*((PaletteEntry*)(data - 18)) = palette[(idx & 32) != 0];
|
546
|
+
*((PaletteEntry*)(data - 15)) = palette[(idx & 16) != 0];
|
547
|
+
*((PaletteEntry*)(data - 12)) = palette[(idx & 8) != 0];
|
548
|
+
*((PaletteEntry*)(data - 9)) = palette[(idx & 4) != 0];
|
549
|
+
*((PaletteEntry*)(data - 6)) = palette[(idx & 2) != 0];
|
550
|
+
*((PaletteEntry*)(data - 3)) = palette[(idx & 1) != 0];
|
551
|
+
}
|
552
|
+
|
553
|
+
int idx = indices[0] << 24;
|
554
|
+
for( data -= 24; data < end; data += 3, idx += idx )
|
555
|
+
{
|
556
|
+
PaletteEntry clr = palette[idx < 0];
|
557
|
+
WRITE_PIX( data, clr );
|
558
|
+
}
|
559
|
+
|
560
|
+
return data;
|
561
|
+
}
|
562
|
+
|
563
|
+
|
564
|
+
uchar* FillGrayRow1( uchar* data, uchar* indices, int len, uchar* palette )
|
565
|
+
{
|
566
|
+
uchar* end = data + len;
|
567
|
+
|
568
|
+
while( (data += 8) < end )
|
569
|
+
{
|
570
|
+
int idx = *indices++;
|
571
|
+
*((uchar*)(data - 8)) = palette[(idx & 128) != 0];
|
572
|
+
*((uchar*)(data - 7)) = palette[(idx & 64) != 0];
|
573
|
+
*((uchar*)(data - 6)) = palette[(idx & 32) != 0];
|
574
|
+
*((uchar*)(data - 5)) = palette[(idx & 16) != 0];
|
575
|
+
*((uchar*)(data - 4)) = palette[(idx & 8) != 0];
|
576
|
+
*((uchar*)(data - 3)) = palette[(idx & 4) != 0];
|
577
|
+
*((uchar*)(data - 2)) = palette[(idx & 2) != 0];
|
578
|
+
*((uchar*)(data - 1)) = palette[(idx & 1) != 0];
|
579
|
+
}
|
580
|
+
|
581
|
+
int idx = indices[0] << 24;
|
582
|
+
for( data -= 8; data < end; data++, idx += idx )
|
583
|
+
{
|
584
|
+
data[0] = palette[idx < 0];
|
585
|
+
}
|
586
|
+
|
587
|
+
return data;
|
588
|
+
}
|
589
|
+
|
590
|
+
|
591
|
+
CV_IMPL void
|
592
|
+
cvConvertImage( const CvArr* srcarr, CvArr* dstarr, int flags )
|
593
|
+
{
|
594
|
+
CvMat* temp = 0;
|
595
|
+
|
596
|
+
CV_FUNCNAME( "cvConvertImage" );
|
597
|
+
|
598
|
+
__BEGIN__;
|
599
|
+
|
600
|
+
CvMat srcstub, *src;
|
601
|
+
CvMat dststub, *dst;
|
602
|
+
int src_cn, dst_cn, swap_rb = flags & CV_CVTIMG_SWAP_RB;
|
603
|
+
|
604
|
+
CV_CALL( src = cvGetMat( srcarr, &srcstub ));
|
605
|
+
CV_CALL( dst = cvGetMat( dstarr, &dststub ));
|
606
|
+
|
607
|
+
src_cn = CV_MAT_CN( src->type );
|
608
|
+
dst_cn = CV_MAT_CN( dst->type );
|
609
|
+
|
610
|
+
if( src_cn != 1 && src_cn != 3 && src_cn != 4 )
|
611
|
+
CV_ERROR( CV_BadNumChannels, "Source image must have 1, 3 or 4 channels" );
|
612
|
+
|
613
|
+
if( CV_MAT_DEPTH( dst->type ) != CV_8U )
|
614
|
+
CV_ERROR( CV_BadDepth, "Destination image must be 8u" );
|
615
|
+
|
616
|
+
if( CV_MAT_CN(dst->type) != 1 && CV_MAT_CN(dst->type) != 3 )
|
617
|
+
CV_ERROR( CV_BadNumChannels, "Destination image must have 1 or 3 channels" );
|
618
|
+
|
619
|
+
if( !CV_ARE_DEPTHS_EQ( src, dst ))
|
620
|
+
{
|
621
|
+
int src_depth = CV_MAT_DEPTH(src->type);
|
622
|
+
double scale = src_depth <= CV_8S ? 1 : src_depth <= CV_32S ? 1./256 : 255;
|
623
|
+
double shift = src_depth == CV_8S || src_depth == CV_16S ? 128 : 0;
|
624
|
+
|
625
|
+
if( !CV_ARE_CNS_EQ( src, dst ))
|
626
|
+
{
|
627
|
+
temp = cvCreateMat( src->height, src->width,
|
628
|
+
(src->type & CV_MAT_CN_MASK)|(dst->type & CV_MAT_DEPTH_MASK));
|
629
|
+
cvConvertScale( src, temp, scale, shift );
|
630
|
+
src = temp;
|
631
|
+
}
|
632
|
+
else
|
633
|
+
{
|
634
|
+
cvConvertScale( src, dst, scale, shift );
|
635
|
+
src = dst;
|
636
|
+
}
|
637
|
+
}
|
638
|
+
|
639
|
+
if( src_cn != dst_cn || (src_cn == 3 && swap_rb) )
|
640
|
+
{
|
641
|
+
uchar *s = src->data.ptr, *d = dst->data.ptr;
|
642
|
+
int s_step = src->step, d_step = dst->step;
|
643
|
+
int code = src_cn*10 + dst_cn;
|
644
|
+
CvSize size = { src->cols, src->rows };
|
645
|
+
|
646
|
+
if( CV_IS_MAT_CONT(src->type & dst->type) )
|
647
|
+
{
|
648
|
+
size.width *= size.height;
|
649
|
+
size.height = 1;
|
650
|
+
s_step = d_step = CV_STUB_STEP;
|
651
|
+
}
|
652
|
+
|
653
|
+
switch( code )
|
654
|
+
{
|
655
|
+
case 13:
|
656
|
+
icvCvt_Gray2BGR_8u_C1C3R( s, s_step, d, d_step, size );
|
657
|
+
break;
|
658
|
+
case 31:
|
659
|
+
icvCvt_BGR2Gray_8u_C3C1R( s, s_step, d, d_step, size, swap_rb );
|
660
|
+
break;
|
661
|
+
case 33:
|
662
|
+
assert( swap_rb );
|
663
|
+
icvCvt_RGB2BGR_8u_C3R( s, s_step, d, d_step, size );
|
664
|
+
break;
|
665
|
+
case 41:
|
666
|
+
icvCvt_BGRA2Gray_8u_C4C1R( s, s_step, d, d_step, size, swap_rb );
|
667
|
+
break;
|
668
|
+
case 43:
|
669
|
+
icvCvt_BGRA2BGR_8u_C4C3R( s, s_step, d, d_step, size, swap_rb );
|
670
|
+
break;
|
671
|
+
default:
|
672
|
+
CV_ERROR( CV_StsUnsupportedFormat, "Unsupported combination of input/output formats" );
|
673
|
+
}
|
674
|
+
src = dst;
|
675
|
+
}
|
676
|
+
|
677
|
+
if( flags & CV_CVTIMG_FLIP )
|
678
|
+
{
|
679
|
+
CV_CALL( cvFlip( src, dst, 0 ));
|
680
|
+
}
|
681
|
+
else if( src != dst )
|
682
|
+
{
|
683
|
+
CV_CALL( cvCopy( src, dst ));
|
684
|
+
}
|
685
|
+
|
686
|
+
__END__;
|
687
|
+
|
688
|
+
cvReleaseMat( &temp );
|
689
|
+
}
|