首页 > 代码库 > openCV中cvSnakeImage()函数代码分析
openCV中cvSnakeImage()函数代码分析
/*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 _CV_SNAKE_BIG 2.e+38f #define _CV_SNAKE_IMAGE 1 #define _CV_SNAKE_GRAD 2 /*F/////////////////////////////////////////////////////////////////////////////////////// // Name: icvSnake8uC1R // Purpose: // Context: // Parameters: // src - source image, // srcStep - its step in bytes, // roi - size of ROI, // pt - pointer to snake points array // n - size of points array, // alpha - pointer to coefficient of continuity energy, // beta - pointer to coefficient of curvature energy, // gamma - pointer to coefficient of image energy, // coeffUsage - if CV_VALUE - alpha, beta, gamma point to single value // if CV_MATAY - point to arrays // criteria - termination criteria. // scheme - image energy scheme // if _CV_SNAKE_IMAGE - image intensity is energy // if _CV_SNAKE_GRAD - magnitude of gradient is energy // Returns: //F*/ static CvStatus icvSnake8uC1R( unsigned char *src, //原始图像数据 int srcStep, //每行的字节数 CvSize roi, //图像尺寸 CvPoint * pt, //轮廓点(变形对象) int n, //轮廓点的个数 float *alpha, //指向α的指针,α能够是单个值,也能够是与轮廓点个数一致的数组 float *beta, //β的值,同α float *gamma, //γ的值,同α int coeffUsage, //确定αβγ是用作单个值还是个数组 CvSize win, //每一个点用于搜索的最小的领域大小,宽度为奇数 CvTermCriteria criteria, //递归迭代终止的条件准则 int scheme ) //确定图像能量场的数据选择,1为灰度,2为灰度梯度 { int i, j, k; int neighbors = win.height * win.width; //当前点领域中点的个数 //当前点的位置 int centerx = win.width >> 1; int centery = win.height >> 1; float invn; //n 的倒数? int iteration = 0; //迭代次数 int converged = 0; //收敛标志,0为非收敛 //能量 float *Econt; // float *Ecurv; //轮廓曲线能量 float *Eimg; //图像能量 float *E; // //αβγ的副本 float _alpha, _beta, _gamma; /*#ifdef GRAD_SNAKE */ float *gradient = NULL; uchar *map = NULL; int map_width = ((roi.width - 1) >> 3) + 1; int map_height = ((roi.height - 1) >> 3) + 1; CvSepFilter pX, pY; #define WTILE_SIZE 8 #define TILE_SIZE (WTILE_SIZE + 2) short dx[TILE_SIZE*TILE_SIZE], dy[TILE_SIZE*TILE_SIZE]; CvMat _dx = cvMat( TILE_SIZE, TILE_SIZE, CV_16SC1, dx ); CvMat _dy = cvMat( TILE_SIZE, TILE_SIZE, CV_16SC1, dy ); CvMat _src = http://www.mamicode.com/cvMat( roi.height, roi.width, CV_8UC1, src );>
转:http://shi-xj.blog.163.com/blog/static/3178051520110911234254/
openCV中cvSnakeImage()函数代码分析
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。