|
Alpha Expansion Library
C++ library for the Alpha-Expansion graph-cut algorithm with Python bindings
|
The Python bindings expose the full C++ API via pybind11. After building, the module is available as alpha_expansion_py inside build/.
You can also add build/ to your PYTHONPATH environment variable so you do not need to do this in every script.
Use the EnergyModel factory. It returns the right typed object based on dtype:
You can also instantiate typed classes directly (ae.EnergyModelInt, ae.EnergyModelFloat or ae.EnergyModelDouble), but the factory is simpler.
Via callbacks (general graphs, community detection):
Via dense arrays (image grids, faster):
Via per-edge weights (Potts model, zero cost for same label and weight otherwise):
Cost priority: per-edge weights > dense arrays > callbacks.
| Class | Description |
|---|---|
EnergyModel | Factory function (preferred) |
EnergyModelInt / Float / Double | Typed energy model classes |
AlphaExpansionInt / Float / Double | Optimizer, ties model to a solver backend |
SequentialStrategyInt / Float / Double | Fixed-order strategy |
GreedyStrategyInt / Float / Double | Best-first strategy |
RandomizedStrategyInt / Float / Double | Random-order strategy |
You can drive the algorithm one move at a time: