Ask Your Question
-1

how to know the area of the overlapping rectangles?

asked 2018-01-27 10:15:47 -0600

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 flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-01-29 03:05:37 -0600

VxW gravatar image

"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...

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-01-27 10:15:47 -0600

Seen: 2,499 times

Last updated: Jan 29 '18