필터 지우기
필터 지우기

merge binary regions to get a bigger object

조회 수: 1 (최근 30일)
Elysi Cochin
Elysi Cochin 2016년 9월 30일
댓글: Elysi Cochin 2016년 10월 6일
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....

채택된 답변

Image Analyst
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);
  댓글 수: 1
Elysi Cochin
Elysi Cochin 2016년 10월 6일
thank you sir.... that was want i wanted...

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by