27 lines
686 B
Python
27 lines
686 B
Python
|
|
|
||
|
|
import cv2
|
||
|
|
import numpy as np
|
||
|
|
import os
|
||
|
|
|
||
|
|
def viz_unwarp():
|
||
|
|
img_path = "seal_cropped.png"
|
||
|
|
img = cv2.imread(img_path)
|
||
|
|
if img is None:
|
||
|
|
print("Image not found")
|
||
|
|
return
|
||
|
|
|
||
|
|
h, w = img.shape[:2]
|
||
|
|
cx, cy = w//2, h//2
|
||
|
|
radius = min(cx, cy)
|
||
|
|
|
||
|
|
# Try different factors
|
||
|
|
for factor in [1.0, 2.0, 3.0, 4.0]:
|
||
|
|
out_w = int(radius * 2 * np.pi * factor)
|
||
|
|
out_h = radius
|
||
|
|
unwarped = cv2.warpPolar(img, (out_w, out_h), (cx, cy), radius, cv2.WARP_POLAR_LINEAR)
|
||
|
|
cv2.imwrite(f"debug_viz_f{factor}.png", unwarped)
|
||
|
|
print(f"Saved debug_viz_f{factor}.png shape={unwarped.shape}")
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
viz_unwarp()
|