#include<iostream>
#include<opencv2/opencv.hpp>
using namespace std;
using namespace cv;
Mat srcImage, dstImage;
int g_nOpenValue = 0;
//有滚动条事件时,可以进入回调函数
void on_Trackbar(int, void *)
{
Mat element = getStructuringElement(MORPH_RECT, Size(2 * g_nOpenValue + 1, 2 * g_nOpenValue + 1));
morphologyEx(srcImage, dstImage, CV_MOP_CLOSE, element);
imshow("【闭运算窗口】", dstImage);
}
int main()
{
srcImage = imread("tiger.jpg");
imshow("【原图】", srcImage);
dstImage.create(srcImage.size(), srcImage.type());
namedWindow("【闭运算窗口】");
createTrackbar("Value", "【闭运算窗口】", &g_nOpenValue, 100, on_Trackbar);
on_Trackbar(g_nOpenValue, 0);
waitKey(0);
return 0;
}
Opencv形态学滤波-闭运算
最新推荐文章于 2024-04-04 09:14:23 发布