#include <iostream>
#include <opencv2\opencv.hpp>
int main() {
//读取图像
cv::Mat img = cv::imread("0015.jpg");
if (!img.data)
{
std::cout << "Error: read image" << std::endl;
return -1;
}
//将图像转化为灰度图
cv::Mat img_gray{};
cv::cvtColor(img, img_gray, cv::COLOR_RGB2GRAY);
//使用高斯滤波
cv::GaussianBlur(img_gray, img_gray, cv::Size(3, 3), 0, 0, cv::BORDER_DEFAULT);
//使用canny算子
double threshold1 = 120.0;
double threshold2 = 55.0;
int apertureSize = 3;
cv::Canny(img_gray, img_gray, threshold1, threshold2, apertureSize);
// 在窗口中显示avatar
cv::imshow("Canny", img_gray);
// 等待按下任意键后窗口关闭
cv::waitKey(0);
}