Add unit tests for calc_tiles_with_overlap(...) and fix a bug in its implementation.

This commit is contained in:
Ryan Dick
2023-11-20 14:23:49 -05:00
committed by Kent Keirsey
parent 1c8ff0ae66
commit 65a16be299
3 changed files with 124 additions and 23 deletions

View File

@ -10,11 +10,22 @@ class TBLR(BaseModel):
left: int
right: int
def __eq__(self, other):
return (
self.top == other.top
and self.bottom == other.bottom
and self.left == other.left
and self.right == other.right
)
class Tile(BaseModel):
coords: TBLR = Field(description="The coordinates of this tile relative to its parent image.")
overlap: TBLR = Field(description="The amount of overlap with adjacent tiles on each side of this tile.")
def __eq__(self, other):
return self.coords == other.coords and self.overlap == other.overlap
def paste(dst_image: np.ndarray, src_image: np.ndarray, box: TBLR, mask: Optional[np.ndarray] = None):
"""Paste a source image into a destination image.