MATLAB Answers

Extracting lines from outer image.

16 views (last 30 days)
NURUL AMIRA MHD RIZAL
NURUL AMIRA MHD RIZAL on 3 May 2018
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 Comments

Alfonso
Alfonso on 3 May 2018
Do you mean finding the x and y coordinates of the 3 lines which are out of the cyclist?
NURUL AMIRA MHD RIZAL
NURUL AMIRA MHD RIZAL on 3 May 2018
Yes yes. Something like that

Sign in to comment.

Answers (1)

Alfonso
Alfonso on 3 May 2018
Edited: Alfonso on 3 May 2018
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 Comment

NURUL AMIRA MHD RIZAL
NURUL AMIRA MHD RIZAL on 6 May 2018
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)

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!