Giter Club home page Giter Club logo

comprehensive-sample-set-image-matting's Introduction

Comprehensive-Sample-Set-Image-Matting

Overview of the program

This program is an implementation of the paper "Improving image matting using comprehensive sample sets" by Shahrian & al. and was coded as part of a science project at university. It includes a small graphical interface to analyze the results and observe the behavior of the algorithm.

Here is the scientific report that I wrote and the slides that were used during the presentation.

Disclaimer This program is not an official implementation of the paper (an official binary can be found here), it is only partial and has not been designed with efficiency concerns. It will not give the same results as the official one and therefore cannot be used to compare the efficiency of this algorithm with other image matting algorithms.

How to make the program work?

Compilation

You need to have the library OpenCV installed on your computer (version 2.4.8 recommended, older versions not tested but should work properly). Details regarding the installation procedure for each platform won't be given here but are easily accessible online (here for example).

A Makefile is provided with the code so compilation shouldn't take more work than simply type make in the code directory. Note that you may have to change the lines LIBS = -L/usr/local/lib and INC = -I/usr/local/include/opencv to point to the directory where OpenCV is installed on your computer.

Usage

The program must be given as a command-line argument the name of the image (including the extension). Input images should be stored in directory input/ and trimaps in directory trimap/ with the exact same name. Usage example : ./cssmatting GT01.png

Note that a nice dataset of images can be found here.

How to use the graphical interface?

Displaying sample sets and best candidates

Once everything has been computed, the program will open three interactive windows that are synchronized together:

• "Input + (F,B)": Shows the input image. Any click on a pixel will show the best (F,B) pair associated with this point. The color of the line joining them gives an indication of the associated alpha value as a continuous variation from blue (0) to red (1).

• "Alpha Matte": Shows the computed alpha matte. Any click on a pixel will be passed on to the two other windows.

• "Sample set": When no pixel has been selected yet it shows the trimap. When a pixel is selected, this window shows its corresponding subregion, and the associated sample set.

Note that pressing any key will exit the program.

Changing the objective function

Move the slider in window "Input + (F,B)" to change the objective function for the selection of the best (F,B) pair. You can choose to use only the color constraint, the spatial constraint, the least-overlapping constraint or a combination of these. Note that the alpha matte will be updated (this can take some time depending on the size of the unknown zone).

Brief description of the data structures

Class Region

The most important data structure used in this program is the class Region. It represents a subset of a given image by embedding a list of pixel positions (indexed over the main image 'input'). It provides facilities to get access to the barycenter, mean color and variance of the region, easy access to the equivalent binary map and a function to draw itself on an image. Foreground, Background, Unknown region, subregions, and all clusters are instances of this class.

Class CandidateSample

This class is designed to represent a candidate sample. It contains the spatial position, color and a pointer to the region where it was extracted. Sample sets for each subregion are stored as lists of instances of CandidateSample.

Tweaking the parameters

You can tweak some parameters of the algorithm easily by changing values in the file CSSMatting.cpp (towards the beginning). Parameters that can be changed include the number of subregions, the number of clusters for the first subregion, the type of covariance matrix for the EM algorithm, the choice of the objective function that will be used.

comprehensive-sample-set-image-matting's People

Contributors

supitalp avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.