how to check if (x,y) coordinates fall within another (x,y) coordinate

5 views (last 30 days)
i have the x,y,w,h --> [x position, y position ,width and height] of the two black boxes and the red boxes inside the black boxes (5 in one box and 3 in the other)
say i have the (x,y,w,h) of black boxes in matrix named black_boundingbox (dimension = 2x4) and
that of red in matrix named red_boundingbox (8x4)
based on a condition, only one blackbox gets selected
eg, if box 1 is selected based on my condition, i want to get all the coordinates of the 5 red boxes
how can i select only the 5 red boxes in black box 1, how can i check it based on coordinates because some of the red boxes are outside the black box, but i need those also, how can i do that

Accepted Answer

Image Analyst
Image Analyst on 31 May 2020
Are you sure you want to do this via bounding boxes instead of imreconstruct()?
The easiest way might be to just turn them into digital images, label the red mask, AND the black mask and red labeled images, and use unique() to find out what labels of red are inside the black.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!