Effacer les filtres
Effacer les filtres

how I extract all straight line co-ordinates from hough transform ?

1 vue (au cours des 30 derniers jours)
sufian ahmed
sufian ahmed le 23 Mai 2017
Réponse apportée : KSSV le 24 Mai 2017
After hough transform I get some horizontal lines. I want to read this horizontal line data , for example: co-ordinates of those lines. Here is the code :
BW=imread('a.png');
[H,theta,rho] = hough(BW);
% figure
% imshow(imadjust(mat2gray(H)),[],...
% 'XData',theta,...
% 'YData',rho,...
% 'InitialMagnification','fit');
% xlabel('\theta (degrees)')
% ylabel('\rho')
% axis on
% axis normal
% hold on
% colormap(gca,hot);
P = houghpeaks(H,10,'threshold',ceil(0.5*max(H(:))));
% x = theta(P(:,2));
% y = rho(P(:,1));
% plot(x,y,'s','color','black');
lines = houghlines(BW,theta,rho,P,'FillGap',50,'MinLength',20);
figure, imshow(BW), 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
% highlight the longest line segment
plot(xy_long(:,1),xy_long(:,2),'LineWidth',2,'Color','red');
  5 commentaires
KSSV
KSSV le 24 Mai 2017
YOu must attach image too...
sufian ahmed
sufian ahmed le 24 Mai 2017
attached bro

Connectez-vous pour commenter.

Réponses (1)

KSSV
KSSV le 24 Mai 2017
Already you have the lines coordinates in hand. Check lines. You are plotting them too.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by