how to find the biggest horizontal length in a rectangular window
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Image Analyst
2015년 1월 17일
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
Image Analyst
2015년 1월 19일
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.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!