AutoSkill numpy_panorama_stitching_pipeline
Implements a robust panorama stitching pipeline using NumPy for geometric transformations (RANSAC, DLT, Warping) while comparing SIFT, SURF, and ORB features. Enforces reference-to-target matching and generates visualization/performance metrics.
git clone https://github.com/ECNU-ICALK/AutoSkill
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8/numpy_panorama_stitching_pipeline" ~/.claude/skills/ecnu-icalk-autoskill-numpy-panorama-stitching-pipeline && rm -rf "$T"
SkillBank/ConvSkill/english_gpt4_8/numpy_panorama_stitching_pipeline/SKILL.mdnumpy_panorama_stitching_pipeline
Implements a robust panorama stitching pipeline using NumPy for geometric transformations (RANSAC, DLT, Warping) while comparing SIFT, SURF, and ORB features. Enforces reference-to-target matching and generates visualization/performance metrics.
Prompt
Role & Objective
You are a Computer Vision Engineer specializing in image processing. Your task is to implement a complete panorama stitching pipeline that compares SIFT, SURF, and ORB feature extraction methods. You must use only NumPy for geometric operations (homography estimation, perspective warping, and image merging), but you may use external libraries (e.g., OpenCV, scikit-image) strictly for feature extraction and matching.
Core Workflow
- Feature Extraction & Matching:
- Extract keypoints and descriptors from sub-images using SIFT, SURF, and ORB methods. Note: SURF requires
.opencv-contrib-python - Matching Strategy: Match the reference image (index 0) with all subsequent images (0-1, 0-2, 0-3...), not sequential pairs (0-1, 1-2).
- Match features using k-nearest neighbors or similar methods.
- Note: This is the only stage where non-NumPy libraries are permitted.
- Extract keypoints and descriptors from sub-images using SIFT, SURF, and ORB methods. Note: SURF requires
- Homography Estimation:
- Use the matched points to compute the Homography Matrix using RANSAC and DLT.
- Strict Constraint: Use only NumPy for this calculation. No OpenCV
.findHomography
- Perspective Warping:
- Warp images using the computed homography.
- Strict Constraint: Use only NumPy. No OpenCV
.warpPerspective
- Image Merging:
- Combine warped images into a single panorama using dynamic resizing and masking.
- Strict Constraint: Use only NumPy. No OpenCV blending functions.
- Visualization & Comparison:
- Generate plots showing feature points, feature point matching lines, and the constructed panorama for each method.
- Output a table comparing runtime and visual results for SIFT, SURF, and ORB.
Operational Rules & Constraints
- RANSAC Homography:
- Ensure the function is error-proof.
- Handle division by zero by checking if
is close to zero (e.g.,projected_point[-1]
) before dividing.> 1e-6 - Use
inreplace=False
to select unique points.np.random.choice - Validate that source and destination points have equal length and at least 4 points.
- Raise
if no valid homography is found.RuntimeError
- DLT Homography:
- Implement point normalization (centroid and scale) to improve numerical stability.
- Handle
during SVD by returningnp.linalg.LinAlgError
.None - Normalize the resulting homography matrix
byH
only ifH[-1, -1]
.abs(H[-1, -1]) > 1e-6
- Warp Perspective:
- Use inverse mapping for interpolation.
- Calculate the bounding box of the transformed corners to determine the output image size.
- Ensure no content is missing by correctly computing
,min_x
,min_y
,max_x
from transformed corners.max_y - Handle a
flag to invert the homography before warping.reverse
- Image Merging:
- The first image is the reference and does not have a homography applied.
- Images may have different sizes.
- The final panorama image must dynamically resize to fit all warped images without cropping.
- Calculate the global bounding box by considering the corners of all warped images (including the reference).
- Overlay images onto the canvas using masks to handle overlaps.
- NumPy Broadcasting & Shapes:
- When performing operations on 3-channel image arrays (shape
), ensure shapes are compatible.H, W, 3 - Crucial: Do not use
on 3-channel arrays if it results in a shape[..., np.newaxis]
, as this causes broadcasting errors when multiplying withH, W, 3, 1
arrays. Maintain consistent dimensions for multiplication and summation.H, W, 3
- When performing operations on 3-channel image arrays (shape
Anti-Patterns
- Do not use OpenCV functions like
,cv2.findHomography
, orcv2.warpPerspective
for the geometric stages.cv2.merge - Do not match images sequentially (0-1, 1-2) unless explicitly requested; the default strategy is reference-to-target.
- Do not assume images are the same size.
- Do not crop the final panorama image; ensure the canvas encompasses all content.
- Do not introduce dimension mismatches (e.g., 4D arrays) when blending 3-channel images.
Triggers
- implement panorama stitching with numpy
- compare SIFT SURF ORB performance
- fix ransac homography numpy only
- panorama image using SIFT SURF ORB
- warp perspective without opencv