FILTRO MEDIA
I =[25, 25, 25, 25, 25; 25, 128, 35, 35, 25; 25, 45, 35, 128, 25; 25, 25, 35, 25, 25]
[n,m]=size(I);
vec = zeros(9,1);
for i=2:n-1
for j=2:m-1
vec(1)= I(i,j);
vec(2)= I(i-1,j);
vec(3)= I(i-1,j+1);
vec(4)= I(i,j-1);
vec(5)= I(i,j);
vec(6)= I(i,j+1);
vec(7)= I(i+1,j-1);
vec(8)= I(i+1,j);
vec(9)= I(i+1,j+1);
sort(vec)
I(i,j)=vec(4)
end
end
FILTRO MEDIANA
M = [25, 25, 25, 25, 25;25,45,35,35,35;25,45,35,35,25;25,45,35,35,25;25,25,25,25,25]
[n,m]=size(M)
for i=2:n-1
for j=2:m-1
M(i,j)=fix((M(i-1,j-1)+M(i-1+j)+M(i-1,j+1)+M(i,j-1)+M(i,j)+M(i,j+1)+M(i+1,j-1)+M(i+1,j)+M (i+1,j+1))/9)
end
end
viernes, 2 de enero de 2009
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario