A Python tool for aligning and cropping handheld photos using computer vision techniques. Open Align detects ORB features, estimates similarity transforms, warps images into a reference frame, and computes the common overlap crop to remove black borders from alignment.
Original images
Aligned images
- Feature Detection: Uses ORB (Oriented FAST and Rotated BRIEF) features for robust image matching
- Image Alignment: Automatically aligns multiple handheld photos to a reference image
- Smart Cropping: Removes black borders and computes optimal crop regions
- Python ≥ 3.9
- Git
# Clone the repository
git clone https://github.com/yourname/open-align.git
cd open-align
# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install in editable mode
pip install -e .The following packages are automatically installed:
opencv-python- Computer vision and image processingnumpy- Numerical computingtyper- CLI frameworkrich- Terminal formatting
python -m open_align align \
/path/to/image1.jpg \
/path/to/image2.jpg \
/path/to/image3.jpg \
--nfeatures 4000 \
--erode 200| Option | Description | Default |
|---|---|---|
-n, --nfeatures INTEGER |
Number of ORB features to detect | 4000 |
-e, --erode INTEGER |
Erosion size for overlap mask (pixels) | 4 |
-v, --version |
Show version and exit | - |
- Feature Detection: Detects ORB features in all input images
- Feature Matching: Matches features between each image and the reference
- Transform Estimation: Estimates similarity transforms for alignment
- Image Warping: Warps all images into the reference coordinate system
- Overlap Computation: Finds the common overlap region across all images
- Cropping: Applies erosion and crops to remove black borders
- Output: Saves aligned and cropped images
ref_matches_all.png- Keypoints detected on the reference image (the first one, for debugging)aligned_###.png- Warped images before cropping (optional, for debugging)aligned_cropped_###.jpg- Final aligned and cropped images
Contributions are welcome! Please feel free to submit a Pull Request.
MIT © 2025