Intersecting and non-intersecting box regions
11 ビュー (過去 30 日間)
古いコメントを表示
Having a set of bounding box values [x y width height] , how can i find the number of bounding box that gets intersected and that do not gets intersected when plotted
From the above example, there are 5 intersecting boxes and 2 non-intersecting boxes
How can i do so with the attached bounding box values
0 件のコメント
採用された回答
Matt J
2021 年 7 月 10 日
編集済み: Matt J
2021 年 7 月 10 日
Using rectint(), you can straightforwardly obtain a binary mask A such that A(i,j)=1 if rectangle bbx(i,:) and bbx(j,:) intersect.
load bbx
A=rectint(bbx,bbx)>0
and therefore the number of rectangles that have an intersection another rectangle would be,
N=sum(tril(A,-1),'all')
6 件のコメント
その他の回答 (2 件)
Simon Chan
2021 年 7 月 10 日
If viusal inspection is allowed, then the number can be counted by plotting the boxes in a figure:
rawdata=load('bbx.mat');
figure
for k=1:length(rawdata.bbx)
rectangle('Position',rawdata.bbx(k,:))
end
4 件のコメント
Simon Chan
2021 年 7 月 10 日
Would you please run the following commands before the above script:
clear;
clc;
If the error happens again, would you please run the following:
size(A) % Check the dimension of Matrix A
size(B) % Check the dimension of Matrix B
KSSV
2021 年 7 月 10 日
Run a loop for each box and find the intersection points. Use this to get the intersection points.
If your output is empty, it means there is no intersection.
3 件のコメント
KSSV
2021 年 7 月 10 日
You have origin, length and width of bounding box. So you can get four vertices of the box. You need to use four coordinates for each bounding box to get the intersection points.
参考
カテゴリ
Help Center および File Exchange で Descriptive Statistics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!