问题分析
内容 1:获取滤波器/卷积核
- 采用 fspecial 函数获取均值滤波器、拉普拉斯算子、prewitt 算子、Sobel
算子,并输出显示这些滤波器,可设置合适的参数、尺寸大小。
- 手动设置 Robert 梯度算子、不同方向的检测算子。
内容 2:图像边缘检测
- 分别读取./data/worldview4_schiphol.jpg、./data/WorlView2-Newzeland.tif
文件,用根据内容 1 中的不同方向(边缘)检测算子,检测不同方向的边缘(由
于图像是 RGB 波段图像,可先通过 rgb2gray 函数将 RGB 图像转换成灰度图像,
然后再进行边缘检测),并显示检测结果
内容 3:实现两种平滑方式
-
用 matlab 实现该平滑算法,并显示结果。可采用./data/worldview4_schiphol.jpg 图像进行测试。
-
用 matlab 实现该平滑算法,并显示结果。可采用./data/worldview4_schiphol.jpg 图像进行测试。
内容 4:图像锐化增强显示
- 采用不同拉普拉斯算子,对./data/blurry_moon.tif 图像进行锐化增强显示,原理参照教材 192 页。
实验数据
- worldview4_schiphol.jpg ,彩色图片;
- WorlView2-Newzeland.tif,四波段彩色图片;
- blurry_moon.tif ,灰度图像。
操作步骤
1 获取滤波器/卷积核
img=imread('blurry_moon.tif');
H2=fspecial('average');
Img2=imfilter(img,H2);
H3=fspecial('prewitt');
Img3=imfilter(img,H3);
H4=fspecial('sobel');
Img4=imfilter(img,H4);
H5=fspecial('laplacian');
Img5=imfilter(img,H5);
H6=[1 0;0 -1];
Img6=imfilter(img,H6);
H7=[0 1;-1 0];
Img7=imfilter(img,H7);
H8=[-1 -1 -1;0 0 0;1 1 1];
Img8=imfilter(img,H8);
H9=[-1 0 1; -1 0 1; -1 0 1];
Img9=imfilter(img,H9);
figure()
subplot(3,3,1),imshow(img),title('原图')
subplot(3,3,2),imshow(Img2),title('均值滤波')
subplot(3,3,3),imshow(Img3),title('Prewitt')
subplot(3,3,4),imshow(Img4),title('Sober')
subplot(3,3,5),imshow(Img5),title('Laplacian')
subplot(3,3,6),imshow(Img6),title('Robert横向')
subplot(3,3,7),imshow(Img7),title('Robert纵向')
subplot(3,3,8),imshow(Img8),title('Prewitt横向')
subplot(3,3,9),imshow(Img9),title('Prewitt纵向')
2 图像边缘检测
img00=imread('worldview4_schiphol.jpg');
img01=imread('WorlView2-Newzeland.tif');
img01=img01(:,:,1:3);
H1=[-1 -1 -1;0 0 0;1 1 1];
H2=[-1 0 1; -1 0 1; -1 0 1];
Img2=imfilter(img00,H1);
Img3=imfilter(img00,H2);
Img5=imfilter(img01,H1);
Img6=imfilter(img01,H2);
figure()
subplot(2,3,1),imshow(img00),title('原图')
subplot(2,3,2),imshow(Img2),title('Prewitt纵向')
subplot(2,3,3),imshow(Img3),title('Prewitt横向')
subplot(2,3,4),imshow(img01),title('原图')
subplot(2,3,5),imshow(Img5),title('Prewitt纵向')
subplot(2,3,6),imshow(Img6),title('Prewitt横向')
3 实现两种平滑方式
img=imread('blurry_moon.tif');
H2=[0 -1 0;-1 4 -1;0 -1 0];
Img2=imfilter(img,H2);
H3=[-1 -1 -1; -1 8 -1; -1 -1 -1];
Img3=imfilter(img,H3);
H4=[1 -2 1; -2 4 -2;1 -2 1];
Img4=imfilter(img,H4);
figure()
subplot(2,2,1),imshow(img),title('原图')
subplot(2,2,2),imshow(Img2),title('1')
subplot(2,2,3),imshow(Img3),title('2')
subplot(2,2,4),imshow(Img4),title('3')