matlab均值滤波代码6,均值滤波matlab程序代码
%均值濾波
%方法一:filter2
clear all;
figure
I=rgb2gray(imread('132.jpg'));
I=imnoise(I,'salt& pepper',0.1); %加入椒鹽噪聲
K1=filter2(fspecial('average',3),I)/255; %進行3*3均值濾波K2=filter2(fspecial('average',5),I)/255; %進行5*5均值濾波K3=filter2(fspecial('average',7),I)/255; %進行7*7均值濾波subplot(2,2,1),imshow(I),title('椒鹽噪聲圖'); %顯示原圖像subplot(2,2,2),imshow(K1),title('3*3均值濾波圖像');
subplot(2,2,3),imshow(K2),title('5*5均值濾波圖像');
subplot(2,2,4),imshow(K3),title('7*7均值濾波圖像');
%方法二雙循環語句,移動平均法
%均值濾波
clc,clear;
figure
f=rgb2gray(imread('132.jpg'));
subplot(2,2,1),imshow(f),title('原圖');
f1=imnoise(f,'gaussian',0.002,0.0008);
subplot(2,2,2),imshow(f1),title('高斯噪聲圖');
k1=floor(3/2)+1;
k2=floor(3/2)+1;
X=f1;
[M,N]=size(X);
uint8 Y=zeros(M,N);
funBox=zeros(3,3);
fori=1:M-3
for j=1:N-3
funBox=X(i:i+3,j:j+3);
s=sum(funBox(:));
總結
以上是生活随笔為你收集整理的matlab均值滤波代码6,均值滤波matlab程序代码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: kali linux基本命令
- 下一篇: 数字藏品平台开发数字藏品系统开发技术架构