pmneila / PyMaxflow

Python library for creating flow networks and computing the maxflow/mincut (aka graph-cuts for Python)
http://pmneila.github.io/PyMaxflow/
246 stars 59 forks source link

energy_of_grid_labeling is not working for list. #58

Closed bejnpenik closed 1 year ago

bejnpenik commented 2 years ago

In function energy_of_grid_labeling from fastmin module (fastmin.py file line 51) instead of:

**binary += V[labels[slice0], labels[slice1]].sum()**

there should probably be:

**binary += V[labels[tuple(slice0)], labels[tuple(slice1)]].sum()**

because currently it is throwing the exception:

IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices

Regards, Branislav

pmneila commented 1 year ago

Hi,

Thank you for letting me know. I just released a new version that fixes this error. You can install it with pip in the usual manner:

python -m pip install --upgrade PyMaxflow

Best