📄 cxconvert.cpp
字号:
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "_cxcore.h"
/****************************************************************************************\
* Splitting/extracting array channels *
\****************************************************************************************/
#define ICV_DEF_PX2PL2PX_ENTRY_C2( arrtype_ptr, ptr ) \
arrtype_ptr plane0 = ptr[0]; \
arrtype_ptr plane1 = ptr[1];
#define ICV_DEF_PX2PL2PX_ENTRY_C3( arrtype_ptr, ptr ) \
arrtype_ptr plane0 = ptr[0]; \
arrtype_ptr plane1 = ptr[1]; \
arrtype_ptr plane2 = ptr[2];
#define ICV_DEF_PX2PL2PX_ENTRY_C4( arrtype_ptr, ptr ) \
arrtype_ptr plane0 = ptr[0]; \
arrtype_ptr plane1 = ptr[1]; \
arrtype_ptr plane2 = ptr[2]; \
arrtype_ptr plane3 = ptr[3];
#define ICV_DEF_PX2PL_C2( arrtype, len ) \
{ \
int j; \
\
for( j = 0; j < (len); j++, (src) += 2 ) \
{ \
arrtype t0 = (src)[0]; \
arrtype t1 = (src)[1]; \
\
plane0[j] = t0; \
plane1[j] = t1; \
} \
plane0 += dststep; \
plane1 += dststep; \
}
#define ICV_DEF_PX2PL_C3( arrtype, len ) \
{ \
int j; \
\
for( j = 0; j < (len); j++, (src) += 3 ) \
{ \
arrtype t0 = (src)[0]; \
arrtype t1 = (src)[1]; \
arrtype t2 = (src)[2]; \
\
plane0[j] = t0; \
plane1[j] = t1; \
plane2[j] = t2; \
} \
plane0 += dststep; \
plane1 += dststep; \
plane2 += dststep; \
}
#define ICV_DEF_PX2PL_C4( arrtype, len ) \
{ \
int j; \
\
for( j = 0; j < (len); j++, (src) += 4 ) \
{ \
arrtype t0 = (src)[0]; \
arrtype t1 = (src)[1]; \
\
plane0[j] = t0; \
plane1[j] = t1; \
\
t0 = (src)[2]; \
t1 = (src)[3]; \
\
plane2[j] = t0; \
plane3[j] = t1; \
} \
plane0 += dststep; \
plane1 += dststep; \
plane2 += dststep; \
plane3 += dststep; \
}
#define ICV_DEF_PX2PL_COI( arrtype, len, cn ) \
{ \
int j; \
\
for( j = 0; j <= (len) - 4; j += 4, (src) += 4*(cn))\
{ \
arrtype t0 = (src)[0]; \
arrtype t1 = (src)[(cn)]; \
\
(dst)[j] = t0; \
(dst)[j+1] = t1; \
\
t0 = (src)[(cn)*2]; \
t1 = (src)[(cn)*3]; \
\
(dst)[j+2] = t0; \
(dst)[j+3] = t1; \
} \
\
for( ; j < (len); j++, (src) += (cn)) \
{ \
(dst)[j] = (src)[0]; \
} \
}
#define ICV_DEF_COPY_PX2PL_FUNC_2D( arrtype, flavor, \
cn, entry_macro ) \
IPCVAPI_IMPL( CvStatus, icvCopy_##flavor##_C##cn##P##cn##R,\
( const arrtype* src, int srcstep, \
arrtype** dst, int dststep, CvSize size ), \
(src, srcstep, dst, dststep, size)) \
{ \
entry_macro(arrtype*, dst); \
srcstep /= sizeof(src[0]); \
dststep /= sizeof(dst[0][0]); \
\
for( ; size.height--; src += srcstep ) \
{ \
ICV_DEF_PX2PL_C##cn( arrtype, size.width ); \
src -= size.width*(cn); \
} \
\
return CV_OK; \
}
#define ICV_DEF_COPY_PX2PL_FUNC_2D_COI( arrtype, flavor )\
IPCVAPI_IMPL( CvStatus, icvCopy_##flavor##_CnC1CR, \
( const arrtype* src, int srcstep, arrtype* dst, int dststep,\
CvSize size, int cn, int coi ), \
(src, srcstep, dst, dststep, size, cn, coi)) \
{ \
src += coi - 1; \
srcstep /= sizeof(src[0]); \
dststep /= sizeof(dst[0]); \
\
for( ; size.height--; src += srcstep, dst += dststep )\
{ \
ICV_DEF_PX2PL_COI( arrtype, size.width, cn ); \
src -= size.width*(cn); \
} \
\
return CV_OK; \
}
ICV_DEF_COPY_PX2PL_FUNC_2D( uchar, 8u, 2, ICV_DEF_PX2PL2PX_ENTRY_C2 )
ICV_DEF_COPY_PX2PL_FUNC_2D( uchar, 8u, 3, ICV_DEF_PX2PL2PX_ENTRY_C3 )
ICV_DEF_COPY_PX2PL_FUNC_2D( uchar, 8u, 4, ICV_DEF_PX2PL2PX_ENTRY_C4 )
ICV_DEF_COPY_PX2PL_FUNC_2D( ushort, 16s, 2, ICV_DEF_PX2PL2PX_ENTRY_C2 )
ICV_DEF_COPY_PX2PL_FUNC_2D( ushort, 16s, 3, ICV_DEF_PX2PL2PX_ENTRY_C3 )
ICV_DEF_COPY_PX2PL_FUNC_2D( ushort, 16s, 4, ICV_DEF_PX2PL2PX_ENTRY_C4 )
ICV_DEF_COPY_PX2PL_FUNC_2D( int, 32f, 2, ICV_DEF_PX2PL2PX_ENTRY_C2 )
ICV_DEF_COPY_PX2PL_FUNC_2D( int, 32f, 3, ICV_DEF_PX2PL2PX_ENTRY_C3 )
ICV_DEF_COPY_PX2PL_FUNC_2D( int, 32f, 4, ICV_DEF_PX2PL2PX_ENTRY_C4 )
ICV_DEF_COPY_PX2PL_FUNC_2D( int64, 64f, 2, ICV_DEF_PX2PL2PX_ENTRY_C2 )
ICV_DEF_COPY_PX2PL_FUNC_2D( int64, 64f, 3, ICV_DEF_PX2PL2PX_ENTRY_C3 )
ICV_DEF_COPY_PX2PL_FUNC_2D( int64, 64f, 4, ICV_DEF_PX2PL2PX_ENTRY_C4 )
ICV_DEF_COPY_PX2PL_FUNC_2D_COI( uchar, 8u )
ICV_DEF_COPY_PX2PL_FUNC_2D_COI( ushort, 16s )
ICV_DEF_COPY_PX2PL_FUNC_2D_COI( int, 32f )
ICV_DEF_COPY_PX2PL_FUNC_2D_COI( int64, 64f )
/****************************************************************************************\
* Merging/inserting array channels *
\****************************************************************************************/
#define ICV_DEF_PL2PX_C2( arrtype, len ) \
{ \
int j; \
\
for( j = 0; j < (len); j++, (dst) += 2 )\
{ \
arrtype t0 = plane0[j]; \
arrtype t1 = plane1[j]; \
\
dst[0] = t0; \
dst[1] = t1; \
} \
plane0 += srcstep; \
plane1 += srcstep; \
}
#define ICV_DEF_PL2PX_C3( arrtype, len ) \
{ \
int j; \
\
for( j = 0; j < (len); j++, (dst) += 3 )\
{ \
arrtype t0 = plane0[j]; \
arrtype t1 = plane1[j]; \
arrtype t2 = plane2[j]; \
\
dst[0] = t0; \
dst[1] = t1; \
dst[2] = t2; \
} \
plane0 += srcstep; \
plane1 += srcstep; \
plane2 += srcstep; \
}
#define ICV_DEF_PL2PX_C4( arrtype, len ) \
{ \
int j; \
\
for( j = 0; j < (len); j++, (dst) += 4 )\
{ \
arrtype t0 = plane0[j]; \
arrtype t1 = plane1[j]; \
\
dst[0] = t0; \
dst[1] = t1; \
\
t0 = plane2[j]; \
t1 = plane3[j]; \
\
dst[2] = t0; \
dst[3] = t1; \
} \
plane0 += srcstep; \
plane1 += srcstep; \
plane2 += srcstep; \
plane3 += srcstep; \
}
#define ICV_DEF_PL2PX_COI( arrtype, len, cn ) \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -