亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cvcanny.cpp

?? 將OpenCV移植到DSP上
?? 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 "_cv.h"

icvCannyGetSize_t icvCannyGetSize_p = 0;
icvCanny_16s8u_C1R_t icvCanny_16s8u_C1R_p = 0;

CV_IMPL void
cvCanny( const void* srcarr, void* dstarr,
         double low_thresh, double high_thresh, int aperture_size )
{
    static const int sec_tab[] = { 1, 3, 0, 0, 2, 2, 2, 2 };
    CvMat *dx = 0, *dy = 0;
    void *buffer = 0;
    uchar **stack_top, **stack_bottom = 0;

    CV_FUNCNAME( "cvCanny" );

    __BEGIN__;

    CvMat srcstub, *src = (CvMat*)srcarr;
    CvMat dststub, *dst = (CvMat*)dstarr;
    CvSize size;
    int flags = aperture_size;
    int low, high;
    int* mag_buf[3];
    uchar* map;
    int mapstep, maxsize;
    int i, j;
    CvMat mag_row;

    CV_CALL( src = cvGetMat( src, &srcstub ));
    CV_CALL( dst = cvGetMat( dst, &dststub ));

    if( CV_MAT_TYPE( src->type ) != CV_8UC1 ||
        CV_MAT_TYPE( dst->type ) != CV_8UC1 )
        CV_ERROR( CV_StsUnsupportedFormat, "" ); 

    if( !CV_ARE_SIZES_EQ( src, dst ))
        CV_ERROR( CV_StsUnmatchedSizes, "" );

    if( low_thresh > high_thresh )
    {
        double t;
        CV_SWAP( low_thresh, high_thresh, t );
    }

    aperture_size &= INT_MAX;
    if( (aperture_size & 1) == 0 || aperture_size < 3 || aperture_size > 7 )
        CV_ERROR( CV_StsBadFlag, "" );

    size = cvGetMatSize( src );

    dx = cvCreateMat( size.height, size.width, CV_16SC1 );
    dy = cvCreateMat( size.height, size.width, CV_16SC1 );
    cvSobel( src, dx, 1, 0, aperture_size );
    cvSobel( src, dy, 0, 1, aperture_size );

    if( icvCannyGetSize_p && icvCanny_16s8u_C1R_p && !(flags & CV_CANNY_L2_GRADIENT) )
    {
        int buf_size=  0;
        IPPI_CALL( icvCannyGetSize_p( size, &buf_size ));
        CV_CALL( buffer = cvAlloc( buf_size ));
        IPPI_CALL( icvCanny_16s8u_C1R_p( (short*)dx->data.ptr, dx->step,
                                     (short*)dy->data.ptr, dy->step,
                                     dst->data.ptr, dst->step,
                                     size, (float)low_thresh,
                                     (float)high_thresh, buffer ));
        EXIT;
    }

    if( flags & CV_CANNY_L2_GRADIENT )
    {
        Cv32suf ul, uh;
        ul.f = (float)low_thresh;
        uh.f = (float)high_thresh;

        low = ul.i;
        high = uh.i;
    }
    else
    {
        low = cvFloor( low_thresh );
        high = cvFloor( high_thresh );
    }

    CV_CALL( buffer = cvAlloc( (size.width+2)*(size.height+2) +
                                (size.width+2)*3*sizeof(int)) );

    mag_buf[0] = (int*)buffer;
    mag_buf[1] = mag_buf[0] + size.width + 2;
    mag_buf[2] = mag_buf[1] + size.width + 2;
    map = (uchar*)(mag_buf[2] + size.width + 2);
    mapstep = size.width + 2;

    maxsize = MAX( 1 << 10, size.width*size.height/10 );
    CV_CALL( stack_top = stack_bottom = (uchar**)cvAlloc( maxsize*sizeof(stack_top[0]) ));

    memset( mag_buf[0], 0, (size.width+2)*sizeof(int) );
    memset( map, 1, mapstep );
    memset( map + mapstep*(size.height + 1), 1, mapstep );

    /* sector numbers 
       (Top-Left Origin)

        1   2   3
         *  *  * 
          * * *  
        0*******0
          * * *  
         *  *  * 
        3   2   1
    */

    #define CANNY_PUSH(d)    *(d) = (uchar)2, *stack_top++ = (d)
    #define CANNY_POP(d)     (d) = *--stack_top

    mag_row = cvMat( 1, size.width, CV_32F );

    // calculate magnitude and angle of gradient, perform non-maxima supression.
    // fill the map with one of the following values:
    //   0 - the pixel might belong to an edge
    //   1 - the pixel can not belong to an edge
    //   2 - the pixel does belong to an edge
    for( i = 0; i <= size.height; i++ )
    {
        int* _mag = mag_buf[(i > 0) + 1] + 1;
        float* _magf = (float*)_mag;
        const short* _dx = (short*)(dx->data.ptr + dx->step*i);
        const short* _dy = (short*)(dy->data.ptr + dy->step*i);
        uchar* _map;
        int x, y;
        int magstep1, magstep2;
        int prev_flag = 0;

        if( i < size.height )
        {
            _mag[-1] = _mag[size.width] = 0;

            if( !(flags & CV_CANNY_L2_GRADIENT) )
                for( j = 0; j < size.width; j++ )
                    _mag[j] = abs(_dx[j]) + abs(_dy[j]);
            else if( icvFilterSobelVert_8u16s_C1R_p != 0 ) // check for IPP
            {
                // use vectorized sqrt
                mag_row.data.fl = _magf;
                for( j = 0; j < size.width; j++ )
                {
                    x = _dx[j]; y = _dy[j];
                    _magf[j] = (float)((double)x*x + (double)y*y);
                }
                cvPow( &mag_row, &mag_row, 0.5 );
            }
            else
            {
                for( j = 0; j < size.width; j++ )
                {
                    x = _dx[j]; y = _dy[j];
                    _magf[j] = (float)sqrt((double)x*x + (double)y*y);
                }
            }
        }
        else
            memset( _mag-1, 0, (size.width + 2)*sizeof(int) );

        // at the very beginning we do not have a complete ring
        // buffer of 3 magnitude rows for non-maxima suppression
        if( i == 0 )
            continue;

        _map = map + mapstep*i + 1;
        _map[-1] = _map[size.width] = 1;
        
        _mag = mag_buf[1] + 1; // take the central row
        _dx = (short*)(dx->data.ptr + dx->step*(i-1));
        _dy = (short*)(dy->data.ptr + dy->step*(i-1));
        
        magstep1 = (int)(mag_buf[2] - mag_buf[1]);
        magstep2 = (int)(mag_buf[0] - mag_buf[1]);

        if( (stack_top - stack_bottom) + size.width > maxsize )
        {
            uchar** new_stack_bottom;
            maxsize = MAX( maxsize * 3/2, maxsize + size.width );
            CV_CALL( new_stack_bottom = (uchar**)cvAlloc( maxsize * sizeof(stack_top[0])) );
            memcpy( new_stack_bottom, stack_bottom, (stack_top - stack_bottom)*sizeof(stack_top[0]) );
            stack_top = new_stack_bottom + (stack_top - stack_bottom);
            cvFree( &stack_bottom );
            stack_bottom = new_stack_bottom;
        }

        for( j = 0; j < size.width; j++ )
        {
            #define CANNY_SHIFT 15
            #define TG22  (int)(0.4142135623730950488016887242097*(1<<CANNY_SHIFT) + 0.5)

            x = _dx[j];
            y = _dy[j];
            int s = x ^ y;
            int m = _mag[j];

            x = abs(x);
            y = abs(y);
            if( m > low )
            {
                int tg22x = x * TG22;
                int tg67x = tg22x + ((x + x) << CANNY_SHIFT);

                y <<= CANNY_SHIFT;

                if( y < tg22x )
                {
                    if( m > _mag[j-1] && m >= _mag[j+1] )
                    {
                        if( m > high && !prev_flag && _map[j-mapstep] != 2 )
                        {
                            CANNY_PUSH( _map + j );
                            prev_flag = 1;
                        }
                        else
                            _map[j] = (uchar)0;
                        continue;
                    }
                }
                else if( y > tg67x )
                {
                    if( m > _mag[j+magstep2] && m >= _mag[j+magstep1] )
                    {
                        if( m > high && !prev_flag && _map[j-mapstep] != 2 )
                        {
                            CANNY_PUSH( _map + j );
                            prev_flag = 1;
                        }
                        else
                            _map[j] = (uchar)0;
                        continue;
                    }
                }
                else
                {
                    s = s < 0 ? -1 : 1;
                    if( m > _mag[j+magstep2-s] && m > _mag[j+magstep1+s] )
                    {
                        if( m > high && !prev_flag && _map[j-mapstep] != 2 )
                        {
                            CANNY_PUSH( _map + j );
                            prev_flag = 1;
                        }
                        else
                            _map[j] = (uchar)0;
                        continue;
                    }
                }
            }
            prev_flag = 0;
            _map[j] = (uchar)1;
        }

        // scroll the ring buffer
        _mag = mag_buf[0];
        mag_buf[0] = mag_buf[1];
        mag_buf[1] = mag_buf[2];
        mag_buf[2] = _mag;
    }

    // now track the edges (hysteresis thresholding)
    while( stack_top > stack_bottom )
    {
        uchar* m;
        if( (stack_top - stack_bottom) + 8 > maxsize )
        {
            uchar** new_stack_bottom;
            maxsize = MAX( maxsize * 3/2, maxsize + 8 );
            CV_CALL( new_stack_bottom = (uchar**)cvAlloc( maxsize * sizeof(stack_top[0])) );
            memcpy( new_stack_bottom, stack_bottom, (stack_top - stack_bottom)*sizeof(stack_top[0]) );
            stack_top = new_stack_bottom + (stack_top - stack_bottom);
            cvFree( &stack_bottom );
            stack_bottom = new_stack_bottom;
        }

        CANNY_POP(m);
    
        if( !m[-1] )
            CANNY_PUSH( m - 1 );
        if( !m[1] )
            CANNY_PUSH( m + 1 );
        if( !m[-mapstep-1] )
            CANNY_PUSH( m - mapstep - 1 );
        if( !m[-mapstep] )
            CANNY_PUSH( m - mapstep );
        if( !m[-mapstep+1] )
            CANNY_PUSH( m - mapstep + 1 );
        if( !m[mapstep-1] )
            CANNY_PUSH( m + mapstep - 1 );
        if( !m[mapstep] )
            CANNY_PUSH( m + mapstep );
        if( !m[mapstep+1] )
            CANNY_PUSH( m + mapstep + 1 );
    }

    // the final pass, form the final image
    for( i = 0; i < size.height; i++ )
    {
        const uchar* _map = map + mapstep*(i+1) + 1;
        uchar* _dst = dst->data.ptr + dst->step*i;
        
        for( j = 0; j < size.width; j++ )
            _dst[j] = (uchar)-(_map[j] >> 1);
    }

    __END__;

    cvReleaseMat( &dx );
    cvReleaseMat( &dy );
    cvFree( &buffer );
    cvFree( &stack_bottom );
}

/* End of file. */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一二三四久久| 欧美三区在线视频| 欧美理论电影在线| 国产亚洲一二三区| 丝袜国产日韩另类美女| 不卡免费追剧大全电视剧网站| 欧美日韩国产一二三| 国产精品久久久99| 狠狠色丁香婷婷综合| 欧美三级三级三级| 欧美国产成人精品| 国产在线不卡视频| 欧美精品黑人性xxxx| 亚洲美女免费在线| 懂色av中文一区二区三区| 日韩欧美色电影| 香蕉久久夜色精品国产使用方法| 不卡的av在线播放| 国产无一区二区| 国产一区在线观看麻豆| 欧美一级片免费看| 日韩精品一二三四| 精品视频在线视频| 亚洲精品欧美二区三区中文字幕| 国产91精品久久久久久久网曝门| 日韩欧美123| 青青青爽久久午夜综合久久午夜| 欧洲精品中文字幕| 一区二区免费看| 日本道色综合久久| 一区二区三区在线看| 99国产麻豆精品| 国产精品激情偷乱一区二区∴| 国产精品888| 日本一区二区三区国色天香| 国产一区二区伦理片| 久久久久久一级片| 成人一级片在线观看| 国产三级三级三级精品8ⅰ区| 国产精品一区二区三区网站| 久久综合九色综合欧美就去吻| 看电影不卡的网站| 久久综合色综合88| 成人在线视频一区| 综合av第一页| 在线观看日韩av先锋影音电影院| 亚洲精品欧美激情| 欧美日产国产精品| 久久66热re国产| 久久精品亚洲精品国产欧美 | 精品日韩99亚洲| 麻豆91在线播放免费| 久久久久久久国产精品影院| 国产成人综合网站| 亚洲欧洲www| 欧美性大战久久久久久久蜜臀 | 亚洲国产精品高清| 91丨porny丨蝌蚪视频| 亚洲精品ww久久久久久p站| 欧美日韩精品三区| 精品一区二区三区的国产在线播放| 久久青草欧美一区二区三区| 成人av午夜影院| 午夜一区二区三区视频| 26uuu亚洲婷婷狠狠天堂| 大桥未久av一区二区三区中文| 一区二区三区四区激情| 精品国内片67194| 99精品欧美一区| 蜜桃av噜噜一区| 亚洲人吸女人奶水| 欧美一区二区三区思思人| 国产91高潮流白浆在线麻豆 | 精品1区2区在线观看| a级精品国产片在线观看| 亚洲国产日韩综合久久精品| 精品欧美乱码久久久久久| 波多野结衣一区二区三区| 午夜伦欧美伦电影理论片| 欧美国产一区在线| 欧美一区二区视频在线观看2022| 大胆亚洲人体视频| 蜜乳av一区二区| 一区二区三区波多野结衣在线观看| 欧美tickling网站挠脚心| 91久久精品一区二区三| 国产成人午夜精品5599| 午夜激情一区二区| 亚洲人成精品久久久久| xfplay精品久久| 欧美日韩一区三区| aaa欧美色吧激情视频| 理论片日本一区| 午夜精品久久久久久不卡8050| 亚洲国产精品99久久久久久久久| 欧美日韩一区中文字幕| 91在线porny国产在线看| 国产毛片一区二区| 蜜桃久久av一区| 国产精品一区二区久激情瑜伽| 午夜久久久影院| 亚洲精选免费视频| 国产精品欧美久久久久一区二区| 欧美成人精精品一区二区频| 欧美丰满少妇xxxbbb| 在线视频一区二区三| 91小视频免费观看| 成人精品在线视频观看| 国产精品18久久久| eeuss影院一区二区三区| 韩国在线一区二区| 久久国产精品一区二区| 另类中文字幕网| 久久国内精品自在自线400部| 天天综合日日夜夜精品| 亚洲成精国产精品女| 亚洲国产精品久久不卡毛片| 亚洲免费看黄网站| 亚洲一区在线视频| 午夜精品久久久久久久99樱桃 | 中文字幕巨乱亚洲| 久久精品视频一区二区三区| 国产日韩精品视频一区| 中文字幕免费不卡| 18欧美亚洲精品| 一区二区三区四区在线| 亚洲国产综合色| 天堂蜜桃91精品| 久久国产生活片100| 国产乱码精品一品二品| 国产成人午夜99999| 99久久亚洲一区二区三区青草| jizzjizzjizz欧美| 欧美伊人久久久久久午夜久久久久| 欧美午夜寂寞影院| 欧美一区二区大片| 国产欧美一区二区三区网站 | 久久久久久久久久久电影| 国产丝袜美腿一区二区三区| 亚洲天堂免费在线观看视频| 亚洲精品国产成人久久av盗摄| 亚洲妇熟xx妇色黄| 久久97超碰色| 99精品欧美一区二区三区小说| 在线观看日韩国产| 日韩免费高清视频| 国产精品乱码一区二三区小蝌蚪| 一区二区久久久久久| 秋霞电影网一区二区| 不卡一二三区首页| 9191成人精品久久| 国产午夜久久久久| 一区二区三区四区在线播放| 久久成人免费网| 成人深夜福利app| 欧美精品久久99久久在免费线| 久久久久久久久蜜桃| 亚洲午夜私人影院| 国产激情一区二区三区四区| 欧美午夜精品一区二区三区| 久久综合色天天久久综合图片| 有码一区二区三区| 国产a精品视频| 91精品蜜臀在线一区尤物| 国产精品乱码妇女bbbb| 首页欧美精品中文字幕| 成人h动漫精品一区二| 日韩一区二区三区视频在线观看| 国产精品久久久久久亚洲伦| 免费成人深夜小野草| 欧美亚洲愉拍一区二区| 国产精品免费视频一区| 精品一区二区免费在线观看| 欧美色偷偷大香| 美洲天堂一区二卡三卡四卡视频| 成人18视频在线播放| 久久久噜噜噜久噜久久综合| 亚洲成av人片一区二区| 色综合亚洲欧洲| 国产精品色在线| 国内精品嫩模私拍在线| 日韩一区二区三免费高清| 亚洲最大成人网4388xx| 99热精品一区二区| 国产欧美日韩另类视频免费观看| 日韩经典中文字幕一区| 在线亚洲精品福利网址导航| 综合激情成人伊人| 成人99免费视频| 亚洲国产成人在线| 国产精品自产自拍| 337p粉嫩大胆噜噜噜噜噜91av| 欧美a级理论片| 7777精品伊人久久久大香线蕉最新版| 椎名由奈av一区二区三区| 懂色av中文字幕一区二区三区| 久久久亚洲国产美女国产盗摄| 激情都市一区二区| 欧美精品一区视频| 久久99日本精品|