Skip to main content

numpymaxflow: Max-flow/Min-cut in Numpy for 2D images and 3D volumes

Project description

numpymaxflow: Max-flow/Min-cut in numpy for 2D images and 3D volumes

License CI Build PyPI version

Numpy-based implementation of Max-flow/Min-cut based on the following paper:

  • Boykov, Yuri, and Vladimir Kolmogorov. "An experimental comparison of min-cut/max-flow algorithms for energy minimization in vision." IEEE transactions on pattern analysis and machine intelligence 26.9 (2004): 1124-1137.

If you want same functionality in PyTorch, then consider PyTorch-based implementation

Citation

If you use this code in your research, then please consider citing:

Asad, Muhammad, Lucas Fidon, and Tom Vercauteren. "ECONet: Efficient Convolutional Online Likelihood Network for Scribble-based Interactive Segmentation." Medical Imaging with Deep Learning (MIDL), 2022.

Installation instructions

pip install numpymaxflow

or

# Clone and install from github repo

$ git clone https://github.com/masadcv/numpymaxflow
$ cd numpymaxflow
$ pip install -r requirements.txt
$ python setup.py install

Example outputs

Maxflow2d

./figures/numpymaxflow_maxflow2d.png

Interactive maxflow2d

./figures/numpymaxflow_intmaxflow2d.png

figures/figure_numpymaxflow.png

Example usage

The following demonstrates a simple example showing numpymaxflow usage:

image = np.asarray(Image.open('data/image2d.png').convert('L'), np.float32)
image = np.expand_dims(image, axis=0)

prob = np.asarray(Image.open('data/image2d_prob.png'), np.float32)

lamda = 20.0
sigma = 10.0

post_proc_label = numpymaxflow.maxflow(image, prob, lamda, sigma)

For more usage examples see:

2D and 3D maxflow and interactive maxflow examples: demo_maxflow.py

References

This repository depends on the code for maxflow from latest version of OpenCV, which has been included.

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

numpymaxflow-0.0.4.tar.gz (14.4 kB view hashes)

Uploaded Source

Built Distributions

numpymaxflow-0.0.4-cp39-cp39-win_amd64.whl (25.4 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

numpymaxflow-0.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (51.6 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

numpymaxflow-0.0.4-cp39-cp39-macosx_10_9_x86_64.whl (21.3 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

numpymaxflow-0.0.4-cp38-cp38-win_amd64.whl (25.6 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

numpymaxflow-0.0.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (51.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

numpymaxflow-0.0.4-cp38-cp38-macosx_10_9_x86_64.whl (21.3 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

numpymaxflow-0.0.4-cp37-cp37m-win_amd64.whl (25.3 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

numpymaxflow-0.0.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (51.5 kB view hashes)

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

numpymaxflow-0.0.4-cp37-cp37m-macosx_10_9_x86_64.whl (21.3 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

numpymaxflow-0.0.4-cp36-cp36m-win_amd64.whl (25.3 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

numpymaxflow-0.0.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (51.5 kB view hashes)

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

numpymaxflow-0.0.4-cp36-cp36m-macosx_10_9_x86_64.whl (21.3 kB view hashes)

Uploaded CPython 3.6m 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