how to find 3 points in binary image?
1 次查看(过去 30 天)
显示 更早的评论
I want to find P1,P3 points and mark it with circle symbol.
0 个评论
采纳的回答
Image Analyst
2020-2-2
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.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!