Calculate the distance L, distance H and circumference (boundary)
1 次查看(过去 30 天)
显示 更早的评论
How can I write code to calculate the distance L; the longest horizontal way, distance H; the highest vertical and circumference (boundary), distance B in Figure A1.jpg that is white in matlab?
A1.jpg
0 个评论
采纳的回答
Image Analyst
2020-1-4
Try this:
binaryImage = bwareafilt(binaryImage, 1); % Extract largest blob only.
props = regionprops(binaryImage, 'BoundingBox', 'Perimeter');
width = props.BoundingBox(3); % Horizontal distance.
height = props.BoundingBox(4); % Vertical distance.
perimeter = props.Perimeter;
2 个评论
Image Analyst
2021-4-16
Pixels.
Max - min + 1 since the bounding box is half a pixel outside of the pixel centers.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!