how to find the biggest horizontal length in a rectangular window
2 views (last 30 days)
Show older comments
Elysi Cochin
on 17 Jan 2015
Commented: Elysi Cochin
on 20 Jan 2015
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...
0 Comments
Accepted Answer
Image Analyst
on 17 Jan 2015
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
Image Analyst
on 19 Jan 2015
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.
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!