how to know the area of the overlapping rectangles?

As a start i have the coordinates x1,y1 and x2,y2 of a rectangle, on the other hand i have a list of other coordinates for other rectangles.

What i want to do is compare the value of the one i already have over an image to the other ones and see if any overlap with it, and in case any do i want to check if the overlap area is equal to 50% of the original rectangle, this is all just part of the work that came before and shall come after but it's been difficult for me to work on even tho i checked numerous resources like https://codereview.stackexchange.com/... https://codereview.stackexchange.com/..., any guidance do fulfill the described issue would be helpful.

edit retag close merge delete

Sort by ยป oldest newest most voted

"The formula for intersection will be

SI= Max(0, Min(XA2, XB2) - Max(XA1, XB1)) * Max(0, Min(YA2, YB2) - Max(YA1, YB1))

then the union will be S=SA+SB-SI

And finally, the ratio will be SI / S."

found in this blog: https://stackoverflow.com/questions/9...

more