how to find the biggest horizontal length in a rectangular window

how to find the biggest horizontal length of the individual contours which are present inside the rectangular window...
i have binarized the image and selected a rectangular portion, now in need to compute the biggest horizontal length inside the rectangular window....
please do reply...

 Accepted Answer

Simply binarize your lines by thresholding,
binaryImage = grayImage < 128;
then call bwlabel,
labeledImage = bwlabel(binaryImage);
then call
stats = regionprops(labeledImage, 'BoundingBox')
then extract all the bounding boxes
allBB = [stats.BoundingBox];
Then look for the blob number with the largest 3rd index of allBB - use the max() function and both output arguments. I know from your other questions that you already know how to do all these steps so let me know if you have problems.

2 Comments

No. You have to extract the widths from the bounding box array. The width is the third element of each BB which means it shows up in elements 3, 7, 11, etc. of the concatenated array of all the BBs. I believe (just off the top of my head) that you do this:
widths = allBB(3:4:end);
Then sort that and find the index of the blob with the widest width
[maxWidth, indexOfWidestBlob] = max(widths);
No need for any for loop. Attach your original image without all that annotation if you want any more help.
thank you sir... i understood...

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!