1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
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.
10 // Intel License Agreement
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
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.
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.
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.
42 #ifndef _CXCORE_INTERNAL_H_
43 #define _CXCORE_INTERNAL_H_
45 #if defined _MSC_VER && _MSC_VER >= 1200
46 /* disable warnings related to inline functions */
47 #pragma warning( disable: 4711 4710 4514 )
50 typedef unsigned long ulong;
55 #undef _CV_ALWAYS_PROFILE_
56 #define _CV_ALWAYS_NO_PROFILE_
71 extern const float icv8x32fTab[];
72 #define CV_8TO32F(x) icv8x32fTab[(x)+128]
74 extern const ushort icv8x16uSqrTab[];
75 #define CV_SQR_8U(x) icv8x16uSqrTab[(x)+255]
77 extern const char* icvHersheyGlyphs[];
79 extern const signed char icvDepthToType[];
81 #define icvIplToCvDepth( depth ) \
82 icvDepthToType[(((depth) & 255) >> 2) + ((depth) < 0)]
84 extern const uchar icvSaturate8u[];
85 #define CV_FAST_CAST_8U(t) (assert(-256 <= (t) && (t) <= 512), icvSaturate8u[(t)+256])
86 #define CV_MIN_8U(a,b) ((a) - CV_FAST_CAST_8U((a) - (b)))
87 #define CV_MAX_8U(a,b) ((a) + CV_FAST_CAST_8U((b) - (a)))
89 typedef CvFunc2D_3A1I CvArithmBinMaskFunc2D;
90 typedef CvFunc2D_2A1P1I CvArithmUniMaskFunc2D;
93 /****************************************************************************************\
94 * Complex arithmetics *
95 \****************************************************************************************/
105 CvComplex32f( float _re, float _im=0 ) : re(_re), im(_im) {}
106 explicit CvComplex32f( const CvComplex64f& v );
107 //CvComplex32f( const CvComplex32f& v ) : re(v.re), im(v.im) {}
108 //CvComplex32f& operator = (const CvComplex32f& v ) { re = v.re; im = v.im; return *this; }
109 operator CvComplex64f() const;
117 CvComplex64f( double _re, double _im=0 ) : re(_re), im(_im) {}
118 explicit CvComplex64f( const CvComplex32f& v );
119 //CvComplex64f( const CvComplex64f& v ) : re(v.re), im(v.im) {}
120 //CvComplex64f& operator = (const CvComplex64f& v ) { re = v.re; im = v.im; return *this; }
121 operator CvComplex32f() const;
124 inline CvComplex32f::CvComplex32f( const CvComplex64f& v ) : re((float)v.re), im((float)v.im) {}
125 inline CvComplex64f::CvComplex64f( const CvComplex32f& v ) : re(v.re), im(v.im) {}
127 inline CvComplex32f operator + (CvComplex32f a, CvComplex32f b)
129 return CvComplex32f( a.re + b.re, a.im + b.im );
132 inline CvComplex32f& operator += (CvComplex32f& a, CvComplex32f b)
139 inline CvComplex32f operator - (CvComplex32f a, CvComplex32f b)
141 return CvComplex32f( a.re - b.re, a.im - b.im );
144 inline CvComplex32f& operator -= (CvComplex32f& a, CvComplex32f b)
151 inline CvComplex32f operator - (CvComplex32f a)
153 return CvComplex32f( -a.re, -a.im );
156 inline CvComplex32f operator * (CvComplex32f a, CvComplex32f b)
158 return CvComplex32f( a.re*b.re - a.im*b.im, a.re*b.im + a.im*b.re );
161 inline double abs(CvComplex32f a)
163 return sqrt( (double)a.re*a.re + (double)a.im*a.im );
166 inline CvComplex32f conj(CvComplex32f a)
168 return CvComplex32f( a.re, -a.im );
172 inline CvComplex32f operator / (CvComplex32f a, CvComplex32f b)
174 double t = 1./((double)b.re*b.re + (double)b.im*b.im);
175 return CvComplex32f( (float)((a.re*b.re + a.im*b.im)*t),
176 (float)((-a.re*b.im + a.im*b.re)*t) );
179 inline CvComplex32f operator * (double a, CvComplex32f b)
181 return CvComplex32f( (float)(a*b.re), (float)(a*b.im) );
184 inline CvComplex32f operator * (CvComplex32f a, double b)
186 return CvComplex32f( (float)(a.re*b), (float)(a.im*b) );
189 inline CvComplex32f::operator CvComplex64f() const
191 return CvComplex64f(re,im);
195 inline CvComplex64f operator + (CvComplex64f a, CvComplex64f b)
197 return CvComplex64f( a.re + b.re, a.im + b.im );
200 inline CvComplex64f& operator += (CvComplex64f& a, CvComplex64f b)
207 inline CvComplex64f operator - (CvComplex64f a, CvComplex64f b)
209 return CvComplex64f( a.re - b.re, a.im - b.im );
212 inline CvComplex64f& operator -= (CvComplex64f& a, CvComplex64f b)
219 inline CvComplex64f operator - (CvComplex64f a)
221 return CvComplex64f( -a.re, -a.im );
224 inline CvComplex64f operator * (CvComplex64f a, CvComplex64f b)
226 return CvComplex64f( a.re*b.re - a.im*b.im, a.re*b.im + a.im*b.re );
229 inline double abs(CvComplex64f a)
231 return sqrt( (double)a.re*a.re + (double)a.im*a.im );
234 inline CvComplex64f operator / (CvComplex64f a, CvComplex64f b)
236 double t = 1./((double)b.re*b.re + (double)b.im*b.im);
237 return CvComplex64f( (a.re*b.re + a.im*b.im)*t,
238 (-a.re*b.im + a.im*b.re)*t );
241 inline CvComplex64f operator * (double a, CvComplex64f b)
243 return CvComplex64f( a*b.re, a*b.im );
246 inline CvComplex64f operator * (CvComplex64f a, double b)
248 return CvComplex64f( a.re*b, a.im*b );
251 inline CvComplex64f::operator CvComplex32f() const
253 return CvComplex32f((float)re,(float)im);
256 inline CvComplex64f conj(CvComplex64f a)
258 return CvComplex64f( a.re, -a.im );
261 inline CvComplex64f operator + (CvComplex64f a, CvComplex32f b)
263 return CvComplex64f( a.re + b.re, a.im + b.im );
266 inline CvComplex64f operator + (CvComplex32f a, CvComplex64f b)
268 return CvComplex64f( a.re + b.re, a.im + b.im );
271 inline CvComplex64f operator - (CvComplex64f a, CvComplex32f b)
273 return CvComplex64f( a.re - b.re, a.im - b.im );
276 inline CvComplex64f operator - (CvComplex32f a, CvComplex64f b)
278 return CvComplex64f( a.re - b.re, a.im - b.im );
281 inline CvComplex64f operator * (CvComplex64f a, CvComplex32f b)
283 return CvComplex64f( a.re*b.re - a.im*b.im, a.re*b.im + a.im*b.re );
286 inline CvComplex64f operator * (CvComplex32f a, CvComplex64f b)
288 return CvComplex64f( a.re*b.re - a.im*b.im, a.re*b.im + a.im*b.re );
292 typedef CvStatus (CV_STDCALL * CvCopyMaskFunc)(const void* src, int src_step,
293 void* dst, int dst_step, CvSize size,
294 const void* mask, int mask_step);
296 CvCopyMaskFunc icvGetCopyMaskFunc( int elem_size );
298 CvStatus CV_STDCALL icvSetZero_8u_C1R( uchar* dst, int dststep, CvSize size );
300 CvStatus CV_STDCALL icvScale_32f( const float* src, float* dst, int len, float a, float b );
301 CvStatus CV_STDCALL icvScale_64f( const double* src, double* dst, int len, double a, double b );
303 CvStatus CV_STDCALL icvLUT_Transform8u_8u_C1R( const uchar* src, int srcstep, uchar* dst,
304 int dststep, CvSize size, const uchar* lut );
305 CvStatus CV_STDCALL icvLUT_Transform8u_16u_C1R( const uchar* src, int srcstep, ushort* dst,
306 int dststep, CvSize size, const ushort* lut );
307 CvStatus CV_STDCALL icvLUT_Transform8u_32s_C1R( const uchar* src, int srcstep, int* dst,
308 int dststep, CvSize size, const int* lut );
309 CvStatus CV_STDCALL icvLUT_Transform8u_64f_C1R( const uchar* src, int srcstep, double* dst,
310 int dststep, CvSize size, const double* lut );
312 CvStatus CV_STDCALL icvLUT_Transform8u_8u_C2R( const uchar* src, int srcstep, uchar* dst,
313 int dststep, CvSize size, const uchar* lut );
314 CvStatus CV_STDCALL icvLUT_Transform8u_8u_C3R( const uchar* src, int srcstep, uchar* dst,
315 int dststep, CvSize size, const uchar* lut );
316 CvStatus CV_STDCALL icvLUT_Transform8u_8u_C4R( const uchar* src, int srcstep, uchar* dst,
317 int dststep, CvSize size, const uchar* lut );
319 typedef CvStatus (CV_STDCALL * CvLUT_TransformFunc)( const void* src, int srcstep, void* dst,
320 int dststep, CvSize size, const void* lut );
323 icvLUT_Transform8u_8s_C1R( const uchar* src, int srcstep, char* dst,
324 int dststep, CvSize size, const char* lut )
326 return icvLUT_Transform8u_8u_C1R( src, srcstep, (uchar*)dst,
327 dststep, size, (const uchar*)lut );
331 icvLUT_Transform8u_16s_C1R( const uchar* src, int srcstep, short* dst,
332 int dststep, CvSize size, const short* lut )
334 return icvLUT_Transform8u_16u_C1R( src, srcstep, (ushort*)dst,
335 dststep, size, (const ushort*)lut );
339 icvLUT_Transform8u_32f_C1R( const uchar* src, int srcstep, float* dst,
340 int dststep, CvSize size, const float* lut )
342 return icvLUT_Transform8u_32s_C1R( src, srcstep, (int*)dst,
343 dststep, size, (const int*)lut );
346 #endif /*_CXCORE_INTERNAL_H_*/