foureg


Namefoureg JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/GCBallesteros/foureg
SummaryFourier transform based image registration
upload_time2024-11-25 08:46:56
maintainerNone
docs_urlNone
authorGuillem Ballesteros
requires_python<3.12,>=3.8
licenseNone
keywords image registration image
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            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`.

```python
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](https://github.com/matejak/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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/GCBallesteros/foureg",
    "name": "foureg",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.12,>=3.8",
    "maintainer_email": null,
    "keywords": "image registration, image",
    "author": "Guillem Ballesteros",
    "author_email": "guillem@maxwellrules.com",
    "download_url": "https://files.pythonhosted.org/packages/62/47/d88dd8911468a296e1b4c45b6247dbd2e41ce9e5d496819d25184e7126e0/foureg-1.0.0.tar.gz",
    "platform": null,
    "description": "Foureg\n======\nImage registration using discrete Fourier transform.\n\n\nGiven two images, `foureg` calculates a similarity transformation that\ntransforms one image into the other.\n\nExample\n-------\nThe example transforms an image with a user defined transformation and then rediscovers\nit using `foureg`.\n\n```python\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport torch\nfrom PIL import Image\n\nfrom foureg import (Constraints, frame_img, similarity, similarity_matrix,\n                    transform_img)\n\n# Generate the test images\ntransformation = similarity_matrix(0.8, -10, (60, 20))\nmaster = np.asarray(Image.open(\"./resources/examples/sample1.png\"))\nmaster = torch.from_numpy(master.copy()).type(torch.float32)\n\nslave = transform_img(master, transformation, invert=True)\n\n# Define some constraints and coregister\nconstraints = Constraints(angle=(-10, 5), scale=(0.8, 0.2), tx=(60, 3), ty=(20, 1))\nimreg_result = similarity(\n    master, slave, constraints=constraints, numiter=5, filter_pcorr=5\n)\n\n# Transform the slave image\nslave_transformed = transform_img(slave, imreg_result.transformation, invert=False)\n\n_, axs = plt.subplots(1, 4, figsize=(13, 8))\nim_0 = axs[0].imshow(master)\nplt.colorbar(im_0, ax=axs[0])\nim_1 = axs[1].imshow(slave)\nplt.colorbar(im_1, ax=axs[1])\nim_2 = axs[2].imshow(slave_transformed)\nplt.colorbar(im_2, ax=axs[2])\nim_3 = axs[3].imshow(np.abs(slave_transformed - master))\nplt.colorbar(im_3, ax=axs[3])\n\nplt.show()\n```\n\nFeatures\n--------\n* Image pre-processing options (frequency filtration, image extension).\n* Under-the-hood options exposed (iterations, phase correlation filtration).\n* Permissive open-source license (3-clause BSD).\n* GPU accelerated\n\nOrigin story\n------------\nThis is a fork of the [imreg_dft](https://github.com/matejak/imreg_dft) borned of the\ndesire to achieve the following goals:\n- Ability to return the final transformation in matrix form as opposed to the angle,\ntranslation and scaling factor separately. The original code makes obtaining that\nmatrix really hard because it does it performs using scipy in  away that each transformation\nresizes the image.\n- Better performance powered by pytorch\n- A more focused codebase. The only goal here is to estimate similarity transformations\nbetween pairs of images.\n\n\nAcknowledgements\n----------------\nThe code was originally developed by Christoph Gohlke (University of California, Irvine, USA)\nand later on developed further by Mat\u011bj T\u00fd\u010d (Brno University of Technology, CZ). This\nrepo wouldn't exist without them.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Fourier transform based image registration",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/GCBallesteros/foureg",
        "Repository": "https://github.com/GCBallesteros/foureg"
    },
    "split_keywords": [
        "image registration",
        " image"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d94a4ad3e72f015d658b0264e0ac291c18d06487b362b9a974b85b76a8684261",
                "md5": "6fa10e5d5c5ceda5443143d09622a042",
                "sha256": "5efd7bbf97fa65fe4daaf9a24973245f395b00584ac0a15cebb735362f819991"
            },
            "downloads": -1,
            "filename": "foureg-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6fa10e5d5c5ceda5443143d09622a042",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.12,>=3.8",
            "size": 18246,
            "upload_time": "2024-11-25T08:46:54",
            "upload_time_iso_8601": "2024-11-25T08:46:54.951671Z",
            "url": "https://files.pythonhosted.org/packages/d9/4a/4ad3e72f015d658b0264e0ac291c18d06487b362b9a974b85b76a8684261/foureg-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6247d88dd8911468a296e1b4c45b6247dbd2e41ce9e5d496819d25184e7126e0",
                "md5": "69e3d8089dbd59d10cf51fe1a6151a5d",
                "sha256": "5fb3b2af173c7c946471d05208d0f4998d3300e4e45af0d536297b7b97f06bd4"
            },
            "downloads": -1,
            "filename": "foureg-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "69e3d8089dbd59d10cf51fe1a6151a5d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.12,>=3.8",
            "size": 15995,
            "upload_time": "2024-11-25T08:46:56",
            "upload_time_iso_8601": "2024-11-25T08:46:56.056193Z",
            "url": "https://files.pythonhosted.org/packages/62/47/d88dd8911468a296e1b4c45b6247dbd2e41ce9e5d496819d25184e7126e0/foureg-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-25 08:46:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "GCBallesteros",
    "github_project": "foureg",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "foureg"
}
        
Elapsed time: 0.81367s