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

6 次查看(过去 30 天)
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

采纳的回答

Image Analyst
Image Analyst 2020-5-31
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.

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by