Coder Social home page Coder Social logo

grubcut-poisson's Introduction

Overview

This is a image tool which integrates the image foreground automatic segmentation with seamless image blending as a total. Specifically, this is a tool integrates two algorithms, they are GrabCut and Possion Image Blending respectively.

The former, GrabCut, is a popular interactive foreground extraction method based on few user input. What you need to do is just to drag a rectangle to cover the foreground object. The latter, Possion Image Blending, is also an appealing work based on the pixels' intensities aorund the boundry and the pixels' intensity gradients which fall in the region the bourny circles.

Thanks for Prof. Shaoping Lu who gives me this idea to integrate these two work together. I implemented this repo just for interests and study. 'Cause I did't used any graphic accelerations and I am not very good at c++/c language, the running time of this tool cannot reach to the real-time level. But our basic requirements can be met.

Environment

  • C++
  • Visual Studio 2015 with x64 runtime

Usage

I have written some code for interactive prompts. Have a try now!

Run the main.cpp, after that:

  1. Foreground Extraction

1.1 Choose an image (img/bear.png here)

1.2. Drag a rectangle to cover the foreground obejct During this step, you can press r to redrag the rectangle. You can also press shift or ctrl and drag your mouse leftkey simultaneously to mark some ground truth foreground or background pixels. For detail usage, you can check out the code.

1.3. Press n to start segmentation.

1.4 Press m to save the mask image. The file name of the mask image is set to be XXX_mask.png , where XXX is your input image file name.

1.5 Press Esc to back to main menu.

  1. Possion Image Blending As the above image indicating, you have to specifiy the source image location,mask image location,target image location,where to save output image,x-coordinate,y-coordinate respectively. The last two coordinates tell the program where to put the source image (starts at (0,0) of taeget image, i.e. left-upper corner).

Check it out:

Input:

Output:

References

[1] Carsten Rother, Vladimir Kolmogorov, Andrew Blake: “GrabCut” — Interactive Foreground Extraction using Iterated Graph Cuts. 2004

[2] Patrick Perez, Michel Gangnet, Andrew Blake: Poisson Image Editing.

[3] OpenCV GrabCut implementation.

grubcut-poisson's People

Contributors

liuzhian avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

jayagami linecode

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.