Skip to content

ochzhen/image-segmentation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

image-segmentation

A simple program that separates an image into foreground and background inside of specified rectangular area leveraging a basic graph cut technique. The following picture demonstrates how it works:

Processing example

Approach

The idea is to represent each pixel as a vertex of the graph and also have two more vertices - source and sink. Each pixel is connected to adjacent pixels and to the source and the sink.

Clearly, this approach has many limitations but it works on simple input.

In general, the process consists of the following steps:

  • Represent each pixel as a graph vertex
  • Add two terminal vertices: source and sink (red and blue on the picture)
  • Connect each non-terminal vertex with neighbors (binary component) and with terminal vertices (unary component)
  • Find minimum cut

The minimum cut gives the separation between foreground and background because all vertices are divided into two sets: reachable from source vertex and non-reachable.

Algorithms

Performance

In order to find min-cut/max-flow in a graph and also to compare the performance of different algorithms, the following ones were implemented:

  • Edmonds-Karp
  • Dinic
  • Push-Relabel

Basic performance comparison is displayed on the chart. Push-Relabel algorithm is the fastest one and therefore was used to process images.

Samples

Bear


Dog


Polar bear


Butterfly

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages