Foureg
Image registration using discrete Fourier transform.
Given two images, foureg calculates a similarity transformation that
transforms one image into the other.
Example
The example transforms an image with a user defined transformation and then rediscovers
it using foureg.
import matplotlib.pyplot as plt
import numpy as np
import torch
from PIL import Image
from foureg import (Constraints, frame_img, similarity, similarity_matrix,
transform_img)
# Generate the test images
transformation = similarity_matrix(0.8, -10, (60, 20))
master = np.asarray(Image.open("./resources/examples/sample1.png"))
master = torch.from_numpy(master.copy()).type(torch.float32)
slave = transform_img(master, transformation, invert=True)
# Define some constraints and coregister
constraints = Constraints(angle=(-10, 5), scale=(0.8, 0.2), tx=(60, 3), ty=(20, 1))
imreg_result = similarity(
master, slave, constraints=constraints, numiter=5, filter_pcorr=5
)
# Transform the slave image
slave_transformed = transform_img(slave, imreg_result.transformation, invert=False)
_, axs = plt.subplots(1, 4, figsize=(13, 8))
im_0 = axs[0].imshow(master)
plt.colorbar(im_0, ax=axs[0])
im_1 = axs[1].imshow(slave)
plt.colorbar(im_1, ax=axs[1])
im_2 = axs[2].imshow(slave_transformed)
plt.colorbar(im_2, ax=axs[2])
im_3 = axs[3].imshow(np.abs(slave_transformed - master))
plt.colorbar(im_3, ax=axs[3])
plt.show()
Features
- Image pre-processing options (frequency filtration, image extension).
- Under-the-hood options exposed (iterations, phase correlation filtration).
- Permissive open-source license (3-clause BSD).
- GPU accelerated
Origin story
This is a fork of the imreg_dft borned of the desire to achieve the following goals:
- Ability to return the final transformation in matrix form as opposed to the angle, translation and scaling factor separately. The original code makes obtaining that matrix really hard because it does it performs using scipy in away that each transformation resizes the image.
- Better performance powered by pytorch
- A more focused codebase. The only goal here is to estimate similarity transformations between pairs of images.
Acknowledgements
The code was originally developed by Christoph Gohlke (University of California, Irvine, USA) and later on developed further by Matěj Týč (Brno University of Technology, CZ). This repo wouldn't exist without them.
Metadata
Release files for foureg 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| foureg-1.0.0.tar.gz | 16.0 kB | Without provenance | Details for foureg-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| foureg-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for foureg-1.0.0-py3-none-any.whl |
Total release size: 34.2 kB
Release files / foureg-1.0.0.tar.gz
| Download URL | foureg-1.0.0.tar.gz |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5fb3b2af173c7c946471d05208d0f4998d3300e4e45af0d536297b7b97f06bd4
|
|
BLAKE2b-256 checksum How to use checksums |
6247d88dd8911468a296e1b4c45b6247dbd2e41ce9e5d496819d25184e7126e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.11.9 Darwin/22.6.0
|
Release files / foureg-1.0.0-py3-none-any.whl
| Download URL | foureg-1.0.0-py3-none-any.whl |
|---|---|
| Size | 18.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5efd7bbf97fa65fe4daaf9a24973245f395b00584ac0a15cebb735362f819991
|
|
BLAKE2b-256 checksum How to use checksums |
d94a4ad3e72f015d658b0264e0ac291c18d06487b362b9a974b85b76a8684261
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.11.9 Darwin/22.6.0
|
Security for foureg 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.