https://github.com/bchao1/fast-poisson-image-editing

Fast, scalable, and extensive implementations of Poisson image editing algorithms.

https://github.com/bchao1/fast-poisson-image-editing

Science Score: 49.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in README
  • Academic publication links
    Links to: acm.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.5%) to scientific vocabulary

Keywords

computer-graphics computer-vision gradient gradient-domain-image-processing image-blending image-cloning image-processing laplacian poisson-equation poisson-image-editing
Last synced: 5 months ago · JSON representation

Repository

Fast, scalable, and extensive implementations of Poisson image editing algorithms.

Basic Info
  • Host: GitHub
  • Owner: bchao1
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 12 MB
Statistics
  • Stars: 45
  • Watchers: 2
  • Forks: 2
  • Open Issues: 1
  • Releases: 0
Topics
computer-graphics computer-vision gradient gradient-domain-image-processing image-blending image-cloning image-processing laplacian poisson-equation poisson-image-editing
Created almost 4 years ago · Last pushed over 3 years ago
Metadata Files
Readme

README.md

Poisson image editing

A fast, scalable, and extensive implementation of the Poisson Image Editing paper by Perez et al. 2003.

teaser

Features

  • Poisson image editing functionalities
    • Seamless cloning - importing gradients
    • Seamless cloning - mixing gradients
    • Seamless tiling
    • Texture flattening
    • Local illumination change
    • Local color change
  • Supports all sparse linear system solvers in scipy.sparse.linalg
  • Acceleration of large input problems using multigrid approaches
  • An Object-Oriented Programming approach for Poisson image editing - see branch oop for more details
    • All editing functions inherit the abstract PoissonImageEditor class

Comparison with other implementations

There are many open source Python implementations of Poisson image editing. However, most implementations only focus on image blending, while ignoring other Poisson image editing applications listed in the paper. This implementation aims to faithfully reproduce all experiments and results presented in the paper. The following table shows the implemented functionalities:

| |Src. 1|Src. 2|Src. 3|This| |---|---|---|---|---| |Seamless cloning|✅|✅|✅|✅| |Seamless tiling|❌|❌|❌|✅| |Texture flattening|✅|❌|❌|✅| |Local illumination change|❌|❌|❌|✅| |Local color change|❌|❌|❌|✅|

Furthermore, this implementation is signifacantly faster and scales much better than others. The following table shows the profiled run time of seamless cloning on different datasets (in seconds):

| |Src. 1|Src. 2|Src. 3|This| |---|---|---|---|---| |test1|32.064|312.930|6.755|1.799| |test2|13.634|59.875|1.775|1.389| |test3|36.575|565.466|3.401|1.818| |test4|19.866|42.592|1.542|1.419|

The following figure shows the scaling performance of this implementation compared to that of Src. 3. For fair comparison, both implementations are modified to use the same solver scipy.sparse.linalg.spsolve. scaling perf

By using multigrid solvers, editing a 1080p image can be done in less than 30 seconds, a 6.7x speedup compared to the current fastest open source Python implementation:

| |Src. 3|This (multigrid approach)| |---|---|---| |1080p image|134.896|20.814|

Usage

To run all experiments using the given datasets (contains testing images in the paper and this README file), run ./run_experiments.sh

Seamless cloning

To test on your own dataset, run python3 seamless_cloning.py --help

  • data_dir: Folder that contains the input image files. The folder should contain image files named mask, target, and source. The file extension of the files can be arbitrary, as long as the files are valid image files.
  • grayscale: Whether to perform blending on the grayscale images.
  • solver: Linear solver to use when solving the poisson blending problem. The value of solver should either be function names in the scipy.sparse.linalg library, or "multigrid". Default is spsolve.
  • gradient_mixing_mode: Method to mix source and target image gradients. max implements 3. Seamless cloning - Mixing gradients section in the paper, while alpha + gradient_mixing_alpha == 1.0 implements 3. Seamless cloning - Importing gradients section.
  • gradient_mixing_alpha: Alpha to blend source and target image gradients. Has an effect only when gradient_mixing_mode == "alpha".

Seamless tiling

To test on your own dataset, run python3 seamless_tiling.py --help

Texture flattening

To test on your own dataset, run python3 texture_flattening.py --help - use_edge: Use edge.* edge map image file in the folder specified in the data_dir folder. If this flag is not set, then computes the edge map from provided source image using Canny edge detector and binary dilation. - canny_threshold: Thresholding parameters for Canny edge detector. You can play with this parameter for different flattening results. See the documentation for more information. - edge_dilation_kernel: Kernel size to dilate detected edges. The kernel is a square box filter filled with ones.

Local illumination change

To test on your own dataset, run python3 local_illumination_change.py --help - data_dir: Folder that contains the input image files. The folder should contain image files named mask and source. The file extension of the files can be arbitrary, as long as the files are valid image files. The illumination of the regions specified by the mask will be modified.

Local color change

To test on your own dataset, run python3 local_color_change.py --help - mode: Color change mode. If mode == "gray_background", then pixels outside the masked region will be converted to grayscale. If mode == "color_change", the hue of the masked region is increased by the value specified by change_hue parameter. - change_hue: Value added to the hue channel of the masked region.

Results

Seamless cloning

|Source|Target|Mask|Result| |---|---|---|---| |src|src|src|src| |src|src|src|src| |src|src|src|src| |||||

Seamless tiling

|Texture|Naive tile|Seamless tile| |---|---|---| |||| ||||

Texture flattening

|Source|Mask|Edge|Flattened| |---|---|---|---| |||||

Local illumination change

|Source|Mask|Modified| |---|---|---| ||||

Local color change

|Source|Green-ish|Blue-ish|Gray background| |---|---|---|---| |||||

Notes

  • Faster solvers: spsolve, cgs, bicg
  • minres gives bad results.
  • If you want to use conjugate gradient solvers, use bicg, bicgstab or cgs. Do not use solver == "cg" since the A matrix is not hermitian (or symmetric since A is real).
  • Iterative least-squares solvers lsqr, lsmr tend to be much slower.

Owner

  • Name: Brian Chao
  • Login: bchao1
  • Kind: user
  • Location: Stanford, California
  • Company: Stanford University

Stanford Ph.D. student. Research in computational photography, displays, and computer graphics. Open source enthusiast.

GitHub Events

Total
  • Watch event: 4
Last Year
  • Watch event: 4

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 44
  • Total Committers: 1
  • Avg Commits per committer: 44.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
bchao1 w****0@g****m 44

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 1
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 1
  • Total pull request authors: 0
  • Average comments per issue: 2.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ade585 (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels