要求如下:
·
具体函数使用方法可以百度,代码如下:
I=imread('C:\Users\灰太狼\Documents\WeChat Files\wxid_owljcwsbzm5322\FileStorage\File\2024-02\数字图像处理matlab版\数字图像处理matlab版\matlab版数字图像处理的图片(冈萨雷斯)\matlab\dipum_images_ch03\Fig0306(a)(bone-scan-GE).tif')
subplot(331);imshow(I);title('原始图像');hold on;%提取图像
%laplacian变换
w=fspecial('laplacian',0);%生成滤波掩膜w
f2=im2double(I);%变换双精度
g2=imfilter(f2,w,'replicate');%滤波函数
subplot(332);imshow(g2,[]);title('laplacian变换');hold on;%图像展示
%锐化
g=f2+g2;%加法锐化
subplot(333);imshow(g,[]);title('锐化');hold on;%
%用sobel算子计算原图像梯度
x=medfilt2(g);%中值滤波
%imshow(x);%图像展示
w1=fspecial('sobel');%函数生成滤波掩膜
sv=w1;%赋值
sh=sv';%掩膜横纵转换
R1=imfilter(I,sv,'replicate');%滤波
R2=imfilter(I,sh,'replicate');%滤波
x2=max(R1,R2);%取最大值
subplot(334);imshow(R1,[]);title('sobel算子横向梯度');hold on;
subplot(335);imshow(R2,[]);title('sobel算子纵向梯度');hold on;
subplot(336);imshow(x2,[]);title('sobel算子横纵合成');hold on;
%5*5平滑滤波处理
k=fspecial('average',[5 5]);%生成掩膜
k2=imfilter(x2,k,"replicate");%平滑
subplot(337);imshow(k2,[]);title('5*5均值平滑');hold on;
%幂律变化
k3=im2double(k2)%转换双精度
y1=g.*k3;%相乘获取掩膜
subplot(338);imshow(y1,[]);title('掩膜图像');hold on;
y2=y1+f2;%锐化图像
y3=imadjust(y2,[0 1],[0 1],0.5);%扩展灰度集,提升图像对比度
subplot(339);imshow(y3,[]);title('目标图像');hold on;%结果图像
结果如下: