sábado, 16 de mayo de 2009

Filtrado de color rojo en matlab

bola=imread('bola_i.bmp')
a=bola(:,:,1);
b=bola(:,:,2);
c=bola(:,:,3);

h = ones(5,5) / 25;
a = imfilter(a,h);
b = imfilter(b,h);
c = imfilter(c,h);

a = imfilter(a,h);
b = imfilter(b,h);
c = imfilter(c,h);

[m,n]=size(a)
for i=1:m
for j=1:n
a(i,j)=a(i,j)-0.3*b(i,j);
if(a(i,j)<0)
a(i,j)=0;
end
end
end
for i=1:m
for j=1:n
a(i,j)=a(i,j)-0.3*c(i,j);
if(a(i,j)<0)
a(i,j)=0;
end
end
end
level = graythresh(a)
BW = im2bw(a,level)
%BW = im2bw(a,0.3)
imview(BW)

No hay comentarios:

Publicar un comentario