How can apply the Hough transform to detect lines in an images?
2 views (last 30 days)
Show older comments
%% Find lines and plot them lines = houghlines(imEdge,T,R,P,'FillGap',30,'MinLength',15); figure, imshow(im), hold on max_len = 0; for k = 1:length(lines) xy = [lines(k).point1; lines(k).point2]; plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
% Plot beginnings and ends of lines
plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
plot(xy(2,1),xy(2,2),'x','LineWidth',2,'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;
xy_long = xy;
end
end
%imclearborder
% highlight the longest line segment
plot(xy_long(:,1),xy_long(:,2),'LineWidth',2,'Col
0 Comments
Answers (0)
See Also
Categories
Find more on Computer Vision with Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!