martes, 6 de noviembre de 2012


EJERCICIO BONIFICACIÓN


TRANSFORMADA HOUGH

realizar la transformada HOUGH de la imagen ''linea.bmp''

CODIGO

img=imread('linea.bmp');%para leer la imagen
imshow(img);
title('Imagen1')

% para la imagen binaria
imb=img;
level = graythresh(imb);
bw=im2bw(imb,level);
title('binarizacion')

bw1=edge(bw,'sobel','vertical');%flitro sobel para la deteccion de bordes

title('bordes sobel')%titulo de la deteccion de bordes

[H,T,R]=hough(bw);%correspondiente a la transformada hough
peaks=houghpeaks(H,10);
lines=houghlines(bw,T,R,peaks);
image

imshow(img);
hold on
title('trasformada Hough')
max_len=0;

for a = 1:length(lines)%lineas para la identificacion de la trans hough
xy = [lines(a).point1; lines(a).point2];
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','blue');
plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');
len = norm(lines(a).point1 - lines(a).point2);
 if( len > max_len)
max_len = len;
xy_long = xy;
  end
     end

RESULTADO OBTENIDO



No hay comentarios:

Publicar un comentario