c++ opencv C2 Basic Funtions

这篇文章详细介绍了使用OpenCV库在C++中进行图像处理的基本步骤,包括读取图片、灰度转换、高斯模糊、Canny边缘检测以及膨胀和腐蚀操作的示例。
摘要由CSDN通过智能技术生成
#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);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值