All Projects → MarcoForte → Closed Form Matting

MarcoForte / Closed Form Matting

Licence: mit
Python implementation of A. Levin D. Lischinski and Y. Weiss. A Closed Form Solution to Natural Image Matting. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), June 2006, New York

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Closed Form Matting

Sewar
All image quality metrics you need in one package.
Stars: ✭ 299 (-14.33%)
Mutual labels:  image-processing
Skeptick
Better ImageMagick for Ruby
Stars: ✭ 326 (-6.59%)
Mutual labels:  image-processing
Filter.js
Filter.js: Video and Image Processing and Computer Vision Library in pure JavaScript (Browser and Node.js)
Stars: ✭ 335 (-4.01%)
Mutual labels:  image-processing
Dali
A GPU-accelerated library containing highly optimized building blocks and an execution engine for data processing to accelerate deep learning training and inference applications.
Stars: ✭ 3,624 (+938.4%)
Mutual labels:  image-processing
Medpy
Medical image processing in Python
Stars: ✭ 321 (-8.02%)
Mutual labels:  image-processing
Face recognition
🍎 My own face recognition with deep neural networks.
Stars: ✭ 328 (-6.02%)
Mutual labels:  image-processing
Segmentation models.pytorch
Segmentation models with pretrained backbones. PyTorch.
Stars: ✭ 4,584 (+1213.47%)
Mutual labels:  image-processing
Pythonfromspace
Python Examples for Remote Sensing
Stars: ✭ 344 (-1.43%)
Mutual labels:  image-processing
Stegano
A pure Python steganography module.
Stars: ✭ 324 (-7.16%)
Mutual labels:  image-processing
Opence
Contrast Enhancement Techniques for low-light images
Stars: ✭ 333 (-4.58%)
Mutual labels:  image-processing
Exifcleaner
Cross-platform desktop GUI app to clean image metadata
Stars: ✭ 305 (-12.61%)
Mutual labels:  image-processing
Jekyll Gallery Generator
A Jekyll plugin that generates photo galleries from directories full of images.
Stars: ✭ 315 (-9.74%)
Mutual labels:  image-processing
Retinexnet
A Tensorflow implementation of RetinexNet
Stars: ✭ 330 (-5.44%)
Mutual labels:  image-processing
Tinify Nodejs
Node.js client for the Tinify API.
Stars: ✭ 299 (-14.33%)
Mutual labels:  image-processing
Imageproc
Image processing operations
Stars: ✭ 340 (-2.58%)
Mutual labels:  image-processing
Bild
Image processing algorithms in pure Go
Stars: ✭ 3,431 (+883.09%)
Mutual labels:  image-processing
Artificio
Deep Learning Computer Vision Algorithms for Real-World Use
Stars: ✭ 326 (-6.59%)
Mutual labels:  image-processing
Thumbnailator
Thumbnailator - a thumbnail generation library for Java
Stars: ✭ 3,845 (+1001.72%)
Mutual labels:  image-processing
Image pipeline
An image processing pipeline for ROS.
Stars: ✭ 343 (-1.72%)
Mutual labels:  image-processing
Imgtoascii
A JavaScript implementation of a image to Ascii code
Stars: ✭ 331 (-5.16%)
Mutual labels:  image-processing

Closed-Form Matting

Build Status

Python implementation of image matting method proposed in A. Levin D. Lischinski and Y. Weiss. A Closed Form Solution to Natural Image Matting. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), June 2006, New York

The repository also contains implementation of background/foreground reconstruction method proposed in Levin, Anat, Dani Lischinski, and Yair Weiss. "A closed-form solution to natural image matting." IEEE Transactions on Pattern Analysis and Machine Intelligence 30.2 (2008): 228-242.

Requirements

  • python 3.5+ (Though it should run on 2.7)
  • scipy
  • numpy
  • opencv-python

Installation

Clone this repository and install the closed-form-matting package via pip.

git clone https://github.com/MarcoForte/closed-form-matting.git
cd closed-form-matting/
pip install .

Usage

Closed-Form matting

CLI inerface:

# Scribbles input
closed-form-matting ./testdata/source.png -s ./testdata/scribbles.png  -o output_alpha.png

# Trimap input
closed-form-matting ./testdata/source.png -t ./testdata/trimap.png  -o output_alpha.png

# Add flag --solve-fg to compute foreground color and output RGBA image instead
# of alpha.

Python interface:

import closed_form_matting
...
# For scribles input
alpha = closed_form_matting.closed_form_matting_with_scribbles(image, scribbles)

# For trimap input
alpha = closed_form_matting.closed_form_matting_with_trimap(image, trimap)

# For prior with confidence
alpha = closed_form_matting.closed_form_matting_with_prior(
    image, prior, prior_confidence, optional_const_mask)

# To get Matting Laplacian for image
laplacian = closed_form_matting.compute_laplacian(image, optional_const_mask)

Foreground and Background Reconstruction

CLI interface (requires opencv-python):

solve-foreground-background image.png alpha.png foreground.png background.png

Python interface:

from closed_form_matting import solve_foreground_background
...
foreground, background = solve_foreground_background(image, alpha)

Results

Original image Scribbled image Output alpha Output foreground
Original image Scribbled image Output alpha Output foreground

More Information

The computation is generally faster than the matlab version thanks to more vectorization. Note. The computed laplacian is slightly different due to array ordering in numpy being different than in matlab. To get same laplacian as in matlab change,

indsM = np.arange(h*w).reshape((h, w)) ravelImg = img.reshape(h*w, d) to indsM = np.arange(h*w).reshape((h, w), order='F') ravelImg = img.reshape(h*w, d, , order='F'). Again note that this will result in incorrect alpha if the D_s, b_s orderings are not also changed to order='F'F.

For more information see the original paper http://www.wisdom.weizmann.ac.il/~levina/papers/Matting-Levin-Lischinski-Weiss-CVPR06.pdf The original matlab code is here http://www.wisdom.weizmann.ac.il/~levina/matting.tar.gz

Disclaimer

The code is free for academic/research purpose. Use at your own risk and we are not responsible for any loss resulting from this code. Feel free to submit pull request for bug fixes.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].