cvaccum.cpp.svn-base

来自「非结构化路识别」· SVN-BASE 代码 · 共 1,023 行 · 第 1/4 页

SVN-BASE
1,023
字号
/*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 "_cv.h"

#define  ICV_DEF_ACC_FUNC( name, srctype, dsttype, cvtmacro )                      \
IPCVAPI_IMPL( CvStatus,                                                            \
name,( const srctype *pSrc, int srcStep,                                           \
      dsttype *pSrcDst, int srcDstStep,                                            \
      CvSize roiSize ))                                                            \
{                                                                                  \
    for( ; roiSize.height--; (char*&)pSrc += srcStep,                              \
                             (char*&)pSrcDst += srcDstStep )                       \
    {                                                                              \
        int x;                                                                     \
                                                                                   \
        for( x = 0; x <= roiSize.width - 4; x += 4 )                               \
        {                                                                          \
            dsttype t0 = pSrcDst[x] + cvtmacro(pSrc[x]);                           \
            dsttype t1 = pSrcDst[x + 1] + cvtmacro(pSrc[x + 1]);                   \
                                                                                   \
            pSrcDst[x] = (dsttype)t0;                                              \
            pSrcDst[x + 1] = (dsttype)t1;                                          \
                                                                                   \
            t0 = pSrcDst[x + 2] + cvtmacro(pSrc[x + 2]);                           \
            t1 = pSrcDst[x + 3] + cvtmacro(pSrc[x + 3]);                           \
                                                                                   \
            pSrcDst[x + 2] = (dsttype)t0;                                          \
            pSrcDst[x + 3] = (dsttype)t1;                                          \
        }                                                                          \
                                                                                   \
        for( ; x < roiSize.width; x++ )                                            \
        {                                                                          \
            dsttype t0 = pSrcDst[x] + cvtmacro(pSrc[x]);                           \
            pSrcDst[x] = (dsttype)t0;                                              \
        }                                                                          \
    }                                                                              \
                                                                                   \
    return CV_OK;                                                                  \
}


#define  ICV_DEF_ACCPROD_FUNC( name, srctype, dsttype, cvtmacro )                  \
IPCVAPI_IMPL( CvStatus,                                                            \
name,( const srctype *pSrc1, int src1Step,                                         \
      const srctype *pSrc2, int src2Step,                                          \
      dsttype *pSrcDst, int srcDstStep,                                            \
      CvSize roiSize ))                                                            \
{                                                                                  \
    for( ; roiSize.height--; (char*&)pSrc1 += src1Step,                            \
                             (char*&)pSrc2 += src2Step,                            \
                             (char*&)pSrcDst += srcDstStep )                       \
    {                                                                              \
        int x;                                                                     \
                                                                                   \
        for( x = 0; x <= roiSize.width - 4; x += 4 )                               \
        {                                                                          \
            dsttype t0 = pSrcDst[x] + cvtmacro(pSrc1[x])*cvtmacro(pSrc2[x]);       \
            dsttype t1 = pSrcDst[x+1] + cvtmacro(pSrc1[x+1])*cvtmacro(pSrc2[x+1]); \
                                                                                   \
            pSrcDst[x] = (dsttype)t0;                                              \
            pSrcDst[x + 1] = (dsttype)t1;                                          \
                                                                                   \
            t0 = pSrcDst[x + 2] + cvtmacro(pSrc1[x + 2])*cvtmacro(pSrc2[x + 2]);   \
            t1 = pSrcDst[x + 3] + cvtmacro(pSrc1[x + 3])*cvtmacro(pSrc2[x + 3]);   \
                                                                                   \
            pSrcDst[x + 2] = (dsttype)t0;                                          \
            pSrcDst[x + 3] = (dsttype)t1;                                          \
        }                                                                          \
                                                                                   \
        for( ; x < roiSize.width; x++ )                                            \
        {                                                                          \
            dsttype t0 = pSrcDst[x] + cvtmacro(pSrc1[x])*cvtmacro(pSrc2[x]);       \
            pSrcDst[x] = (dsttype)t0;                                              \
        }                                                                          \
    }                                                                              \
                                                                                   \
    return CV_OK;                                                                  \
}


#define  ICV_DEF_ACCWEIGHT_FUNC( name, srctype, dsttype, cvtmacro )                \
IPCVAPI_IMPL( CvStatus,                                                            \
name,( const srctype *pSrc, int srcStep,                                           \
      dsttype *pSrcDst, int srcDstStep,                                            \
      CvSize roiSize, dsttype alpha ))                                             \
{                                                                                  \
    for( ; roiSize.height--; (char*&)pSrc += srcStep,                              \
                             (char*&)pSrcDst += srcDstStep )                       \
    {                                                                              \
        int x;                                                                     \
                                                                                   \
        for( x = 0; x <= roiSize.width - 4; x += 4 )                               \
        {                                                                          \
            dsttype t0 = pSrcDst[x] + alpha*(cvtmacro(pSrc[x]) - pSrcDst[x]);      \
            dsttype t1 = pSrcDst[x+1] + alpha*(cvtmacro(pSrc[x+1]) - pSrcDst[x+1]);\
                                                                                   \
            pSrcDst[x] = (dsttype)t0;                                              \
            pSrcDst[x + 1] = (dsttype)t1;                                          \
                                                                                   \
            t0 = pSrcDst[x + 2] + alpha*(cvtmacro(pSrc[x + 2]) - pSrcDst[x + 2]);  \
            t1 = pSrcDst[x + 3] + alpha*(cvtmacro(pSrc[x + 3]) - pSrcDst[x + 3]);  \
                                                                                   \
            pSrcDst[x + 2] = (dsttype)t0;                                          \
            pSrcDst[x + 3] = (dsttype)t1;                                          \
        }                                                                          \
                                                                                   \
        for( ; x < roiSize.width; x++ )                                            \
        {                                                                          \
            dsttype t0 = pSrcDst[x] + alpha*(cvtmacro(pSrc[x]) - pSrcDst[x]);      \
            pSrcDst[x] = (dsttype)t0;                                              \
        }                                                                          \
    }                                                                              \
                                                                                   \
    return CV_OK;                                                                  \
}


#define  ICV_DEF_ACCMASK_CASE_C1( dsttype, cvtmacro, maskmacro, prepare_mask )  \
{                                                                               \
    for( x = 0; x <= roiSize.width - 4; x += 4 )                                \
    {                                                                           \
        dsttype t0 = pSrcDst[x] + cvtmacro(maskmacro(pMask[x], pSrc[x]));       \
        dsttype t1 = pSrcDst[x+1] + cvtmacro(maskmacro(pMask[x+1], pSrc[x+1])); \
                                                                                \
        pSrcDst[x] = (dsttype)t0;                                               \
        pSrcDst[x + 1] = (dsttype)t1;                                           \
                                                                                \
        t0 = pSrcDst[x + 2] + cvtmacro(maskmacro(pMask[x + 2], pSrc[x + 2]));   \
        t1 = pSrcDst[x + 3] + cvtmacro(maskmacro(pMask[x + 3], pSrc[x + 3]));   \
                                                                                \
        pSrcDst[x + 2] = (dsttype)t0;                                           \
        pSrcDst[x + 3] = (dsttype)t1;                                           \
    }                                                                           \
                                                                                \
    for( ; x < roiSize.width; x++ )                                             \
    {                                                                           \
        dsttype t0 = pSrcDst[x] + cvtmacro(maskmacro(pMask[x], pSrc[x]));       \
        pSrcDst[x] = (dsttype)t0;                                               \
    }                                                                           \
}


#define  ICV_DEF_ACCMASK_CASE_C2( dsttype, cvtmacro, maskmacro, prepare_mask )  \
{                                                                               \
    for( x = 0; x < roiSize.width; x++ )                                        \
    {                                                                           \
        prepare_mask(m,pMask[x]);                                               \
        dsttype t0 = pSrcDst[x*2] + cvtmacro(maskmacro(pSrc[x*2], m ));         \
        dsttype t1 = pSrcDst[x*2+1] + cvtmacro(maskmacro(pSrc[x*2+1], m ));     \
                                                                                \
        pSrcDst[x*2] = (dsttype)t0;                                             \
        pSrcDst[x*2 + 1] = (dsttype)t1;                                         \
    }                                                                           \
}


#define  ICV_DEF_ACCMASK_CASE_C3( dsttype, cvtmacro, maskmacro, prepare_mask )  \
{                                                                               \
    for( x = 0; x < roiSize.width; x++ )                                        \
    {                                                                           \
        prepare_mask(m,pMask[x]);                                               \
        dsttype t0 = pSrcDst[x*3] + cvtmacro(maskmacro(pSrc[x*3], m ));         \
        dsttype t1 = pSrcDst[x*3+1] + cvtmacro(maskmacro(pSrc[x*3+1], m ));     \
        dsttype t2 = pSrcDst[x*3+2] + cvtmacro(maskmacro(pSrc[x*3+2], m ));     \
                                                                                \
        pSrcDst[x*3] = (dsttype)t0;                                             \
        pSrcDst[x*3 + 1] = (dsttype)t1;                                         \
        pSrcDst[x*3 + 2] = (dsttype)t2;                                         \
    }                                                                           \
}


#define  ICV_DEF_ACCMASK_CASE_C4( dsttype, cvtmacro, maskmacro, prepare_mask )  \
{                                                                               \
    for( x = 0; x < roiSize.width; x++ )                                        \
    {                                                                           \
        prepare_mask(m,pMask[x]);                                               \
        dsttype t0 = pSrcDst[x*4] + cvtmacro(maskmacro(pSrc[x*4], m ));         \
        dsttype t1 = pSrcDst[x*4+1] + cvtmacro(maskmacro(pSrc[x*4+1], m ));     \
        dsttype t2 = pSrcDst[x*4+2] + cvtmacro(maskmacro(pSrc[x*4+2], m ));     \
        dsttype t3 = pSrcDst[x*4+3] + cvtmacro(maskmacro(pSrc[x*4+3], m ));     \
                                                                                \
        pSrcDst[x*4] = (dsttype)t0;                                             \
        pSrcDst[x*4 + 1] = (dsttype)t1;                                         \
        pSrcDst[x*4 + 2] = (dsttype)t2;                                         \
        pSrcDst[x*4 + 3] = (dsttype)t3;                                         \
    }                                                                           \
}


#define  ICV_DEF_ACCMASK_FUNC( name, cn, srctype, dsttype, cvtmacro,            \
                               maskmacro, define_mask, prepare_mask )           \
IPCVAPI_IMPL( CvStatus,                                                         \
name,( const srctype *pSrc, int srcStep,                                        \
      const uchar *pMask, int maskStep,                                         \
      dsttype *pSrcDst, int srcDstStep,                                         \
      CvSize roiSize ))                                                         \
{                                                                               \
    int x;                                                                      \
    define_mask;                                                                \
                                                                                \
    for( ; roiSize.height--; (char*&)pSrc += srcStep,                           \
                             (char*&)pMask += maskStep,                         \
                             (char*&)pSrcDst += srcDstStep )                    \
    {                                                                           \
        ICV_DEF_ACCMASK_CASE_C##cn( dsttype, cvtmacro,                          \
                                    maskmacro, prepare_mask);                   \
    }                                                                           \
                                                                                \
    return CV_OK;                                                               \
}


#define  ICV_DEF_ACCPRODMASK_CASE_C1( dsttype, cvtmacro, maskmacro, prepare_mask)\
{                                                                               \
    for( x = 0; x <= roiSize.width - 4; x += 4 )                                \
    {                                                                           \

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?