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.
2 implementations, including:
- using Green Function Convolution, as described in Fast and Optimal Laplacian Solver for Gradient-Domain Image Editing using Green Function Convolution
- using a Discrete Sine Transform, following OpenCV's implementation
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: callsblendbut 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 ofblend.blend_wide[_numpy]: Wrappers ofblendmethods 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87b5a5945b0ef7b6f08587ea24313ea0ae6e73878ad1ca2b141daec72781e644
|
|
| MD5 |
3e46c23057cf0d89b5adf7e4b3783cd6
|
|
| BLAKE2b-256 |
a7ea5351f7e45144f13d462f27623a22419ec9c161ca6576da59aab5de1edc69
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aaa3a44e31a3c2109a06074c6a3a2222c91f829d6f3927a8e912f2549ea83ddd
|
|
| MD5 |
946449098417723ca5d63e6908a90d5f
|
|
| BLAKE2b-256 |
cd1de4ce47da8559d771cdb8fc32a3371df1d53461c982f8214ab2e5a0b09aad
|