use*_*599 2 matlab plot image image-processing
我试图在所有重叠的较小边界框周围绘制一个外边界框.整个图像中可能存在许多这些区域.
例如

到目前为止,我有一个称为rects的矩形向量.
overlaps = rectint(rects, rects);
Run Code Online (Sandbox Code Playgroud)
我检查彼此重叠的地方,因为它将与自身进行比较,我删除对角线如下:
overlaps(logical(eye(size(overlaps)))) = 0;
Run Code Online (Sandbox Code Playgroud)
然后找到重叠的位置
[r,c] = find(overlaps > 0);
Run Code Online (Sandbox Code Playgroud)
但是,我不知道如何处理这个,因为它不是返回的方形矩阵中的简单双向映射,因为该区域中可能存在多个重叠.
关于我如何进行的任何建议将不胜感激.
谢谢
这里是一些随机矩形的示例:
% Generate fake data, 3 rects with format [x,y,w,h]:
rects=20+randi(60,3,4);
% plot the rects :
for n=1:size(rects,1)
rectangle('Position',rects(n,:));
end
% get min max
xmin=min(rects(:,1));
ymin=min(rects(:,2));
xmax=max(rects(:,1)+rects(:,3));
ymax=max(rects(:,2)+rects(:,4));
% define outer rect:
outer_rect=[xmin ymin xmax-xmin ymax-ymin];
hold on
rectangle('Position',outer_rect,'EdgeColor','r','LineStyle',':');
Run Code Online (Sandbox Code Playgroud)
