feat: refine boundary mapping to improve alignment of inner and outer source coordinates

This commit is contained in:
2026-09-15 19:40:40 +08:00
parent 4035f5c9e4
commit 94130ff38f
2 changed files with 14 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ def build_boundary_mapping(content_values, threshold, padding, target_shape=None
)
distance = padding * scale
signed = ndimage.distance_transform_edt(mask) - ndimage.distance_transform_edt(~mask)
signed = np.where(signed != 0.0, signed - 0.5 * np.sign(signed), 0.0)
inward_y = ndimage.sobel(signed, axis=0, mode="nearest")
inward_x = ndimage.sobel(signed, axis=1, mode="nearest")
length = np.hypot(inward_y, inward_x)