Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hpjansson/cropsicle

Minimal C implementation of the Growcut area selection algorithm
https://github.com/hpjansson/cropsicle

c graphics image-processing

Last synced: 3 months ago
JSON representation

Minimal C implementation of the Growcut area selection algorithm

Awesome Lists containing this project

README

        

Cropsicle
=========

Cropsicle is a multithreaded C implementation of the GrowCut algorithm
described in the paper "GrowCut - Interactive Multi-Label N-D Image
Segmentation By Cellular Automata" by Vladimir Vezhnevets and Vadim
Konouchine [1].

It lets you remove the background from an image with minimal input, cutting
along irregular boundaries.

[1] http://graphicon.ru/oldgr/en/publications/text/gc2005vk.pdf

Build
-----

> gcc -g -O3 cropsicle.c $(pkg-config --libs --cflags libpng) -lm -pthread -o cropsicle

Run
---

This program supports 4-channel 8-bit-per-channel RGBA PNG images only. If
you have something else, you must convert it to the proper format first,
like this:

> convert image.jpg -channel rgba png32:image.png

Perform the GrowCut operation like this:

> cropsicle image.png overlay.png output.png

Image is the source image, overlay is an alpha-transparent overlay with
a few green pixels spread out over the foreground you want to keep
and red pixels over the background. The pixels don't have to be perfect red
and green as long as the corresponding red/green channels are dominant and
the pixels are not transparent.

Enjoy!

Example
-------

Example input and output images for the cropsicle invocation above:

* [image.png](http://hpjansson.org/cropsicle/example/surf.png)
* [overlay.png](http://hpjansson.org/cropsicle/example/surf-overlay.png)
* [output.png](http://hpjansson.org/cropsicle/example/surf-out.png)