Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/masadcv/numpymaxflow
Numpy-based implementation of Max-flow/Min-cut (graphcut) for 2D/3D data
https://github.com/masadcv/numpymaxflow
numpy python segmentation
Last synced: 1 day ago
JSON representation
Numpy-based implementation of Max-flow/Min-cut (graphcut) for 2D/3D data
- Host: GitHub
- URL: https://github.com/masadcv/numpymaxflow
- Owner: masadcv
- License: bsd-3-clause
- Created: 2022-04-19T18:53:23.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-30T21:16:25.000Z (16 days ago)
- Last Synced: 2024-11-14T14:11:11.632Z (1 day ago)
- Topics: numpy, python, segmentation
- Language: C++
- Homepage: https://pypi.org/project/numpymaxflow/
- Size: 2.69 MB
- Stars: 2
- Watchers: 1
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# numpymaxflow: Max-flow/Min-cut in numpy for 2D images and 3D volumes
[![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![CI Build](https://github.com/masadcv/numpymaxflow/actions/workflows/build.yml/badge.svg)](https://github.com/masadcv/numpymaxflow/actions/workflows/build.yml)
[![PyPI version](https://badge.fury.io/py/numpymaxflow.svg)](https://badge.fury.io/py/numpymaxflow)
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](https://github.com/masadcv/torchmaxflow)
## 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."](https://openreview.net/pdf?id=9xtE2AgD_Cc) 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](https://raw.githubusercontent.com/masadcv/numpymaxflow/main/figures/numpymaxflow_maxflow2d.png)
Interactive maxflow2d
![./figures/numpymaxflow_intmaxflow2d.png](https://raw.githubusercontent.com/masadcv/numpymaxflow/main/figures/numpymaxflow_intmaxflow2d.png)
![figures/figure_numpymaxflow.png](https://raw.githubusercontent.com/masadcv/numpymaxflow/main/figures/figure_numpymaxflow.png)
## Example usage
The following demonstrates a simple example showing numpymaxflow usage:
```python
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.0post_proc_label = numpymaxflow.maxflow(image, prob, lamda, sigma)
```For more usage examples see:
**2D and 3D maxflow and interactive maxflow examples**: [`demo_maxflow.py`](https://raw.githubusercontent.com/masadcv/numpymaxflow/main/demo_maxflow.py)
## References
- [OpenCV's Graphcut implementation](https://github.com/opencv/opencv/blob/4.x/modules/imgproc/include/opencv2/imgproc/detail/gcgraph.hpp)
- [SimpleCRF's maxflow implementation](https://github.com/HiLab-git/SimpleCRF)
- [torchmaxflow's implementation](https://github.com/masadcv/torchmaxflow)This repository depends on the code for [maxflow from latest version of OpenCV](https://github.com/opencv/opencv/blob/4.x/modules/imgproc/include/opencv2/imgproc/detail/gcgraph.hpp), which has been included.