当前位置:网站首页>Opencv learning log 13 corrosion, expansion, opening and closing operations
Opencv learning log 13 corrosion, expansion, opening and closing operations
2022-07-06 15:43:00 【@Spring sauce】
Preface
This article mainly describes the basic operation of image processing : corrosion 、 Expansion and opening and closing operations .
One 、 Code
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
int main()
{
cv::Mat srcMat = imread("C://Users//john//Desktop//1.jpg", 0);
cv::Mat resMat;
cv::Mat res2Mat;
cv::Mat kernel(5, 5, CV_8UC1);
// imshow("src", srcMat);
//threshold(srcMat, resMat, 100, 255, THRESH_BINARY);
adaptiveThreshold(srcMat, resMat, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY_INV, 15, 10);
imshow("res", resMat);
// morphologyEx(resMat, res2Mat, 0, kernel, Point(-1, -1), 1, BORDER_CONSTANT,morphologyDefaultBorderValue());// corrosion
// morphologyEx(resMat, res2Mat, 1, kernel, Point(-1, -1), 1, BORDER_CONSTANT, morphologyDefaultBorderValue());// inflation
// morphologyEx(resMat, res2Mat, 2, kernel, Point(-1, -1), 1, BORDER_CONSTANT, morphologyDefaultBorderValue());// Open operation
morphologyEx(resMat, res2Mat, 3, kernel, Point(-1, -1), 1, BORDER_CONSTANT, morphologyDefaultBorderValue());// Closed operation
imshow("res2", res2Mat);
waitKey(0);
}
summary
1. The code can run directly , If you don't understand, please leave a message .
边栏推荐
猜你喜欢
随机推荐
ucorelab3
Research Report of exterior wall insulation system (ewis) industry - market status analysis and development prospect prediction
nodejs爬虫
Printing quality inspection and verification system Industry Research Report - market status analysis and development prospect forecast
Report on the market trend, technological innovation and market forecast of printing and decorative paper in China
Accounting regulations and professional ethics [2]
Cost accounting [14]
区间和------离散化
Cost accounting [22]
Accounting regulations and professional ethics [5]
LeetCode#2062. Count vowel substrings in strings
C语言是低级和高级的分水岭
ucorelab4
JS --- JS function and scope (II)
Es6--- two methods of capturing promise status as failed
Accounting regulations and professional ethics [3]
学习记录:理解 SysTick系统定时器,编写延时函数
Crawler series of learning while tapping (3): URL de duplication strategy and Implementation
Borg Maze (BFS+最小生成树)(解题报告)
JS --- detailed explanation of JS DOM (IV)









