FILTRO DE LA 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);
v = zeros(9,1);
for i=2:n-1
for j=2:m-1
v(1)= I(i,j);
v(2)= I(i-1,j);
v(3)= I(i-1,j+1);
v(4)= I(i,j-1);
v(5)= I(i,j);
v(6)= I(i,j+1);
v(7)= I(i+1,j-1);
v(8)= I(i+1,j);
v(9)= I(i+1,j+1);
sort(v)
I(i,j)=v(5)
end
end
FILTRO DE LA MEDIANA
I = [25, 25, 25, 25, 25; 25, 45, 35, 128, 25; 25, 45, 35, 35, 25; 25, 45, 35, 35, 25; 25, 25, 25, 25, 25]
[n,m]=size(I);
for i=2:n-1
for j=2:m-1
I(i,j)=fix((I(i-1,j-1)+I(i-1,j)+I(i-1,j+1)+I(i,j-1)+I(i,j)+I(i,j+1)+I(i+1,j-1)+I(i+1,j)+I(i+1,j+1))/9)
end
end
jueves, 18 de diciembre de 2008
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario