OpenCV 教程 11 : 边缘检测
2020-02-24 本文已影响0人
wjundong
Canny算法
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char const *argv[])
{
Mat image = imread("1.jpg"), gray, edge;
cvtColor(image, gray, COLOR_RGB2GRAY);
imshow("原图", image);
// 用 3x3 的核进行降噪
blur( gray, edge, Size(3,3) );
// 运行Canny 算法, 获得边缘 edge
Canny( edge, edge, 3, 9,3 );
// 输出结果, 将 image 以 edge 作为 Mask 拷贝到 out
Mat out = Mat::zeros(image.size(), image.type());
image.copyTo( out, edge);
imshow("效果", out);
waitKey(0);
return 0;
}

