#include<opencv2/opencv.hpp>
#include<iostream>
#include<math.h>
using namespace cv;
using namespace std;
Mat src,gray_src,dst,drt,final_img;
int value = 50;
int Max_Value = 255;
//const char* output_title= "canny_img";
void canny_Demo(int, void*);
int main()
{
src = imread("lena.jpg");//载入原图
imshow("原图片", src);//显示原图
namedWindow("图片2", CV_WINDOW_AUTOSIZE);
cvtColor(src, gray_src, COLOR_BGR2GRAY);//转灰度图
createTrackbar("Threshold Value:", "图片2", &value, Max_Value, canny_Demo);//创建滑动条
canny_Demo(0, 0);
waitKey(0);
return 0;
}
void canny_Demo(int, void*)
{
blur(gray_src, dst, Size(3, 3), Point(-1, -1), BORDER_DEFAULT);
Canny(dst, final_img, value, value * 2, 3, false);
imshow("图片2", ~final_img);//显示结果图
}
canny边缘检测代码
猜你喜欢
转载自blog.csdn.net/qinshiyang/article/details/82317532
今日推荐
周排行