C/C++ OpenCV之Laplacian边缘检测
生活随笔
收集整理的這篇文章主要介紹了
C/C++ OpenCV之Laplacian边缘检测
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
計算拉普拉斯變換:Laplacian()
void Laplacian(
inputArray src,
outputArray dst,
int deepth,
int ksize=1,
double scale=1,
double delta=0,
int borderType=BORDER_DEFAULT
)
其中int ksize=1,這是關鍵,這是1,3,5,7這類的奇數,越大說明識別越多
下面是代碼:
#include <opencv2/opencv.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp>using namespace cv;int main() {Mat src, src_gray, dst;src = imread("1.jpg");namedWindow("原圖");imshow("原圖", src);//用高斯濾波降噪Mat g_src;GaussianBlur(src, g_src, Size(3, 3), 0, 0);//灰度圖像cvtColor(g_src, src_gray, COLOR_RGB2GRAY);//開始邊緣檢測(Laplacian)Laplacian(src_gray, dst, CV_8U, 9, 1, 0, BORDER_DEFAULT);namedWindow("效果圖");imshow("效果圖", dst);waitKey();return 0; }運行結果:
我們把
Laplacian(src_gray, dst, CV_8U, 9, 1, 0, BORDER_DEFAULT);
改成
Laplacian(src_gray, dst, CV_8U, 3, 1, 0, BORDER_DEFAULT);
運行結果如下:
總結
以上是生活随笔為你收集整理的C/C++ OpenCV之Laplacian边缘检测的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux中的socket编程,linu
- 下一篇: Qt5.7+Opencv2.4.9人脸识