[refactor] SubImage → SubImageExtract, add SubImageCombine

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-02 08:20:38 +02:00
co-authored by Claude Sonnet 4.6
parent 2da2262368
commit a07698497d
5 changed files with 46 additions and 30 deletions
+4 -4
View File
@@ -5,7 +5,7 @@ import matplotlib.pyplot as plt
from rbm.model import Model
from rbm.entity import Entity, EntityParams, TrainingParams
from image.sub_image import SubImage, normalize
from image.sub_image import SubImageExtract, normalize
from rbm.matrix import Mat, np, convert
from rbm.status import CheckpointStatus
@@ -38,7 +38,7 @@ class TestModel(Model):
def pad_to_stride(img: numpy.ndarray) -> numpy.ndarray:
"""Pad so (H - PATCH) and (W - PATCH) are divisible by STRIDE (required by SubImage.check)."""
"""Pad so (H - PATCH) and (W - PATCH) are divisible by STRIDE (required by SubImageExtract.check)."""
h, w = img.shape[:2]
ph = (-h) % STRIDE if h >= PATCH else PATCH - h
pw = (-w) % STRIDE if w >= PATCH else PATCH - w
@@ -86,8 +86,8 @@ def load_patches(data_dir: str, n_images: int = N_IMAGES, start: int = 0):
def load_image_patches(path: str):
"""Extract normalised patches from a single image via SubImage; return (patches, nx_steps, ny_steps)."""
sub = SubImage(PATCH, PATCH, STRIDE, STRIDE)
"""Extract normalised patches from a single image via SubImageExtract; return (patches, nx_steps, ny_steps)."""
sub = SubImageExtract(PATCH, PATCH, STRIDE, STRIDE)
img = cv2.imread(path)
img = pad_to_stride(img)
h, w = img.shape[:2]