preprocessed images

This commit is contained in:
Mikkeli Matlock
2026-02-15 22:23:28 +09:00
parent b51e1faf8d
commit 29db4ec019
3 changed files with 2 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View File

@@ -10,7 +10,7 @@ log = logging.getLogger(__name__)
IMG_DIR = Path(__file__).parent / "assets" / "img" IMG_DIR = Path(__file__).parent / "assets" / "img"
STATUS_IMG_SIZE = 120 STATUS_IMG_SIZE = 120
MONOCHROME_THRESHOLD = 120 MONOCHROME_THRESHOLD = 140
def load_status_image(path: Path) -> bytes: def load_status_image(path: Path) -> bytes:
@@ -37,7 +37,7 @@ def load_status_image(path: Path) -> bytes:
y_off = (STATUS_IMG_SIZE - img.height) // 2 y_off = (STATUS_IMG_SIZE - img.height) // 2
canvas.paste(img, (x_off, y_off)) canvas.paste(img, (x_off, y_off))
# Threshold to 1-bit: black (< 128) -> 1, white -> 0 # Threshold to 1-bit: black (< MONOCHROME_THRESHOLD) -> 1, white -> 0
bw = canvas.point(lambda p: 1 if p < MONOCHROME_THRESHOLD else 0, "1") bw = canvas.point(lambda p: 1 if p < MONOCHROME_THRESHOLD else 0, "1")
raw = bw.tobytes() raw = bw.tobytes()
log.info("Status image loaded: %s -> %d bytes", path.name, len(raw)) log.info("Status image loaded: %s -> %d bytes", path.name, len(raw))