MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / _iou

Function _iou

src/table.py:138–147  ·  view source on GitHub ↗

Compute intersection over union of two rectangles.

(r1, r2)

Source from the content-addressed store, hash-verified

136
137
138def _iou(r1, r2):
139 """Compute intersection over union of two rectangles."""
140 ix = max(0, min(r1[2], r2[2]) - max(r1[0], r2[0]))
141 iy = max(0, min(r1[3], r2[3]) - max(r1[1], r2[1]))
142 intersection = ix * iy # intersection area
143 if not intersection:
144 return 0
145 area1 = (r1[2] - r1[0]) * (r1[3] - r1[1])
146 area2 = (r2[2] - r2[0]) * (r2[3] - r2[1])
147 return intersection / (area1 + area2 - intersection)
148
149
150def intersects_words_h(bbox, y, word_rects) -> bool:

Callers 1

find_tablesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…