MATLAB: Calculate the distance L, distance H and circumference (boundary)

find length (l)height (h) and circumference (boundary)MATLAB

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

Best Answer

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;
Related Question