Matlab 数字图像处理 for循环处理多张图片
需求
- 对文件名b1.tif ; b2.tif ; b3.tif ; b4.tif 进行同一图像处理操作
- 用for函数循环输出,避免繁琐操作
关键函数
num2str(i)
实现对文件名编号的读入
代码
for i=1:4
image=imread(['b',num2str(i),'.tif'])
i1=imnoise(image,'salt & pepper',0.2)
i2=medfilt2(i1)
i3=medfilt2(i1,'symmetric')
figure,
subplot(221),imshow(['b',num2str(i),'.tif'])
title('x射线图像')
subplot(222),imshow(i1)
title('被椒盐噪声污染的图像')
subplot(223),imshow(i2)
title('使用函数medfilt2滤波')
subplot(224),imshow(i3)
title('symmetric滤波图像')
end