Skip to main content

Image Registration with Fourier Mellin using OpenCV

Project description

Fourier-Mellin Python Library using OpenCV

This repository implements the Fourier-Mellin transform for image registration and video stabilization using semilog polar coordinates with OpenCV. The implementation is written in C++, but python bindings are provided. For information about the pipeline, see this article. Tested on Ubuntu 20.04.

Disclaimer

This repository is an unstable release and not intended for production. Many other repositories have implemented the Fourier-Mellin transform, for example imreg_fmt by sthoduka or fourier-mellin by polakluk.

Note that the image registration only works effectively for Eucledian/similar transformations without affine or perspective distortions.

Video Stabilization

https://github.com/brht0/fourier-mellin/assets/90235713/c5524042-6bc6-46b5-837e-adb62ddcf9b1

Original video can be found on Youtube (No affiliation)

Image Registration

lena_transform_demo

Image registration with a transformed image, overlayed.

Installation with git clone

It is recommended to use a python virtual environment. The repository will be added to PyPI in time.

# inside your own project
python3 -m venv .venv
source .venv/bin/activate
pip install git+https://github.com/brht0/fourier-mellin

Examples

Many examples, such as video stabilization, are included inside the examples/ subdirectory. The following example registers two images.

import cv2
import numpy as np
import fourier_mellin

reference = cv2.imread('lenna.png')
transformed = cv2.imread('lenna_transformed.png')

rows, cols = reference.shape[:2]
fm = fourier_mellin.FourierMellin(cols, rows)

transformed_reference, transform = fm.register_image(reference, transformed)
overlay = cv2.addWeighted(transformed, 0.5, transformed_reference, 0.5, 0.0, dtype=cv2.CV_32F)

cv2.imwrite("overlay.jpg", overlay)
cv2.imwrite("transformed.jpg", transformed)

Building without pip

Building without pip is not required for use with python. Building without pip requires installing additional dependencies, such as pybind11. This step may be skipped, in case only python bindings are used.

cmake -B build/release -S . -DCMAKE_BUILD_TYPE=Release
cmake --build build/release -j 8

