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.7.tar.gz (14.2 kB view details)

Uploaded Source

Built Distributions

numpymaxflow-0.0.7-cp312-cp312-win_amd64.whl (24.9 kB view details)

Uploaded CPython 3.12 Windows x86-64

numpymaxflow-0.0.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (51.7 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

numpymaxflow-0.0.7-cp312-cp312-macosx_11_0_arm64.whl (21.8 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

numpymaxflow-0.0.7-cp311-cp311-win_amd64.whl (24.8 kB view details)

Uploaded CPython 3.11 Windows x86-64

numpymaxflow-0.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (51.7 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

numpymaxflow-0.0.7-cp311-cp311-macosx_11_0_arm64.whl (21.8 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

numpymaxflow-0.0.7-cp310-cp310-win_amd64.whl (24.8 kB view details)

Uploaded CPython 3.10 Windows x86-64

numpymaxflow-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (51.7 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

numpymaxflow-0.0.7-cp310-cp310-macosx_11_0_arm64.whl (21.8 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

numpymaxflow-0.0.7-cp39-cp39-win_amd64.whl (24.8 kB view details)

Uploaded CPython 3.9 Windows x86-64

numpymaxflow-0.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (51.7 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

numpymaxflow-0.0.7-cp39-cp39-macosx_11_0_arm64.whl (21.8 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

File details

Details for the file numpymaxflow-0.0.7.tar.gz.

File metadata

  • Download URL: numpymaxflow-0.0.7.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for numpymaxflow-0.0.7.tar.gz
Algorithm Hash digest
SHA256 a1ca70c90d11ffeaa0ef9f173cf9093f8f0d7f3cd697340544dee01f4577fc34
MD5 a9b24a20f50ff64ce3c3db31ec297374
BLAKE2b-256 740c3c05aae78b7d153798b436bef624c801b2ced964dfdc8ba8c276c806032c

See more details on using hashes here.

File details

Details for the file numpymaxflow-0.0.7-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for numpymaxflow-0.0.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3584ce3b8b68e21811c152c275e5680887b17cc44bd63dc985c000430a50455a
MD5 303cceb2b1369e635c2c95080361e85a
BLAKE2b-256 3dab0c4bed4e74ae76c67d0aa340d4deb5bef14a9d65482a2c105d5c5e4845d0

See more details on using hashes here.

File details

Details for the file numpymaxflow-0.0.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for numpymaxflow-0.0.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 63dda31f1905a9a996796313e3453894415a61a5fd278dc30b18874ed0cd5056
MD5 a7fd9521cc60ba19b2cfc594622ce29d
BLAKE2b-256 8c0be6d82e92cf934ed180959c02fb7a1ff3ca05ca60d1d402727e7f91d70948

See more details on using hashes here.

File details

Details for the file numpymaxflow-0.0.7-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for numpymaxflow-0.0.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 88ed1e5c15e7d63b3dc016d757e0e3df30b5f4396e4d8a327b958918ed0e6a5c
MD5 6d2018c044f95792a7566a0ba0b4cfd7
BLAKE2b-256 6fcc8c27ac16aa21e435d3c0c4af9856627e99d79248da57524b7fefa5cdd248

See more details on using hashes here.

File details

Details for the file numpymaxflow-0.0.7-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for numpymaxflow-0.0.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a98cbc96109844105604d20d51b8a4e0f797b54c720129a0bb757bd5dfb041c7
MD5 eae5d1ae4acb8214b6b31ed63a6a6528
BLAKE2b-256 c194a66c47ac240ba7947e6c9e902b483479f203972f06ebc3f22f7d78691a76

See more details on using hashes here.

File details

Details for the file numpymaxflow-0.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for numpymaxflow-0.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dc651879e9285abb39f2d22a8beb66f94210dbf5169ebe0a5fcc9fc7f000f828
MD5 8f3f7e474f586980c3f95ad6e16e9d39
BLAKE2b-256 e8402e5c098b9e85b04860090fb2d95f73775156ce48b84045a459e18608c816

See more details on using hashes here.

File details

Details for the file numpymaxflow-0.0.7-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for numpymaxflow-0.0.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 887ebe7d1a8473bb94178c5241fa5d11c8e809d90461f2cc8c55dea2b42f5345
MD5 291f45ce7f248a1627ba1718d5f43d1c
BLAKE2b-256 51f98b414ea37fff6513ef1a6fabd4211bf03f845b4cfb6d4ee21cf2dd1436e9

See more details on using hashes here.

File details

Details for the file numpymaxflow-0.0.7-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for numpymaxflow-0.0.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 92aa54f288682d2761a54d54801428e3e852b7957d3742fd539f2027692fe2c2
MD5 e2844b3b4deff6ed41fccb2007bccfec
BLAKE2b-256 e3402c652f5001cb1ded7e75a768e164cc8aee4780ce651137f08ea01b5bd5a3

See more details on using hashes here.

File details

Details for the file numpymaxflow-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for numpymaxflow-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7ad5ad18608da2a1b8707f861b9fd08413743cd322b267c8cc7eb1899b795505
MD5 72b5134ddea1223fdd8208d7376d43e1
BLAKE2b-256 8ed6dcb526b4af2bd07c847d4e439cc528ca1a579ccda41cf0a1d4dbdb0b23ee

See more details on using hashes here.

File details

Details for the file numpymaxflow-0.0.7-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for numpymaxflow-0.0.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d10695076d428480a88303b25da591c3be01a787d9862c09b981b53fd16d17fa
MD5 30786d674d262ae9103bc591696e1ecb
BLAKE2b-256 67b8e070cbd75fb5572a97c7f0f7aee454810d90d0054afa3d770ae4627f163f

See more details on using hashes here.

File details

Details for the file numpymaxflow-0.0.7-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for numpymaxflow-0.0.7-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 3275cab94ac887c75452a9c69249abb9b37138fdb101473ad6e582e28afabe14
MD5 19f080502455b064093cfed90e4482ba
BLAKE2b-256 2c8c9fbadca195219fcc9ad17a32525fcf0cc341b90fa112a2040ea82282b438

See more details on using hashes here.

File details

Details for the file numpymaxflow-0.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for numpymaxflow-0.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ea23e815561e5d05fa610ac2745946f9501a6251a4cd17923ed892a86c0dec67
MD5 52f80098b40904bee8d3de9e5f066017
BLAKE2b-256 8ea655875e227477074bf6c6bdb640b26046e42c40f5a0e2aae9b23e905f2dc4

See more details on using hashes here.

File details

Details for the file numpymaxflow-0.0.7-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for numpymaxflow-0.0.7-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9d1f60096055299259afc12f894f9a331393800a11219aac0d7769f8b9380d1b
MD5 60e1cb54318a1ec1715daf45ae247ba3
BLAKE2b-256 723073de4b631696caf563a08e7877bfad0f479466da5947f63a7b0364ba11d1

See more details on using hashes here.

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