-
Laplacian算子
鎖定
- 中文名
- Laplacian算子
- 外文名
- Laplacian Operator
- 適用領域
- 數學
Laplacian算子定義
如果f是二階可微的實函數,則f的拉普拉斯算子定義為:
(2) 作為一個二階微分算子,拉普拉斯算子把C函數映射到C函數,對於k ≥ 2。表達式(1)(或(2))定義了一個算子Δ : C(R) → C(R),或更一般地,定義了一個算子Δ : C(Ω) → C(Ω),對於任何開集Ω。
Laplacian算子運算模板
0 | 1 | 0 |
1 | -4 | 1 |
0 | 1 | 0 |
如果鄰域系統是8 鄰域,Laplacian 算子的模板為:
1 | 1 | 1 |
1 | -8 | 1 |
1 | 1 | 1 |
前面提過,Laplacian 算子對噪聲比較敏感,所以圖像一般先經過平滑處理,因為平滑處理也是用模板進行的,所以,通常的分割算法都是把Laplacian 算子和平滑算子結合起來生成一個新的模板。
Laplacian算子結果對比
#include <opencv2\opencv.hpp> #include <opencv2\highgui\highgui.hpp> #include <opencv2\imgproc\imgproc.hpp> using namespace cv; int main() { //[0] define the variables Mat src, src_gray, dst, abs_dst; //[1] load the picture src = imread("2.jpg"); //[2] show source picture imshow("Source picture", src); //[3] use Gaussian filter to eliminate noise GaussianBlur(src, src, Size(7, 7), 0, 0, BORDER_DEFAULT); //[4] convert from color picture to gray scale picture cvtColor(src, src_gray, COLOR_BGR2GRAY); //[5] use Laplace function Laplacian(src_gray, dst, CV_16S, 3, 1, 0, BORDER_DEFAULT); //[6] calculate the absolute,and convert the result to 8-bit; convertScaleAbs(dst, abs_dst); //[7] show the effect picture imshow("effect picture", abs_dst); waitKey(0); return 0; }