PyMatting

PyMatting: A Python Library for Alpha Matting - Published in JOSS (2020)

https://github.com/pymatting/pymatting

Science Score: 95.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 6 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org
  • Committers with academic emails
    2 of 14 committers (14.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

alpha-matting foreground image-processing python3

Keywords from Contributors

cryptocurrencies

Scientific Fields

Mathematics Computer Science - 63% confidence
Last synced: 4 months ago · JSON representation

Repository

A Python library for alpha matting

Basic Info
  • Host: GitHub
  • Owner: pymatting
  • License: mit
  • Language: Python
  • Default Branch: master
  • Homepage: https://pymatting.github.io
  • Size: 7.21 MB
Statistics
  • Stars: 1,863
  • Watchers: 39
  • Forks: 224
  • Open Issues: 10
  • Releases: 5
Topics
alpha-matting foreground image-processing python3
Created almost 6 years ago · Last pushed 7 months ago
Metadata Files
Readme Changelog Contributing License

README.md

PyMatting: A Python Library for Alpha Matting

License: MIT CI PyPI JOSS Gitter

We introduce the PyMatting package for Python which implements various methods to solve the alpha matting problem.

Lemur

Given an input image and a hand-drawn trimap (top row), alpha matting estimates the alpha channel of a foreground object which can then be composed onto a different background (bottom row).

PyMatting provides: - Alpha matting implementations for: - Closed Form Alpha Matting [1] - Large Kernel Matting [2] - KNN Matting [3] - Learning Based Digital Matting [4] - Random Walk Matting [5] - Shared Sampling Matting [6] - Foreground estimation implementations for: - Closed Form Foreground Estimation [1] - Fast Multi-Level Foreground Estimation (CPU, CUDA and OpenCL) [7] - Fast multithreaded KNN search - Preconditioners to accelerate the convergence rate of conjugate gradient descent: - The incomplete thresholded Cholesky decomposition (Incomplete is part of the name. The implementation is quite complete.) - The V-Cycle Geometric Multigrid preconditioner - Readable code leveraging NumPy, SciPy and Numba

Getting Started

Requirements

Minimal requirements * numpy>=1.16.0 * pillow>=5.2.0 * numba>=0.47.0 * scipy>=1.1.0

Additional requirements for GPU support * cupy-cuda90>=6.5.0 or similar * pyopencl>=2019.1.2

Requirements to run the tests * pytest>=5.3.4

Installation with PyPI

bash pip3 install pymatting

Installation from Source

bash git clone https://github.com/pymatting/pymatting cd pymatting pip3 install .

Example

```python

First import will take a minute due to compilation

from pymatting import cutout

cutout( # input image path "data/lemur/lemur.png", # input trimap path "data/lemur/lemurtrimap.png", # output cutout path "lemurcutout.png") ```

More advanced examples

Trimap Construction

All implemented methods rely on trimaps which roughly classify the image into foreground, background and unknown regions. Trimaps are expected to be numpy.ndarrays of type np.float64 having the same shape as the input image with only one color-channel. Trimap values of 0.0 denote pixels which are 100% background. Similarly, trimap values of 1.0 denote pixels which are 100% foreground. All other values indicate unknown pixels which will be estimated by the algorithm.

Testing

Run the tests from the main directory: pip3 install -r requirements_tests.txt ppytest

Currently 89% of the code is covered by tests.

Upgrade

bash pip3 install --upgrade pymatting python3 -c "import pymatting"

Bug Reports, Questions and Pull-Requests

Please, see our community guidelines.

Authors

  • Thomas Germer
  • Tobias Uelwer
  • Stefan Conrad
  • Stefan Harmeling

See also the list of contributors who participated in this project.

Projects using PyMatting

  • Rembg - an excellent tool for removing image backgrounds.
  • PaddleSeg - a library for a wide range of image segmentation tasks.
  • chaiNNer - a node-based image processing GUI.
  • LSA-Matting - improving deep image matting via local smoothness assumption.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Citing

If you found PyMatting to be useful for your work, please consider citing our paper:

@article{Germer2020, doi = {10.21105/joss.02481}, url = {https://doi.org/10.21105/joss.02481}, year = {2020}, publisher = {The Open Journal}, volume = {5}, number = {54}, pages = {2481}, author = {Thomas Germer and Tobias Uelwer and Stefan Conrad and Stefan Harmeling}, title = {PyMatting: A Python Library for Alpha Matting}, journal = {Journal of Open Source Software} }

References

[1] Anat Levin, Dani Lischinski, and Yair Weiss. A closed-form solution to natural image matting. IEEE transactions on pattern analysis and machine intelligence, 30(2):228–242, 2007.

[2] Kaiming He, Jian Sun, and Xiaoou Tang. Fast matting using large kernel matting laplacian matrices. In 2010 IEEE Computer Society Conference on Computer Vision and Pattern Recognition, 2165–2172. IEEE, 2010.

[3] Qifeng Chen, Dingzeyu Li, and Chi-Keung Tang. Knn matting. IEEE transactions on pattern analysis and machine intelligence, 35(9):2175–2188, 2013.

[4] Yuanjie Zheng and Chandra Kambhamettu. Learning based digital matting. In 2009 IEEE 12th international conference on computer vision, 889–896. IEEE, 2009.

[5] Leo Grady, Thomas Schiwietz, Shmuel Aharon, and Rüdiger Westermann. Random walks for interactive alpha-matting. In Proceedings of VIIP, volume 2005, 423–429. 2005.

[6] Eduardo S. L. Gastal and Manuel M. Oliveira. "Shared Sampling for Real-Time Alpha Matting". Computer Graphics Forum. Volume 29 (2010), Number 2, Proceedings of Eurographics 2010, pp. 575-584.

[7] Germer, T., Uelwer, T., Conrad, S., & Harmeling, S. (2020). Fast Multi-Level Foreground Estimation. arXiv preprint arXiv:2006.14970.

Lemur image by Mathias Appel from https://www.flickr.com/photos/mathiasappel/25419442300/ licensed under CC0 1.0 Universal (CC0 1.0) Public Domain License.

Owner

  • Name: PyMatting
  • Login: pymatting
  • Kind: organization

JOSS Publication

PyMatting: A Python Library for Alpha Matting
Published
October 13, 2020
Volume 5, Issue 54, Page 2481
Authors
Thomas Germer
Department of Computer Science, Heinrich Heine University Düsseldorf
Tobias Uelwer
Department of Computer Science, Heinrich Heine University Düsseldorf
Stefan Conrad
Department of Computer Science, Heinrich Heine University Düsseldorf
Stefan Harmeling
Department of Computer Science, Heinrich Heine University Düsseldorf
Editor
George K. Thiruvathukal ORCID
Tags
alpha matting soft-segmentation foreground extraction toolbox

GitHub Events

Total
  • Create event: 1
  • Release event: 1
  • Issues event: 3
  • Watch event: 88
  • Issue comment event: 15
  • Push event: 3
  • Pull request event: 3
  • Fork event: 8
Last Year
  • Create event: 1
  • Release event: 1
  • Issues event: 3
  • Watch event: 88
  • Issue comment event: 15
  • Push event: 3
  • Pull request event: 3
  • Fork event: 8

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 184
  • Total Committers: 14
  • Avg Commits per committer: 13.143
  • Development Distribution Score (DDS): 0.56
Past Year
  • Commits: 11
  • Committers: 4
  • Avg Commits per committer: 2.75
  • Development Distribution Score (DDS): 0.545
Top Committers
Name Email Commits
Tobias Uelwer t****r@u****e 81
99991 9****1 72
99991 y****u@e****m 11
Joseph Adams w****m@g****m 3
Dany Vohl m****e 3
Christian Clauss c****s@m****m 3
Richard Brown r****n@s****o 2
germer g****r@b****e 2
99991 p****g@g****m 2
Pierre Chapuis g****t@c****o 1
Paarth Bhatnagar p****3@g****m 1
Matt Chan 4****n 1
Egor Karpov k****a@g****m 1
99991 9****1@n****m 1

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 68
  • Total pull requests: 24
  • Average time to close issues: 4 months
  • Average time to close pull requests: about 17 hours
  • Total issue authors: 53
  • Total pull request authors: 11
  • Average comments per issue: 3.24
  • Average comments per pull request: 1.0
  • Merged pull requests: 21
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 4
  • Pull requests: 4
  • Average time to close issues: about 8 hours
  • Average time to close pull requests: about 1 hour
  • Issue authors: 3
  • Pull request authors: 3
  • Average comments per issue: 1.5
  • Average comments per pull request: 0.75
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • 99991 (4)
  • tuelwer (3)
  • ntuLC (3)
  • dreamer121121 (3)
  • lfxx (2)
  • egoorr (2)
  • TatianaSnauwaert (2)
  • GraceKafuu (2)
  • ghazni123 (2)
  • jangop (2)
  • mweinelt (1)
  • xamxixixo (1)
  • thewchan (1)
  • CruiseShao (1)
  • Windaway (1)
Pull Request Authors
  • 99991 (8)
  • tuelwer (4)
  • macrocosme (3)
  • cclauss (3)
  • rb-synth (2)
  • catwell (2)
  • p4arth (2)
  • karpp (2)
  • jcla1 (1)
  • chendeheng611 (1)
  • thewchan (1)
Top Labels
Issue Labels
enhancement (1) good first issue (1)
Pull Request Labels

Packages

  • Total packages: 3
  • Total downloads:
    • pypi 1,507,369 last-month
  • Total docker downloads: 445
  • Total dependent packages: 5
    (may contain duplicates)
  • Total dependent repositories: 109
    (may contain duplicates)
  • Total versions: 25
  • Total maintainers: 1
pypi.org: pymatting

Python package for alpha matting.

  • Versions: 18
  • Dependent Packages: 5
  • Dependent Repositories: 109
  • Downloads: 1,507,369 Last month
  • Docker Downloads: 445
Rankings
Downloads: 0.8%
Dependent repos count: 1.4%
Stargazers count: 1.7%
Dependent packages count: 1.9%
Average: 2.2%
Docker downloads count: 3.5%
Forks count: 3.6%
Maintainers (1)
Last synced: 4 months ago
proxy.golang.org: github.com/pymatting/pymatting
  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 4 months ago
conda-forge.org: pymatting
  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Stargazers count: 10.0%
Forks count: 12.3%
Average: 26.9%
Dependent repos count: 34.0%
Dependent packages count: 51.2%
Last synced: 4 months ago

Dependencies

.github/workflows/lint.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
.github/workflows/tests.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
requirements.txt pypi
  • numba *
  • numpy >=1.16.0
  • pillow >=5.2.0
  • scipy >=1.1.0
requirements_gpu.txt pypi
  • cupy-cuda90 >=6.5.0
  • pyopencl >=2019.1.2
requirements_tests.txt pypi
  • flake8 >=3.7.9 test
  • pytest >=5.3.4 test