Skip to main content

N-dimensional Poisson image editing implemented with Pytorch and NumPy

Project description

PIE-torch: Poisson Image Editing in Pytorch

Fast, n-dimensional Poisson image editing.

Open In Colab

2 implementations, including:

Recommendations:

  • For blending images with consistent boundaries, use blend, the Green Function Convolution implementation.
  • For images with inconsistent boundaries, use blend_dst_numpy.

Main interface:

  • blend: primary entrypoint, blends source image into target image at specified coordinates.
  • blend_dst_numpy: entrypoint for DST-based blending (currently only available in NumPy).
  • CachedPoissonBlender: calls blend but caches the Green function, so should be faster if you're repeatedly blending source patches of equal size, as you will only need to construct the Green function once.
  • blend_numpy: A NumPy implementation of blend.
    • blend_wide[_numpy]: Wrappers of blend methods which allow for blending over entire image to more smoothly integrate the source region.

Why use it?

  • It's faster than any available alternative (OpenCV's seamlessClone, or manual solvers using iterative methods).
  • It's flexible, working on n-dimensional images, with no explicit limitations on data types (unlike seamlessClone, which only operates on 8-bit 3-channel images).
  • You using it makes me feel like I'm contributing to the world.

Installation

Using pip

... coming soon ...

Manually

Clone PIE-torch repository and install the package locally:

git clone https://github.com/matt-baugh/pytorch-poisson-image-editing.git
pip install -e ./pytorch-poisson-image-editing

You can check the installation by running the tests:

cd pytorch-poisson-image-editing/test
pytest

Usage

Example of blending normal images using mixed gradients:

from pietorch import blend

target : torch.Tensor = ... # 3 x N x M image to be blended into
source : torch.Tensor = ... # 3 x H x W image to be blended
mask : torch.Tensor = ... # H x W mask of which pixels from source to be included
corner : torch.Tensor = ... # [y, x] coordinate of location in target for source to be blended

result = blend(target, source, mask, corner, True, channels_dim=0)

A wide variety of full examples are given in the examples notebook.

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

pie-torch-0.0.1.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

pie_torch-0.0.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file pie-torch-0.0.1.tar.gz.

File metadata

  • Download URL: pie-torch-0.0.1.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for pie-torch-0.0.1.tar.gz
Algorithm Hash digest
SHA256 87b5a5945b0ef7b6f08587ea24313ea0ae6e73878ad1ca2b141daec72781e644
MD5 3e46c23057cf0d89b5adf7e4b3783cd6
BLAKE2b-256 a7ea5351f7e45144f13d462f27623a22419ec9c161ca6576da59aab5de1edc69

See more details on using hashes here.

File details

Details for the file pie_torch-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pie_torch-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for pie_torch-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aaa3a44e31a3c2109a06074c6a3a2222c91f829d6f3927a8e912f2549ea83ddd
MD5 946449098417723ca5d63e6908a90d5f
BLAKE2b-256 cd1de4ce47da8559d771cdb8fc32a3371df1d53461c982f8214ab2e5a0b09aad

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