This commit is contained in:
2ManyProjects 2026-01-10 00:29:31 -06:00
parent a7215e496f
commit 4a326e0c9f

View file

@ -184,15 +184,26 @@ class StitchingScanner:
result[:, w_strip:] = base result[:, w_strip:] = base
result[y_offset:y_offset + h_strip, :w_strip] = strip result[y_offset:y_offset + h_strip, :w_strip] = strip
return result return result
if append_right: if append_right:
result_width = w_base + w_strip - blend_w result_width = w_base + w_strip - blend_w
result = np.zeros((h_base, result_width, 3), dtype=np.uint8) result = np.zeros((h_base, result_width, 3), dtype=np.uint8)
self.log(f"=== _blend_horizontal_at_y (append_right) ===")
self.log(f" base: {w_base}x{h_base}, strip: {w_strip}x{h_strip}")
self.log(f" y_offset: {y_offset}, blend_w: {blend_w}")
self.log(f" result: {result_width}x{h_base}")
# Step 1: Copy entire base # Step 1: Copy entire base
self.log(f" Step 1: Copy base to result[:, :w_base] -> [:, :{w_base}]")
result[:, :w_base] = base result[:, :w_base] = base
# Step 2: Copy non-overlap portion of strip at correct Y # Step 2: Copy non-overlap portion of strip at correct Y
x_start = w_base
x_end = result_width
y_start = y_offset
y_end = y_offset + h_strip
self.log(f" Step 2: Place strip at X={x_start}:{x_end}, Y={y_start}:{y_end}")
self.log(f" Strip source: [:, {blend_w}:] -> {w_strip - blend_w} cols")
result[y_offset:y_offset + h_strip, w_base:] = strip[:, blend_w:] result[y_offset:y_offset + h_strip, w_base:] = strip[:, blend_w:]
# Step 3: Create blend # Step 3: Create blend
@ -202,18 +213,34 @@ class StitchingScanner:
blended = (base_overlap * alpha + strip_overlap * (1 - alpha)).astype(np.uint8) blended = (base_overlap * alpha + strip_overlap * (1 - alpha)).astype(np.uint8)
# Step 4: Place blend (overwrites part of base at correct Y) # Step 4: Place blend (overwrites part of base at correct Y)
blend_x_start = w_base - blend_w
blend_x_end = w_base
self.log(f" Step 4: Blend zone at X={blend_x_start}:{blend_x_end}, Y={y_start}:{y_end}")
result[y_offset:y_offset + h_strip, w_base - blend_w:w_base] = blended result[y_offset:y_offset + h_strip, w_base - blend_w:w_base] = blended
self.log(f" Final: Strip placed at X={w_base - blend_w}, Y={y_offset}")
return result return result
else: # append_left else: # append_left
result_width = w_base + w_strip - blend_w result_width = w_base + w_strip - blend_w
result = np.zeros((h_base, result_width, 3), dtype=np.uint8) result = np.zeros((h_base, result_width, 3), dtype=np.uint8)
self.log(f"=== _blend_horizontal_at_y (append_left) ===")
self.log(f" base: {w_base}x{h_base}, strip: {w_strip}x{h_strip}")
self.log(f" y_offset: {y_offset}, blend_w: {blend_w}")
self.log(f" result: {result_width}x{h_base}")
# Step 1: Copy ENTIRE base shifted right # Step 1: Copy ENTIRE base shifted right
base_x_start = w_strip - blend_w
self.log(f" Step 1: Copy base to result[:, {base_x_start}:] (shifted right)")
result[:, w_strip - blend_w:] = base result[:, w_strip - blend_w:] = base
# Step 2: Copy non-overlap portion of strip at correct Y # Step 2: Copy non-overlap portion of strip at correct Y
strip_x_end = w_strip - blend_w
y_start = y_offset
y_end = y_offset + h_strip
self.log(f" Step 2: Place strip at X=0:{strip_x_end}, Y={y_start}:{y_end}")
self.log(f" Strip source: [:, :{strip_x_end}] -> {strip_x_end} cols")
result[y_offset:y_offset + h_strip, :w_strip - blend_w] = strip[:, :w_strip - blend_w] result[y_offset:y_offset + h_strip, :w_strip - blend_w] = strip[:, :w_strip - blend_w]
# Step 3: Create blend # Step 3: Create blend
@ -223,8 +250,12 @@ class StitchingScanner:
blended = (strip_overlap * (1 - alpha) + base_overlap * alpha).astype(np.uint8) blended = (strip_overlap * (1 - alpha) + base_overlap * alpha).astype(np.uint8)
# Step 4: Place blend at correct Y # Step 4: Place blend at correct Y
blend_x_start = w_strip - blend_w
blend_x_end = w_strip
self.log(f" Step 4: Blend zone at X={blend_x_start}:{blend_x_end}, Y={y_start}:{y_end}")
result[y_offset:y_offset + h_strip, w_strip - blend_w:w_strip] = blended result[y_offset:y_offset + h_strip, w_strip - blend_w:w_strip] = blended
self.log(f" Final: Strip placed at X=0, Y={y_offset} (base shifted right by {base_x_start})")
return result return result
def _blend_horizontal(self, base: np.ndarray, strip: np.ndarray, def _blend_horizontal(self, base: np.ndarray, strip: np.ndarray,