transformada de hough

Post on 13-Oct-2015

5 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

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')

top related