MATLAB: How to find vertical height in an image

image analysisimage processingImage Processing Toolbox

So I have a bunch of images like the one attached and need to find the vertical height of the white boxes in all of them and Ive been trying but have not succeeded. I do no need the width but need to try and find a way to find the height of these rectangles in about 25 images. I need a way to that is not manually going in there and doing it as well. Thanks for any help

Best Answer

Label the image and call regionprops to get the bounding boxes
[labeledImage, numBlobs] = bwlabel(binaryImage);
props = regionprops(labeledImage, 'BoundingBox');
bb = [props.BoundingBox];
allHeights = bb(4:4:end)