Skip to content

Latest commit

 

History

History

ImageAlignment

README.md

Companion code for Image Alignment with ECC in OpenCV: C++ and Python.

Offset architectural images converging through ECC registration

Download Code

What these examples do

  • image_alignment_simple_example.py/.cpp aligns a moving image to a template and reports the ECC correlation, warp matrix, and before/after error.
  • image_alignment.py/.cpp reconstructs a color image from vertically stacked monochrome plates by aligning the blue and green channels to red.

Both paths support translation, Euclidean, affine, and homography motion models.

Requirements

  • Python 3.10+ with NumPy and OpenCV 4.10+ or OpenCV 5.x
  • CMake 3.16+ and a C++17 compiler for the C++ examples

Run the Python examples

python -m pip install -r requirements.txt
python image_alignment_simple_example.py --no-display --validate
python image_alignment.py --no-display --validate

Outputs are written to output/.

Build and run the C++ examples

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel
./build/image_alignment_simple --no-display --validate
./build/image_alignment --no-display --validate

Use --help to see the input, motion-model, convergence, output, display, and validation options.

Compatibility

The update removes Python 2 syntax, fixes the missing C++ sample-image path, initializes each channel warp independently, and adds robust size handling plus saved outputs. Both Python and C++ paths are tested with OpenCV 4.x and OpenCV 5.0.

Files

ImageAlignment/
├── CMakeLists.txt
├── ecc_utils.py
├── image_alignment.cpp
├── image_alignment.py
├── image_alignment_simple_example.cpp
├── image_alignment_simple_example.py
├── images/
├── requirements.txt
├── test_ecc.py
└── readme-images/

BigVision.AI

Build Production-Ready Computer Vision & AI Solutions

LearnOpenCV is maintained by BigVision.AI, a computer vision and AI consulting company. We help organizations design, build, optimize, and deploy production-ready AI solutions. Our team has deep expertise in computer vision, deep learning, multimodal AI, and edge deployment, with experience solving complex technical challenges across industries.

Have a project in mind? Talk with our expert AI solution builders.

Get in Touch with BigVision.AI