Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [] = lineHoughFunc(image, threshold, sigma, npeaks)
- e = edge(image, 'Canny', threshold, sigma);
- [H, th, d] = hough(e);
- peaks = houghpeaks(H, npeaks);
- lines = houghlines(e, th, d, peaks);
- figure, imshow(image), hold on
- max_len = 0;
- for k = 1:length(lines)
- xy = [lines(k).point1; lines(k).point2];
- plot(xy(:,1),xy(:,2),'LineWidth',3,'Color','green');
- % Plot beginnings and ends of lines
- plot(xy(1,1),xy(1,2),'x','LineWidth',3,'Color','yellow');
- plot(xy(2,1),xy(2,2),'x','LineWidth',3,'Color','red');
- % Determine the endpoints of the longest line segment
- len = norm(lines(k).point1 - lines(k).point2);
- if ( len > max_len)
- max_len = len;
- end
- end
- end
Add Comment
Please, Sign In to add comment