how to find 3 points in binary image?

1 view (last 30 days)
ankle binary with angle.png
I want to find P1,P3 points and mark it with circle symbol.

Accepted Answer

Image Analyst
Image Analyst on 2 Feb 2020
I'd find the narrowest part first, then scan down line-by-line to get the first widest part. Not the widest part because there seems to be some noise near the bottom
% First smooth the mask
mask = conv2(double(mask), ones(7)/49, 'same') > 0.5;
[rows, columns] = size(mask)
leftBoundary = zeros(rows, 1);
rightBoundary = zeros(rows, 1);
for row = 1 : rows
thisRow = mask(row, :);
col = find(thisRow, 2, 'first')
if ~isempty(col)
leftBoundary = col(1);
rightBoundary = col(2);
end
end
Now see where the left boundary is greatest (most to the right), and the right boundary is least (most to the left) in the top 3/4 or the rows. This will find the narrow part of the leg above the ankle. See if you can do it. Then scan from there down until the boundary reverses direction. When it first reverses direction, that will be the first widest part, which is the ankle. Then you will have the two ankle points and the average of the x and y coordinates will be the mid point.
xMid = (xLeft + xRight) / 2;
yMid = (yLeft + yRight) / 2;
Please give it a try as I don't have time to do the complete project for you.
  10 Comments
wongsathorn pinwihok
wongsathorn pinwihok on 10 Mar 2020
you mean P3 ? It's a 1/3 distance between P1 and P2.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!