opencv10-形态学操作
生活随笔
收集整理的這篇文章主要介紹了
opencv10-形态学操作
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?主要針對二值圖像和灰度圖
#include<opencv2\opencv.hpp> #include<opencv2\highgui\highgui.hpp> #include<iostream> #include<math.h> using namespace std; using namespace cv; int main() {Mat src = imread("E:\\vs2015\\opencvstudy\\1.jpg", 1);if (src.empty()){cout << "could not load the src image!" << endl;return -1;}char *input_title = "input Image";imshow(input_title, src);Mat dst_open,dst_close,dst_gradient,dst_tophat,dst_blackhat;char output_title[] = "output Image";Mat kernal = getStructuringElement(MORPH_RECT, Size(3, 3), Point(-1, -1));morphologyEx(src, dst_open, CV_MOP_OPEN, kernal);imshow("dst_open", dst_open);morphologyEx(src, dst_close, CV_MOP_CLOSE, kernal);imshow("dst_close", dst_close);morphologyEx(src, dst_gradient, CV_MOP_GRADIENT, kernal);imshow("dst_gradient", dst_gradient);morphologyEx(src, dst_tophat, CV_MOP_TOPHAT, kernal);imshow("dst_tophat", dst_tophat);morphologyEx(src, dst_blackhat, CV_MOP_BLACKHAT, kernal);imshow("dst_blackhat", dst_blackhat);waitKey(0);return 0; }?
總結
以上是生活随笔為你收集整理的opencv10-形态学操作的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Ubuntu nginx+uwsgi部署
- 下一篇: mysql 导入导出大文件