transformada de hough
TRANSCRIPT
Ejemplo Transformada Hough Matlab
clcclearallcloseall
imagen=imread('linea.bmp');subplot(2,2,1)imshow(imagen)
title('Imagen Original')
%Binarizacin imagenlevel=graythresh(imagen);bn=im2bw(imagen,level);subplot(2,2,2)imshow(bn)
title('Imagen Binarizada')
%preprocesamientobn=edge(bn,'sobel','vertical');subplot(2,2,3)imshow(bn)
title('Imagen filtrada: detec. de bordes')
subplot(2,2,4)imshow(imagen);
[H,T,R]=hough(bn);peaks=houghpeaks(H,5);lines=houghlines(bn,T,R,peaks);
holdon
max_len=0;
fork=1:length(lines)xy=[lines(k).point1; lines(k).point2];plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');% dibuja el principo y el final de cada segmentoplot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');
% dibuja el segmentolen=norm(lines(k).point1 - lines(k).point2);if( len > max_len) max_len = len; xy_long = xy;endend
title('Imagen original y 5 primeras lneas')