#include<opencv2/imgcodecs.hpp>
#include<opencv2/highgui.hpp>
#include<opencv2/imgproc.hpp>
#include<iostream>
#include<Guass.h>
using namespace cv;
using namespace std;
// Basic Functions ///
void main() {
string path = "Learn-OpenCV-cpp-in-4-Hours-main\\Resources\\test.png";
Mat img = imread(path);
Mat imgGray,imgBlur, imgBlur2,imgCanny, imgDil, imgErode;
double sigma = 0.8;
cvtColor(img, imgGray, COLOR_BGR2GRAY);
GaussianBlur(img, imgBlur, Size(3, 3), 3, 0);
//25-75疑似边界 >75边界
Canny(imgBlur,imgCanny,25,75);
//GaussianFilter(img, imgBlur2, 3, sigma);
Mat kernel = getStructuringElement(MORPH_RECT, Size(5, 5));
dilate(imgCanny, imgDil, kernel);
erode(imgDil, imgErode, kernel);
imshow("Image", img);
//灰度转换
imshow("Image Gray", imgGray);
//高斯模糊
imshow("Image Blur", imgBlur);
//imshow("Image Blur2", imgBlur2);
//canny边缘检测
imshow("ImgCanny", imgCanny);
//膨胀
imshow("Image Dilataion", imgDil);
//腐蚀
imshow("Image Erode", imgErode);
waitKey(0);
c++ opencv C2 Basic Funtions
这篇文章详细介绍了使用OpenCV库在C++中进行图像处理的基本步骤,包括读取图片、灰度转换、高斯模糊、Canny边缘检测以及膨胀和腐蚀操作的示例。
摘要由CSDN通过智能技术生成