Extracting lines from outer image.

4 次查看(过去 30 天)
uploaded_files/115811/aaa.PNG I have this image. I want to find the lines plotting from outside of the edges so that there will be existence of line intersections. From there I would like to find the angle. Can someone help me with this?
  2 个评论
Alfonso
Alfonso 2018-5-3
Do you mean finding the x and y coordinates of the 3 lines which are out of the cyclist?

请先登录,再进行评论。

回答(1 个)

Alfonso
Alfonso 2018-5-3
编辑:Alfonso 2018-5-3
An option would be using bwboundaries which obtains all the boundaries in the image.
the variable boundary outputs the amount of existing boundaries, in your case there are 32, you can try to plot each one until you find the ones corresponding to the outer lines.
imshow(img_bin)
boundary=bwboundaries(img_bin); % number of boundaries
% First boundary
boundary1 = boundary{1}; % select boundary 1
x1 = boundary1(:,2); % x coords of boundary1
y1 = boundary1(:,1); % y coords of boundary1
hold on
plot(x1, y1, 'r', 'Linewidth', 2)
% Second boundary
boundary2=boundary{2}
x2 = boundary2(:,2); % x coords of boundary2
y2 = boundary2(:,1); % x coords of boundary2
hold on
plot(x2, y2, 'b', 'Linewidth', 2)
% ...
You could also make a for loop which plots all boundaries, but in your case maybe is better trying to plot one at a time and see which ones are the ones you want, it's up to you.
In order to compute all of the boundaries in a loop you can see the examples in https://es.mathworks.com/help/images/ref/bwboundaries.html
  1 个评论
NURUL AMIRA MHD RIZAL
May I know, how do you identified this have 32 boundaries? And some people have been asking me to do hough algorithms to detect the lines from the edges. How can it be? I want something like this so that I can identify the angle at the specific line intersections(at the orange dot)

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by