pmneila / PyMaxflow

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

It would be very helpful to add examples for maxflow.fastmin module... #24

Open hellokenlee opened 8 years ago

hellokenlee commented 8 years ago

Thank you so much for writing this package! The documentation is great in the maxflow part. But it's a little confusing in the maxflow.fastmin part... It would be great if you can improve the documentation on this part. Thank you again.

CrisDamian commented 6 years ago

I made a minimal example Here. Hope it helps.

zhangwenyuan0926 commented 4 years ago

Hi! I have a question about the 2-D matrix V. In the example you provided, the values of V are the same for all pixels. But sometimes, for different pixels, the neighborhood cost should be different, and I think that each pixel in an image should be corresponding to a V. are the values of V fixed for all pixels in this module?

pmneila commented 4 years ago

Hi @zhangwenyuan0926,

are the values of V fixed for all pixels in this module?

Unfortunately yes, they are fixed. I wrote the fastmin module a long time ago and I didn't keep it updated with the rest of the API. The good news is that the C++ implementations for aexpansion_grid_step and abswap_grid_step are unnecessary now, and they can be easily implemented in Python with the new API (or so I want to believe). I am planning to update this in the future and get rid of the old C++ fastmin implementation.

In the meantime, you can just reuse the implementation of aexpansion_grid (or abswap_grid) from fastmin.py and write your own aexpansion_grid_step (or abswap_grid_step) that builds the graph using the neighborhood costs you want.

Sorry for the inconvenience. I will fix this as soon as I have time.