Laplacian边缘检测原理

Posted 奔跑着的国风

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Laplacian边缘检测原理相关的知识,希望对你有一定的参考价值。




<span style="font-size:18px;color:#000099;">clear;
sourcePic=rgb2gray(imread('lena.jpg'));%读取原图像
grayPic=mat2gray(sourcePic);%转换成灰度图像
subplot(121);imshow(grayPic);title('原图');
[m,n]=size(grayPic);
newGrayPic=grayPic;%为保留图像的边缘一个像素
LaplacianNum=0;%经Laplacian算子计算得到的每个像素的值
LaplacianThreshold=0.21;%设定阈值
for j=2:m-1 %进行边界提取
for k=2:n-1
LaplacianNum=abs(4*grayPic(j,k)-grayPic(j-1,k)-grayPic(j+1,k)-grayPic(j,k+1)-grayPic(j,k-1));
%newGrayPic(j,k)=LaplacianNum;
if(LaplacianNum > LaplacianThreshold)
newGrayPic(j,k)=255;
else
newGrayPic(j,k)=0;
end
end
end
subplot(122),imshow(newGrayPic);title('Laplacian算子的处理结果')</span>


以上是关于Laplacian边缘检测原理的主要内容,如果未能解决你的问题,请参考以下文章

OpenCV实战: SobelLaplacianCanny 边缘检测

OpenCV-Laplacian边缘检测

OpenCV-Laplacian边缘检测

OpenCV——边缘检测(sobel算子Laplacian算子scharr滤波器)

常见边缘检测对比(Roberts算子Prewitt算子Sobel算子Laplacian算子Canny算子)

常见边缘检测对比(Roberts算子Prewitt算子Sobel算子Laplacian算子Canny算子)