一:canny算法
http://www.baike.com/wiki/Canny%E7%AE%97%E5%AD%90
二:cvCanny使用
canny算子有两个阈值,上限和下限,构造函数定义为:
void cvCanny(const CvArr* img,CvArr* edges,double lowthreshold,double highthreshold,int apertureSize=3);
需要注意的是canny需要输入的是灰度图像,所以我们在使用canny之前要使用cvCvtColor将之转换为灰度图像,一下程序对高低阈值不同比例,不同大小进行设置来观察如果一个像素的梯度大与上限值,则被认为是边缘像素,如果小于下限阈值,则被抛弃,那么如果该店的梯度位于两者之间呢?则当其与高于上限值的像素点连接时我们才保留,否则删除。
三:例子
(一)c 无选择条 黑白轮廓
#include <stdio.h>
#include <\cv.h>
#include <opencv\highgui.h>
#include <opeopencvncv\cxcore.h>
using namespace std;
using namespace cv;
int main()
{
IplImage *p1=NULL,*p2=NULL;
p1 = cvLoadImage("Lena.jpg",0);
p2