糖尿病康复,内容丰富有趣,生活中的好帮手!
糖尿病康复 > 图像锐化拉普拉斯算子matlab Matlab图像锐化-Sobel Laplacian算子 实验教程

图像锐化拉普拉斯算子matlab Matlab图像锐化-Sobel Laplacian算子 实验教程

时间:2021-11-29 11:11:21

相关推荐

图像锐化拉普拉斯算子matlab Matlab图像锐化-Sobel Laplacian算子 实验教程

一.实验内容:

⑴图像的锐化:使用Sobel,Laplacian算子分别对图像进行运算,观察并体会运算结果。

⑵综合练习:对需要进行处理的图像分析,正确运用所学的知识,采用正确的步骤,对图像进行各类处理,以得到令人满意的图像效果。

[3] 编程实现Roberts梯度锐化算法。

二.实验目的:

学会用Matlab中的下列函数对输入图像按实验内容进行运算;感受各种不同的图像处理方法对最终图像效果的影响。

imfilter;fspecial;imadjust;

三.实验步骤:

1.仔细阅读Matlab帮助文件中有关以上函数的使用说明,能充分理解其使用方法并能运用它们完成实验内容。

2.将cameraman.jpg图像文件读入Matlab,使用imfilter函数分别采用Sobel,Laplacian算子对其作锐化运算,显示运算前后的图像。算子输入方法(两种方法都做):

(1)用fspecial函数产生(注意:fspecial仅能产生垂直方向sobel算子,产生Laplacian算子时alpha参数选择0,详见Help)。

(2)直接输入,其中Sobel算子形式为

(水平Sobel)(垂直Sobel)

Laplacian算子形式为

对于Sobel算子,采用生成图像;对于Laplacian算子,直接采用计算结果作为锐化后图像。

3.将skeleton.jpg图像文件读入Matlab,按照以下步骤对其进行处理:

1)用带对角线的Laplacian对其处理,以增强边缘。对角线Laplacian算子为。

2)将1)结果叠加到原始图像上。可以看出噪声增强了(Laplacian算子对噪声敏感),应想法降低。

3)获取Sobel图像并用imfilter对其进行5×5邻域平均,以减少噪声。

4)获取2)和3)相乘图像,噪声得以减少。

5)将4)结果叠加到原始图像上。

6)最后用imadjust函数对5)结果做幂指数为0.2的灰度变换。

4.编写Roberts梯度锐化函数。Roberts梯度为

锐化图像的形成以下式为准,

LG=255,LB=0,门限T适当选择。要求:输入参数为待锐化图像和设定的门限,输出为锐化后图像。读入cell.jpg图像进行验证。显示图像时给出选择的门限值。

解析:%2

a=imread('e:\cameraman.tif');

a=im2double(a);

%(1)

figure;

subplot(1,3,1);imshow(a);title('input image');

h1 = fspecial('sobel');

MotionBlur1 = imfilter(a,h1);

subplot(1,3,2);imshow(MotionBlur1);title('sobel-Motion Blurred Image ');

h2 = fspecial('Laplacia',0);

MotionBlur2 = imfilter(a,h2);

subplot(1,3,3);imshow(MotionBlur2);title('Laplacia-Motion Blurred Image');

%(2)

figure('name','直接输入算子锐化处理','NumberTitle','Off');

subplot(1,3,1);imshow(a);title('input image');

dx=[-1 -2 -1;0 0 0;1 2 1];

dy=[-1 0 1;-2 0 2;-1 0 1];

d=(dx.^2+dy.^2).^0.5;

MotionBlur3= imfilter(a,d);

subplot(1,3,2);imshow(MotionBlur3);title('sobel-direct input-Motion Blurred Image ');

l=[0 -1 0;-1 4 -1;0 -1 0];

MotionBlur4 = imfilter(a,l);

subplot(1,3,3);imshow(MotionBlur4);title('Laplacia-direct input-Motion Blurred Image');

%3

a=imread('e:\skeleton.jpg');

a=im2double(a);

figure;

%(1);

subplot(1,3,1);imshow(a);title('input image');

L=[-1 -1 -1;-1 8 -1;-1 -1 -1];

MotionBlur1 = imfilter(a,L);

subplot(1,3,2);imshow(MotionBlur1);title('对角线Laplacian算子');

%(2)

MotionBlur2=MotionBlur1+a;

subplot(1,3,3);imshow(MotionBlur2);title('叠加后图形');

%(3)

figure;

subplot(2,3,1);imshow(a);title('input image');

h1 = fspecial('sobel');

h2 = imfilter(a,h1);

subplot(2,3,2);imshow(h2);title('sobel-Motion Blurred Image ');

MotionBlur3=imfilter(h2,[5 5]);

subplot(2,3,3);imshow(MotionBlur3);title('sobel-领域平均 ');

%(4,5,6)

MotionBlur4 = imsubtract(MotionBlur2,h2);

subplot(2,3,4);imshow(MotionBlur4);title('相乘图象 ');

MotionBlur5=MotionBlur4+a;

subplot(2,3,5);imshow(MotionBlur5);title('与原始图叠加后图形');

MotionBlur6=imadjust(MotionBlur5,[],[],0.2);

subplot(2,3,6);imshow(MotionBlur6);title('幂指数为0.2的灰度变换');

%4

a1=imread('e:\cell.jpg');

a=im2double(a1);

f=double(a1);

[m,n]=size(f);

for i=1:m

for j=1:n

if i==m

G(i,j)=G(i-1,j) ;

elseif j==n

G(i,j)=G(i,j-1);

else

G(i,j)=abs(f(i,j)-f(i+1,j+1))+abs(f(i+1,j)-f(i,j+1));

end

end

end

Z=f;

figure;

for i=4:8

k=find(G>=i);Z(k)=255;

q=find(G

subplot(2,3,1);imshow(a);title('input image');

subplot(2,3,i-2);imshow(Z);title(['门限T为',num2str(i)]);

end;

如果觉得《图像锐化拉普拉斯算子matlab Matlab图像锐化-Sobel Laplacian算子 实验教程》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。