Bounding Box with constraints
조회 수: 4 (최근 30일)
이전 댓글 표시
Need some urgent help!
I've drawn a BoundingBox over a binary image. Now, I want to draw separate BoundingBoxes for the white pixeled regions above and below a blue horizontal line, which I've plotted on the image. If not BoundingBox, please advise on other options.
Thanks
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/157893/image.jpeg)
답변 (1개)
Image Analyst
2014년 3월 4일
Not sure where the confusion lies - seems really straightforward. I assume you have 2 x columns: x1 and x2. And you have 3 y rows: y1 (top), y2 (middle) and y3 (bottom). So the total bounding box is
% Upper Bounding box
bb1x = [x1 x2 x2 x1 x1];
bb1y = [y1 y1 y2 y2 y1];
% Lower bounding box
bb2x = bb1x;
bb2y = [y2 y2 y3 y3 y2];
% Outer, overall bounding box
bb3x = bb1x;
bb3y = [y1 y1 y3 y3 y1];
Now you can plot any of them
plot(bb1x, bb1y, 'r-', 'LineWidth', 3);
% or
plot(bb2x, bb2y, 'b-', 'LineWidth', 3);
% or
plot(bb3x, bb3y, 'g-', 'LineWidth', 3);
Isn't this what you were thinking of? If not, why not? Maybe I oversimplified what you were after.
댓글 수: 4
Image Analyst
2014년 3월 4일
Uh, not really. Except that you don't want just 2 or 3 boxes but lots and lots of them. Of course there are numerous ways to divide the whole thing up into a variety of sub-boxes. But maybe someone else will explain it also.
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!