Todo

  • Register images directly from files
  • Benchmarking
  • Optimization
  • CUDA with OpenCV
  • remove filters, as cv::phaseCorrelate already applies Hanning Window
  • Documentation
  • Proper threading support
  • angles beyond -90 to 90 deg
  • updated readme with up to date information
  • pure python version that for windows/macos
  • memory problem when passing in reference to some functions, where image is replaced (clearer documentation?)
  • link time optimizer flto

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fourier_mellin-0.2.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fourier_mellin-0.2.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (32.3 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

fourier_mellin-0.2.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (32.3 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

fourier_mellin-0.2.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (32.3 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

fourier_mellin-0.2.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (32.3 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

fourier_mellin-0.2.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (32.3 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

fourier_mellin-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (32.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

fourier_mellin-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (32.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

fourier_mellin-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (32.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

fourier_mellin-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (32.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

fourier_mellin-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (32.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

fourier_mellin-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (32.3 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

fourier_mellin-0.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (32.3 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

File details

Details for the file fourier_mellin-0.2.0.tar.gz.

File metadata

  • Download URL: fourier_mellin-0.2.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for fourier_mellin-0.2.0.tar.gz
Algorithm Hash digest
SHA256 104e2829c7f4c6499493913b13bf23d9e839826ae7e211eb6334fae308619d0b
MD5 4b99be242b907b6cf53963d1b88d986c
BLAKE2b-256 fa538b0a1801b4823d4ecb705cd2f660023b26884ddd0190b65aeb260e604155

See more details on using hashes here.

File details

Details for the file fourier_mellin-0.2.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fourier_mellin-0.2.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 33899a759bc860d97c7803d76758cca9c6516b99fb2990700cf8ec4bf6b3ac8d
MD5 a3287a614197566cf4179644a90b64de
BLAKE2b-256 2bcb63e0b660fea1665a383e47039c3c34a71efd6b50a329cd7c55ced421072d

See more details on using hashes here.

File details

Details for the file fourier_mellin-0.2.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fourier_mellin-0.2.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3bbd44574d26a0484991dfd6f741166241621b55d4438241efb5115f1316b6d5
MD5 c02a513dc77de9ac8386b82a0e54fb0e
BLAKE2b-256 b74f31910fa058de7254d5f469c7d4345892a6b45ac5076bf99a6e68721a480e

See more details on using hashes here.

File details

Details for the file fourier_mellin-0.2.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fourier_mellin-0.2.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a6ae523e82c9cebda020c10829763a3126e91e341e679b8b1e9cdcbf9c32acf5
MD5 23e67bf88a0f7df852d7e5a64e011764
BLAKE2b-256 acfd4dfeb17ac3830011586b4ee372b472f59111048c447685a2735ffe959e91

See more details on using hashes here.

File details

Details for the file fourier_mellin-0.2.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fourier_mellin-0.2.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fc73bee6eeb0bd89d899c669b93a73ac9cf2f5cc021c542ff53e35f8de7ac8b8
MD5 9fcdd96d1cad5fa93a7c3cfc36c11e83
BLAKE2b-256 c6ee76ca7d215cf3fbcfe54d5cf7391a2d477fb2469fc7003e8b0c7d425e378d

See more details on using hashes here.

File details

Details for the file fourier_mellin-0.2.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fourier_mellin-0.2.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 85ff99b63c8117dadda760d802190508c8526d7a69e0626e7076d69145549755
MD5 803f03feefc5cbfc9d6a523f47abbda8
BLAKE2b-256 d1976f8ac0aed8690cd6f8f2f05b1f1d97058d4e5e8e33e98434ea43801d0543

See more details on using hashes here.

File details

Details for the file fourier_mellin-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fourier_mellin-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ce6ba940b42fab51af4fa996de22a029950063c888f48855196d2eb5eb75852f
MD5 4eda9d5268dc33aa3adeb9ee92faa0df
BLAKE2b-256 97afe9353248448a65143f3a9283dd6c9d1c21c498b2913b98e37f0bc108a63a

See more details on using hashes here.

File details

Details for the file fourier_mellin-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fourier_mellin-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 518a283dbe8b8db606d27462892551b1b07922a5512b9a5e436dc8a78657471d
MD5 deddeed2f852c1bf5b29f3c9d7b7aaba
BLAKE2b-256 57b8af31ab3fb9a54850c52260b988fabf3a13ec492c3b9e78a0a5946bef3953

See more details on using hashes here.

File details

Details for the file fourier_mellin-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fourier_mellin-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f5e0bd2c0fe994cd608a7a58f09fecbcd4c1155948f235b321d5c305a8e7c671
MD5 232a798ec69b19379044db64dd900aec
BLAKE2b-256 97aee3284b746336d9eb929ba27c671a6f6862d616e648111b83d5c765be8d28

See more details on using hashes here.

File details

Details for the file fourier_mellin-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fourier_mellin-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 66b0b589a694e3f5e7c102d68c21e00a751c42aa27aa7fdee498a9dde61b0b72
MD5 e3a4e47779861d4e49dc8fd01b3bd27b
BLAKE2b-256 19360307abd5ff7f56641047f8332b4797527e3d39bc699182283c06094d67bd

See more details on using hashes here.

File details

Details for the file fourier_mellin-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fourier_mellin-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 16bbeebb3674979147d0cdabeb3d065e45a0d68a3726c40752e9831afa85ecbe
MD5 aa479a5ae01f83e0c1055f1f8028db7f
BLAKE2b-256 bbbb72a7aebc24e62facbdb50347391d0981d492374bbe40dedb3ec621f4af7b

See more details on using hashes here.

File details

Details for the file fourier_mellin-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fourier_mellin-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 74b7bedde15c5010175181338a123e3e573ca6a312d92ed5ba24c784e2234613
MD5 4167328751f7c70262fdcb29d02819d6
BLAKE2b-256 47de42394eb1cd4c496986d79b29c6530b6319ccad9e83b1f4bfe06e6c15ea78

See more details on using hashes here.

File details

Details for the file fourier_mellin-0.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fourier_mellin-0.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 afc58a06cb179f028db36e2398dde1a594bdd048244c1cf62a828b021c0b61ee
MD5 e317c5ddf11020234e69ba06d9bf2c39
BLAKE2b-256 2f17130d0959e9d091f123f0a52e5b21b4e4e036e9754329dfd8fa0a7d300604

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page