opencv例程分析(3)

来源:互联网 发布:产品原型设计软件 编辑:程序博客网 时间:2024/05/17 01:34

//边缘检测之Sobel,Laplacian,Canny

#include "cv.h"#include "highgui.h"using namespace cv;int main(){    Mat src = imread("src\\redBall.jpg");    Mat dst;    //输入图像    //输出图像    //输入图像颜色通道数    //x方向阶数    //y方向阶数    Sobel(src,dst,src.depth(),1,1);    imwrite("sobel.jpg",dst);    //输入图像    //输出图像    //输入图像颜色通道数    Laplacian(src,dst,src.depth());    imwrite("laplacian.jpg",dst);    //输入图像    //输出图像    //彩色转灰度    cvtColor(src,src,CV_BGR2GRAY);  //canny只处理灰度图    //输入图像    //输出图像    //低阈值    //高阈值,opencv建议是低阈值的3倍    //内部sobel滤波器大小    Canny(src,dst,50,150,3);        imwrite("canny.jpg",dst);    imshow("dst",dst);    waitKey();//和0效果相同    return 0;}

参考:
http://blog.csdn.net/xiaowei_cqu/article/details/7829481
http://blog.csdn.net/hitwengqi/article/details/6877864

0 0