编程语言
首页 > 编程语言> > Opencv3 C++ VS2017 学习笔记 08腐蚀膨胀

Opencv3 C++ VS2017 学习笔记 08腐蚀膨胀

作者:互联网

#include "pch.h"
#include <iostream>
#include <opencv2/opencv.hpp>
#include <string>

using namespace std;
using namespace cv; 

Mat src0, src1, dst;
int element_size = 3;
int max_size = 21;
void CallBack_Dem(int, void*);

int main(int argc, char ** argv)
{
	src0 = imread("C:\\Users\\xujin\\Desktop\\test0.JPG");
	if (!src0.data)
	{
		cout << "no image";
		return -1;
	}
	namedWindow("src0_image", WINDOW_AUTOSIZE);
	imshow("src0_image", src0);
	namedWindow("dst_image", WINDOW_AUTOSIZE);
	createTrackbar("Element Size", "dst_image", &element_size, max_size,CallBack_Dem);
	//CallBack_Dem(0, 0);

	waitKey(0);
	return 0;
}

void CallBack_Dem(int, void*)
{
	int s = element_size * 2 + 1;
	Mat structureElement = getStructuringElement(MORPH_RECT, Size(s, s), Point(-1, -1));
	dilate(src0, dst, structureElement, Point(-1, -1));
	//erode(src0, dst, structureElement, Point(-1, -1);
	imshow("dst_image", dst);
	return;
}

 

MillenniumFalcon 发布了11 篇原创文章 · 获赞 2 · 访问量 6985 私信 关注

标签:kernel,函数,int,VS2017,08,腐蚀,Opencv3,src0,void
来源: https://blog.csdn.net/Mrsherlock_/article/details/104510077