acupedia-ops/tests/data/image/test_clean_image_borders.py

12 lines
624 B
Python

from pathlib import Path
import cv2
import numpy as np
from acupedia_ops.data.image.clean_image_borders import clean_image
def test_clean_image_preserves_dimensions(tmp_path: Path) -> None:
source=tmp_path/"source.png"; target=tmp_path/"target.png"
image=np.full((200,300,3),255,dtype=np.uint8); image[:,0:3]=190; image[0:3,:]=190; image[:,297:300]=190
cv2.circle(image,(150,100),30,(0,0,0),3); assert cv2.imwrite(str(source),image)
assert clean_image(source,target)
cleaned=cv2.imread(str(target)); assert cleaned is not None; assert cleaned.shape==image.shape; assert int(cleaned[100,120].mean())<100