필터 지우기
필터 지우기

How to merge multiple bounding box into one?

조회 수: 34 (최근 30일)
Leonard Yeo
Leonard Yeo 2016년 1월 27일
댓글: Walter Roberson 2022년 11월 24일
How do I merge multiple bounding on the same object as one bounding box around the object? Below is an example. Thanks

답변 (3개)

Walter Roberson
Walter Roberson 2016년 1월 27일
편집: Image Analyst 2016년 1월 27일
Convert the [x y width height] coordinates to start and end coordinates,
[x y x+width-1 y+height-1]
Now take the minimum of all of the left x over all of the boxes to get the left bound, the maximum over all of the right x to get the right bound, the minimum over the top y to get the lower bound, the maximum over the bottom y to get the upper bound.

Nibir Sarker
Nibir Sarker 2018년 12월 13일
Please Provide me the full code for multiple bounding box converting into one bounding box.In the below figure i want to merge trash and human bounding box together then count the object and detect human and trash together.
sample.jpg
  댓글 수: 4
Mangaraju Palepu
Mangaraju Palepu 2021년 5월 24일
편집: Mangaraju Palepu 2021년 5월 24일
Regardless of merging bounding boxes. The text will be detected when used OCR. I see no text in your image. so it is obvious that function OCR detected no text.
anyways to merge two bounding boxes they should overlap first. Increase the size of bounding boxes, make them overlap and try to merge. change the valuse expansionAmount in your code.
By the way you totally copied the exaple code from matlab. And only use either regionprops or stoke width variation to remove non text region , the code you copied using both. only one method has to opt.
Walter Roberson
Walter Roberson 2021년 5월 25일
The images were posted by @Nibir Sarker and are probably not the same ones uses by @Saketh Nannaka .

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


kalpana k
kalpana k 2022년 11월 24일
편집: Walter Roberson 2022년 11월 24일
if you are having the binary image as "I7", follow the below code to merge all the regions into common bounding box as below
RegionAll=regionprops(I7,'BoundingBox');
BBall=[];
for jk=1:length(RegionAll)
Box1=RegionAll(jk).BoundingBox;
Box2=[Box1(1) Box1(2) Box1(1)+Box1(3)-1 Box1(2)+Box1(4)-1];
BBall=[BBall ;Box2];
end
mX=min(BBall(:,1));
mY=min(BBall(:,2));
mW=max(BBall(:,3))-mX;
mH=max(BBall(:,4))-mY;
NewBB=[mX mY mW mH];
  댓글 수: 1
Walter Roberson
Walter Roberson 2022년 11월 24일
No loop needed
RegionAll=regionprops(I7,'BoundingBox');
AllBoxes = vertcat(RegionAll.BoundingBox);
xy = [AllBoxes(:,1:2), AllBoxes(:,1:2) + AllBoxes(:,3:4));
startX = min(xy(:,1));
startY = min(xy(:,2));
endX = max(xy(:,3));
endY = max(xy(:,4));
BB = [startX, startY, endX - startX, endY - startY];

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

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by