原理:
图像边缘计算 canny算子

 

 


#include <opencv2/opencv.hpp> #include <iostream> #include <math.h> using namespace cv; using namespace std; Mat src, dst,dst2,gray_src; char* INPUT_WIN = "input image"; char* OUTPUT_WIN = "binary image"; int t1_value = 50; int max_value = 255; void Canny_Demo(int, void*) { Mat edge_output; //中值滤波 blur(gray_src, edge_output, Size(3, 3), Point(-1, -1), BORDER_DEFAULT); Canny(edge_output, edge_output, t1_value, t1_value * 2, 3, false); imshow(OUTPUT_WIN, edge_output); } int main() { src = imread(".//pic//kate.png"); namedWindow(INPUT_WIN, CV_WINDOW_AUTOSIZE); namedWindow(OUTPUT_WIN, CV_WINDOW_AUTOSIZE); imshow(INPUT_WIN, src); cvtColor(src, gray_src, CV_BGR2GRAY); createTrackbar("Threshold Value", OUTPUT_WIN, &t1_value, max_value, Canny_Demo); Canny_Demo(0, 0); waitKey(0); return 0; }

 

相关文章:

  • 2021-09-12
  • 2021-12-01
  • 2021-12-14
  • 2021-10-27
  • 2021-05-28
  • 2022-12-23
  • 2021-06-23
  • 2021-05-26
猜你喜欢
  • 2022-12-23
  • 2022-01-09
  • 2021-06-21
  • 2022-12-23
  • 2021-12-22
  • 2021-04-12
相关资源
相似解决方案