Azzera filtri
Azzera filtri

How to merge overlapping rectangles ?

12 visualizzazioni (ultimi 30 giorni)
RAJESHWAR R il 15 Mar 2021
Risposto: Shubham Rawat il 18 Mar 2021
I have used BWLABEL and BOUNDINGBOX command to get the following image.
Here we can see in the right corner two rectangles are overlapping and as we can see the bigger rectangle completely encloses the smaller one. How can I remove the smaller one and keep the big rectangle alone? Also I don't want any rectangles over lapping.
Any help would be appreciated.

Risposte (1)

Shubham Rawat
Shubham Rawat il 18 Mar 2021
Hi Rajeshwar,
There is no as such function which can remove inscribed rectancles.
But you may write a similar code like this in which i want to return that rectangle which has larger area.
A = [1 2 5 6]; %Rectangle A
B = [1 2 3 4]; %Rectangle B
%Rectangle B is completely inscribed in Rectangle A
area = rectint(A, B); %returning area inscribed
if ~area %if area is not zero
return max(A, B); %return maximum area rectangle
rectangle('Position', max(A,B)); %plotting maximum area rectangle
axis([0 10 0 10]);
You may look at these documentations for further help:
Hope this Helps!


Scopri di più su Images in Help Center e File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by