Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
sufian ahmed
sufian ahmed el 23 de Mayo de 2017
Respondida: KSSV el 24 de Mayo de 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 comentarios
KSSV
KSSV el 24 de Mayo de 2017
YOu must attach image too...

Iniciar sesión para comentar.

Respuestas (1)

KSSV
KSSV el 24 de Mayo de 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