Skip to main content

pyGCO: a python wrapper for the graph cuts package

Project description

pyGCO: a python wrapper for the graph cuts

The original wrapper is pygco

PyPI - Python Version PyPI Status PyPI Status CI testing codecov Codacy Badge


This is a python wrapper for gco-v3.0 package, which implements a graph cuts based move-making algorithm for optimization in Markov Random Fields.

It contains a copy of the gco-v3.0 package. Some of the design were borrowed from the gco_python package. However, compared to gco_python:

  • This package does not depend on Cython. Instead it is implemented using the ctypes library and a C wrapper of the C++ code.
  • This package is an almost complete wrapper for gco-v3.0, which supports more direct low level control over GCoptimization objects.
  • This package supports graphs with edges weighted differently.

This wrapper is composed of two parts, a C wrapper and a python wrapper.

Implemented functions

  • cut_general_graph(...)
  • cut_grid_graph(...)
  • cut_grid_graph_simple(...)

Building wrapper

  1. download the last version of gco-v3.0 to the gco_source
  2. compile gco-v3.0 and the C wrapper using make
  3. compile test_wrapper using make test_wrapper
  4. run the C test code ./test_wrapper (now you have the C wrapper ready)
make download
make all
make test_wrapper
./test_wrapper

The successful run should return:

labels = [ 0 2 2 1 ], energy=19
data energy=15, smooth energy=4

Next test the python wrapper using python test_examples.py, if it works fine you are ready to use pygco.

To include pygco in your code, simply import pygco module. See the documentation inside code for more details.

Install wrapper

Clone repository and enter folder, then

pip install -r requirements.txt
python setup.py install

Now it can be also installed from PyPi

pip install gco-wrapper

Show test results

Visualisation of the unary terns for binary segmentation

unary terms

4-connected components with the initial labeling (left) and estimated labeling with regularisation 1 (middle) and 0 (right)

labelling

8-connected components with the initial labeling (left) and estimated labeling with regularisation 1 (middle) and 0 (right)

labelling

Visualisation of the unary terns for 3 labels segmentation

unary terms

with the initial labeling (left) and estimated labeling (right)

labelling

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gco-wrapper-3.0.7.tar.gz (57.4 kB view hashes)

Uploaded Source

Built Distributions

gco_wrapper-3.0.7-cp39-cp39-win_amd64.whl (43.4 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

gco_wrapper-3.0.7-cp39-cp39-win32.whl (39.6 kB view hashes)

Uploaded CPython 3.9 Windows x86

gco_wrapper-3.0.7-cp39-cp39-manylinux2010_x86_64.whl (261.7 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

gco_wrapper-3.0.7-cp39-cp39-manylinux2010_i686.whl (248.6 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ i686

gco_wrapper-3.0.7-cp39-cp39-macosx_10_9_x86_64.whl (58.2 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

gco_wrapper-3.0.7-cp38-cp38-win_amd64.whl (43.4 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

gco_wrapper-3.0.7-cp38-cp38-win32.whl (39.5 kB view hashes)

Uploaded CPython 3.8 Windows x86

gco_wrapper-3.0.7-cp38-cp38-manylinux2010_x86_64.whl (261.6 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

gco_wrapper-3.0.7-cp38-cp38-manylinux2010_i686.whl (248.4 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

gco_wrapper-3.0.7-cp38-cp38-macosx_10_9_x86_64.whl (58.2 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

gco_wrapper-3.0.7-cp37-cp37m-win_amd64.whl (43.4 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

gco_wrapper-3.0.7-cp37-cp37m-win32.whl (39.5 kB view hashes)

Uploaded CPython 3.7m Windows x86

gco_wrapper-3.0.7-cp37-cp37m-manylinux2010_x86_64.whl (261.6 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

gco_wrapper-3.0.7-cp37-cp37m-manylinux2010_i686.whl (248.4 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

gco_wrapper-3.0.7-cp37-cp37m-macosx_10_9_x86_64.whl (58.2 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

gco_wrapper-3.0.7-cp36-cp36m-win_amd64.whl (43.4 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

gco_wrapper-3.0.7-cp36-cp36m-win32.whl (39.5 kB view hashes)

Uploaded CPython 3.6m Windows x86

gco_wrapper-3.0.7-cp36-cp36m-manylinux2010_x86_64.whl (261.6 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

gco_wrapper-3.0.7-cp36-cp36m-manylinux2010_i686.whl (248.4 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ i686

gco_wrapper-3.0.7-cp36-cp36m-macosx_10_9_x86_64.whl (58.2 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

gco_wrapper-3.0.7-cp35-cp35m-win_amd64.whl (43.4 kB view hashes)

Uploaded CPython 3.5m Windows x86-64

gco_wrapper-3.0.7-cp35-cp35m-win32.whl (39.5 kB view hashes)

Uploaded CPython 3.5m Windows x86

gco_wrapper-3.0.7-cp35-cp35m-manylinux2010_x86_64.whl (261.6 kB view hashes)

Uploaded CPython 3.5m manylinux: glibc 2.12+ x86-64

gco_wrapper-3.0.7-cp35-cp35m-manylinux2010_i686.whl (248.4 kB view hashes)

Uploaded CPython 3.5m manylinux: glibc 2.12+ i686

gco_wrapper-3.0.7-cp35-cp35m-macosx_10_9_x86_64.whl (57.5 kB view hashes)

Uploaded CPython 3.5m macOS 10.9+ x86-64

gco_wrapper-3.0.7-cp27-cp27mu-manylinux2010_x86_64.whl (258.5 kB view hashes)

Uploaded CPython 2.7mu manylinux: glibc 2.12+ x86-64

gco_wrapper-3.0.7-cp27-cp27mu-manylinux2010_i686.whl (244.9 kB view hashes)

Uploaded CPython 2.7mu manylinux: glibc 2.12+ i686

gco_wrapper-3.0.7-cp27-cp27m-manylinux2010_x86_64.whl (258.6 kB view hashes)

Uploaded CPython 2.7m manylinux: glibc 2.12+ x86-64

gco_wrapper-3.0.7-cp27-cp27m-manylinux2010_i686.whl (244.9 kB view hashes)

Uploaded CPython 2.7m manylinux: glibc 2.12+ i686

gco_wrapper-3.0.7-cp27-cp27m-macosx_10_9_x86_64.whl (57.4 kB view hashes)

Uploaded CPython 2.7m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page