![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/175146/image.png)
merge binary regions to get a bigger object
1 回表示 (過去 30 日間)
古いコメントを表示
when i do segmentation i get bboxes such as
bboxes =
85 76 75 79
90 79 55 78
57 168 48 19
91 92 38 67
how can i merge all the regions of the bounding box to one single object.... i want all the regions in one bounding box....
0 件のコメント
採用された回答
Image Analyst
2016 年 9 月 30 日
Try this
bboxes = [...
85 76 75 79
90 79 55 78
57 168 48 19
91 92 38 67]
allx1 = bboxes(:, 1)
ally1 = bboxes(:, 2)
allx2 = allx1 + bboxes(:, 3)
ally2 = ally1 + bboxes(:, 4)
maxWidth = max(allx2) - min(allx1)
maxHeight = max(ally2) - min(ally1)
overallBBox = [min(allx1), min(ally1), maxWidth, maxHeight]
% Display every individual box.
for k = 1 : size(bboxes, 1)
rectangle('Position', bboxes(k, :), 'EdgeColor', 'k', 'LineWidth', 5);
hold on;
end
% Display the overall box.
rectangle('Position', overallBBox, 'EdgeColor', 'r', 'LineWidth', 3);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/175146/image.png)
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!