日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

opencv14-自定义线性滤波

發(fā)布時(shí)間:2025/3/15 编程问答 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 opencv14-自定义线性滤波 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

?

卷積作用:提取邊緣,圖像增強(qiáng)圖像銳化,模糊圖像

#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 robertx_image, roberty_image;Mat robert_x = (Mat_<int>(2, 2) << 1, 0, 0, -1);filter2D(src, robertx_image, -1, robert_x, Point(-1, -1), 0.0);imshow("robertx", robertx_image);Mat robert_y = (Mat_<int>(2, 2) << 0, 1, -1, 0);filter2D(src, roberty_image, -1, robert_y, Point(-1, -1), 0.0);imshow("roberty", roberty_image);Mat sobelx_image, sobely_image;Mat sobel_x = (Mat_<int>(3, 3) << -1,0,1,-2,0,2,-1,0,1);filter2D(src, sobelx_image, -1, sobel_x, Point(-1, -1), 0.0);imshow("sobelx", sobelx_image);Mat sobel_y = (Mat_<int>(3, 3) << -1,-2,-1,0,0,0,1,2,1);filter2D(src, sobely_image, -1, sobel_y, Point(-1, -1), 0.0);imshow("sobely", sobely_image);Mat lapulasi_image; //邊緣檢測(cè)算子Mat lapulasi = (Mat_<int>(3, 3) << 0,-1,0,-1,4,-1,0,-1,0);filter2D(src, lapulasi_image, -1, lapulasi, Point(-1, -1), 0.0);imshow("lapulasi", lapulasi_image);//利用filter2D自定義卷積核int c = 0;int index = 0;int ksize = 3;Mat filter_image;while (true){c = waitKey(1000);if ((char)c == 27) //ESC{break;}ksize = (index % 5) * 2 + 1;Mat kernal = Mat::ones(Size(ksize,ksize),CV_32F)/(float)(ksize*ksize);filter2D(src, filter_image, -1, kernal, Point(-1, -1));index++;imshow("filter2D", filter_image);}waitKey(0);return 0; }

?

?

總結(jié)

以上是生活随笔為你收集整理的opencv14-自定义线性滤波的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。