How to find out overlapping region between bounding boxes?

Hi
Does anyone know if there's a way to find out whether there's an overlap between two bounding boxes drawn around individual connected components??
I need to remove the areas which do not have any overlap with other bounding boxes. which is the same as making the white pixels in those black... I need help with these steps.
Please guide! Any help is greatly appreciated, thanks a lot!

Answers (1)

overlappedPixels = binaryImage1 & binaryImage2; % Find overlap.
grayImage(overlappedPixels) = 0; % Set to zero.

5 Comments

Hey, thanks for the response! But i'm having problems comparing a whole set of bounding boxes with each other. Not sure how to keep track of what has overlap with another...
If max(overlappedPixels(:)) >= 1 then there is overlap. If it's zero, there was no overlap. Of course you could do a similar thing just by inspecting the corner locations.
Hey, I couldn't use your help because I have a different situation. I have am image which is split into its connected components. I have to compare the bounding boxes of each connected component with the bounding boxes of all the others.I'm not sure how to compare it with so many others and keep track of which boxes have no overlap with any other. Please help me out if possible, thank you very much!
Just do a double loop over all blobs, checking the x1,y1,x2,y2 coordinates of each of the two bounding boxes and see which bounding boxes intersect. It's just a dumb, brute force, intuitive and straightforward, easy approach but it will work, and it will work fast.
hi, thanks! i thought of that but am unable to find out how to access the coordinates of the bounding box...

Sign in to comment.

Asked:

on 10 Oct 2012

Community Treasure Hunt

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

Start Hunting!