📄 cxnorm.cpp
字号:
int x = 0; \
ICV_NORM_COI_CASE( _op_, _update_op_, \
worktype, size.width, cn ); \
} \
\
*_norm = post_func((double)norm); \
return CV_OK; \
}
#define ICV_DEF_NORM_DIFF_NOHINT_BLOCK_FUNC_2D( name, _op_, \
_update_op_, post_func, arrtype, \
normtype, worktype, block_size ) \
IPCVAPI_IMPL( CvStatus, name,( const arrtype* src1, int step1, \
const arrtype* src2, int step2, CvSize size, double* _norm),\
(src1, step1, src2, step2, size, _norm)) \
{ \
int remaining = block_size; \
normtype total_norm = 0; \
worktype norm = 0; \
step1 /= sizeof(src1[0]); \
step2 /= sizeof(src2[0]); \
\
for( ; size.height--; src1 += step1, src2 += step2 ) \
{ \
int x = 0; \
while( x < size.width ) \
{ \
int limit = MIN( remaining, size.width - x ); \
remaining -= limit; \
limit += x; \
ICV_NORM_DIFF_CASE( _op_, _update_op_, \
worktype, limit ); \
if( remaining == 0 ) \
{ \
remaining = block_size; \
total_norm += (normtype)norm; \
norm = 0; \
} \
} \
} \
\
total_norm += (normtype)norm; \
*_norm = post_func((double)total_norm); \
return CV_OK; \
}
#define ICV_DEF_NORM_DIFF_NOHINT_FUNC_2D( name, _op_, \
_update_op_, post_func, \
arrtype, normtype, worktype, block_size ) \
IPCVAPI_IMPL( CvStatus, name,( const arrtype* src1, int step1, \
const arrtype* src2, int step2, CvSize size, double* _norm),\
( src1, step1, src2, step2, size, _norm )) \
{ \
normtype norm = 0; \
step1 /= sizeof(src1[0]); \
step2 /= sizeof(src2[0]); \
\
for( ; size.height--; src1 += step1, src2 += step2 ) \
{ \
int x = 0; \
ICV_NORM_DIFF_CASE( _op_, _update_op_, \
worktype, size.width ); \
} \
\
*_norm = post_func((double)norm); \
return CV_OK; \
}
#define ICV_DEF_NORM_DIFF_HINT_FUNC_2D( name, _op_, \
_update_op_, post_func, \
arrtype, normtype, worktype, block_size ) \
IPCVAPI_IMPL( CvStatus, name,( const arrtype* src1, int step1, \
const arrtype* src2, int step2, CvSize size, double* _norm, \
CvHintAlgorithm /*hint*/ ), \
(src1, step1, src2, step2, size, _norm, cvAlgHintAccurate ))\
{ \
normtype norm = 0; \
step1 /= sizeof(src1[0]); \
step2 /= sizeof(src2[0]); \
\
for( ; size.height--; src1 += step1, src2 += step2 ) \
{ \
int x = 0; \
ICV_NORM_DIFF_CASE( _op_, _update_op_, \
worktype, size.width ); \
} \
\
*_norm = post_func((double)norm); \
return CV_OK; \
}
#define ICV_DEF_NORM_DIFF_NOHINT_BLOCK_FUNC_2D_COI( name, _op_,\
_update_op_, post_func, arrtype, \
normtype, worktype, block_size ) \
static CvStatus CV_STDCALL name( const arrtype* src1, int step1,\
const arrtype* src2, int step2, CvSize size, \
int cn, int coi, double* _norm ) \
{ \
int remaining = block_size; \
normtype total_norm = 0; \
worktype norm = 0; \
step1 /= sizeof(src1[0]); \
step2 /= sizeof(src2[0]); \
src1 += coi - 1; \
src2 += coi - 1; \
\
for( ; size.height--; src1 += step1, src2 += step2 ) \
{ \
int x = 0; \
while( x < size.width ) \
{ \
int limit = MIN( remaining, size.width - x ); \
remaining -= limit; \
limit += x; \
ICV_NORM_DIFF_COI_CASE( _op_, _update_op_, \
worktype, limit, cn ); \
if( remaining == 0 ) \
{ \
remaining = block_size; \
total_norm += (normtype)norm; \
norm = 0; \
} \
} \
} \
\
total_norm += (normtype)norm; \
*_norm = post_func((double)total_norm); \
return CV_OK; \
}
#define ICV_DEF_NORM_DIFF_NOHINT_FUNC_2D_COI( name, _op_, \
_update_op_, post_func, \
arrtype, normtype, worktype, block_size ) \
static CvStatus CV_STDCALL name( const arrtype* src1, int step1,\
const arrtype* src2, int step2, CvSize size, \
int cn, int coi, double* _norm ) \
{ \
normtype norm = 0; \
step1 /= sizeof(src1[0]); \
step2 /= sizeof(src2[0]); \
src1 += coi - 1; \
src2 += coi - 1; \
\
for( ; size.height--; src1 += step1, src2 += step2 ) \
{ \
int x = 0; \
ICV_NORM_DIFF_COI_CASE( _op_, _update_op_, \
worktype, size.width, cn ); \
} \
\
*_norm = post_func((double)norm); \
return CV_OK; \
}
/****************************************************************************************\
* N o r m with M A S K *
\****************************************************************************************/
#define ICV_NORM_MASK_CASE( _op_, \
_update_op_, worktype, len ) \
{ \
for( ; x <= (len) - 2; x += 2 ) \
{ \
worktype t0; \
if( mask[x] ) \
{ \
t0 = (src)[x]; \
t0 = _op_(t0); \
norm = _update_op_( norm, t0 ); \
} \
if( mask[x+1] ) \
{ \
t0 = (src)[x+1]; \
t0 = _op_(t0); \
norm = _update_op_( norm, t0 ); \
} \
} \
\
for( ; x < (len); x++ ) \
if( mask[x] ) \
{ \
worktype t0 = (src)[x]; \
t0 = _op_(t0); \
norm = _update_op_( norm, t0 ); \
} \
}
#define ICV_NORM_DIFF_MASK_CASE( _op_, _update_op_, worktype, len ) \
{ \
for( ; x <= (len) - 2; x += 2 ) \
{ \
worktype t0; \
if( mask[x] ) \
{ \
t0 = (src1)[x] - (src2)[x]; \
t0 = _op_(t0); \
norm = _update_op_( norm, t0 ); \
} \
if( mask[x+1] ) \
{ \
t0 = (src1)[x+1] - (src2)[x+1]; \
t0 = _op_(t0); \
norm = _update_op_( norm, t0 ); \
} \
} \
\
for( ; x < (len); x++ ) \
if( mask[x] ) \
{ \
worktype t0 = (src1)[x] - (src2)[x];\
t0 = _op_(t0); \
norm = _update_op_( norm, t0 ); \
} \
}
#define ICV_NORM_MASK_COI_CASE( _op_, _update_op_, worktype, len, cn ) \
{ \
for( ; x < (len); x++ ) \
if( mask[x] ) \
{ \
worktype t0 = (src)[x*(cn)]; \
t0 = _op_(t0); \
norm = _update_op_( norm, t0 ); \
} \
}
#define ICV_NORM_DIFF_MASK_COI_CASE( _op_, _update_op_, worktype, len, cn )\
{ \
for( ; x < (len); x++ ) \
if( mask[x] ) \
{ \
worktype t0 = (src1)[x*(cn)] - (src2)[x*(cn)]; \
t0 = _op_(t0); \
norm = _update_op_( norm, t0 ); \
} \
}
#define ICV_DEF_NORM_MASK_NOHINT_BLOCK_FUNC_2D( name, _op_, \
_update_op_, post_func, arrtype, \
normtype, worktype, block_size ) \
IPCVAPI_IMPL( CvStatus, name, ( const arrtype* src, int step, \
const uchar* mask, int maskstep, CvSize size, double* _norm ),\
(src, step, mask, maskstep, size, _norm) ) \
{ \
int remaining = block_size; \
normtype total_norm = 0; \
worktype norm = 0; \
step /= sizeof(src[0]); \
\
for( ; size.height--; src += step, mask += maskstep ) \
{ \
int x = 0; \
while( x < size.width ) \
{ \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -