Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i detect overlapping ROIs?

Solved!
Go to solution

Good day,
in my application i set a certain number of ROIs in specific regions defined programmatically. Unfortunately they could overlap each other. Since that the ROIs that i set are regions of analysis overlapping two ROIs means analyze the same region two time. So i need to delete one of the two overlapping ROIs. I can't figure out how i can detect the overlapping ROIs. Note that the ROIs may not completely overlap but they could overlap each other only in undefined percentage.

 

Thank you in advance,

 

Francesco

0 Kudos
Message 1 of 4
(3,882 Views)

What shape are the ROIs?  Rectangles would be fairly easy to check for overlap, but random shapes would be more difficult.

 

You could check rectangles by generating a list of left, right, top, bottom coordinates.  For each rectangle, check if its left or right is between any other left/right pairs AND top or bottom is between the top/bottom of the same ROI.

 

For random shapes, I might consider converting each ROI to a mask, then adding all the masks together.  If any pixels have a value greater than 1, you have overlap.  You would have to use each mask to figure out which one it is.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 4
(3,877 Views)
Solution
Accepted by topic author FM82

What shape are the ROIs?  Rectangles would be fairly easy to check for overlap, but random shapes would be more difficult.

 

You could check rectangles by generating a list of left, right, top, bottom coordinates.  For each rectangle, check if its left or right is between any other left/right pairs AND top or bottom is between the top/bottom of the same ROI.

 

For random shapes, I might consider converting each ROI to a mask, then adding all the masks together.  If any pixels have a value greater than 1, you have overlap.  You would have to use each mask to figure out which one it is.

 

Bruce

Bruce Ammons
Ammons Engineering
Message 3 of 4
(3,876 Views)

Thank you, Bruce. Your second advice hit the spot.

 

Francesco

0 Kudos
Message 4 of 4
(3,853 Views)