⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 代码18-8.txt

📁 matlab宝典书籍源码 全部代码 希望大家喜欢
💻 TXT
字号:

I=imread('eight.tif');                 % 读入图像
subplot(2,3,1),imshow(I);              % 显示原始图像
title('original image');               % 设置图像标题
J=imnoise(I,'salt & pepper',0.02);     % 加均值为 0,方差为 0.02 的椒盐噪声
subplot(2,3,2),imshow(J);              % 显示处理后的图像
title('salt & pepper noise image');    % 设置图像标题
text(-20,320,'Med-value Filter for 3*3 window '); % 添加说明文字
K = medfilt2(J);                       
%用于3×3的滤波窗口对图像J进行中值滤波。
%若用[m,n]的滤波窗口做中值滤波,语法为 K = medfilt2(J,[m,n]) 
subplot(2,3,3),imshow(K,[]);           % 显示处理后的图像
title('medfilter image');              % 设置图像标题
I2=imread('eight.tif');                % 读入图像
subplot(2,3,4),imshow(I2);             % 显示原始图像
title('original image');               % 设置图像标题
J2=imnoise(I2,'gaussian',0.02);        % 加均值为 0,方差为 0.02 的高斯噪声
subplot(2,3,5),imshow(J2);             % 显示处理后的图像
title('gaussian noise image');         % 设置图像标题
K2 = medfilt2(J2);                     % 图像滤波处理
subplot(2,3,6),imshow(K2,[]);          % 显示处理后的图像
title('medfilter image');              % 设置图像标题
I=imread('eight.tif');                 % 读入图像
subplot(2,3,1),imshow(I);              % 显示原始图像
title('original image');               % 设置图像标题
J=imnoise(I,'salt & pepper',0.02);     % 加均值为 0,方差为 0.02 的椒盐噪声
subplot(2,3,2),imshow(J);              % 显示处理后的图像
title('salt & pepper noise image');    % 设置图像标题
text(-20,320,'Med-value Filter for 5*5 window '); % 添加说明文字
K = medfilt2(J,[5,5]);                
%用于5×5的滤波窗口对图像J进行中值滤波。
%若用[m,n]的滤波窗口做中值滤波,语法为 K = medfilt2(J,[m,n]) 
subplot(2,3,3),imshow(K,[]);           % 显示处理后的图像
title('medfilter image');              % 设置图像标题
I2=imread('eight.tif');                % 读入图像
subplot(2,3,4),imshow(I2);             % 显示原始图像
title('original image');             % 设置图像标题
J2=imnoise(I2,'gaussian',0.02);      % 加均值为 0,方差为 0.02 的高斯噪声
subplot(2,3,5),imshow(J2);           % 显示处理后的图像
title('gaussian noise image');       % 设置图像标题
K2 = medfilt2(J2,[5,5]);             % 图像滤波处理
subplot(2,3,6),imshow(K2,[]);        % 显示处理后的图像
title('medfilter image');            % 设置图像标题

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -