|
Alpha Expansion Library
C++ library for the Alpha-Expansion graph-cut algorithm with Python bindings
|
Abstract interface for a binary max-flow / QPBO solver. More...
#include <MaxFlowSolver.hpp>
Public Types | |
| typedef int | Var |
| Integer handle identifying a binary variable. | |
Public Member Functions | |
| virtual | ~MaxFlowSolver ()=default |
| virtual Var | add_variable ()=0 |
| Introduces a new binary variable and returns its handle. | |
| virtual void | add_constant (T E)=0 |
| Adds a constant term to the energy function. | |
| virtual void | add_term1 (Var x, T E0, T E1)=0 |
| Adds a unary term E(x) where x ∈ {0, 1}. | |
| virtual void | add_term2 (Var x, Var y, T E00, T E01, T E10, T E11)=0 |
| Adds a pairwise term E(x, y) where x, y ∈ {0, 1}. | |
| virtual T | minimize ()=0 |
| Minimizes the energy and returns the minimum value. | |
| virtual int | get_var (Var x)=0 |
Returns the optimal value of variable x (0 or 1) after minimize(). | |
Abstract interface for a binary max-flow / QPBO solver.
Implementations build a binary energy function term by term using add_term1 and add_term2, then minimize it via max-flow.
Built-in implementations: BKSolver (Boykov–Kolmogorov), ORToolsSolver (Google OR-Tools). Implement this interface and add a factory lambda to AlphaExpansion to add a custom solver.
| T | Numeric type for energy values (int32_t, float, or double). |
| typedef int MaxFlowSolver< T >::Var |
Integer handle identifying a binary variable.
|
virtualdefault |
|
pure virtual |
Adds a constant term to the energy function.
| E | Constant to add. |
Implemented in BKSolver< T >, and ORToolsSolver< T >.
|
pure virtual |
Adds a unary term E(x) where x ∈ {0, 1}.
| x | Variable handle. |
| E0 | Energy contribution when x = 0. |
| E1 | Energy contribution when x = 1. |
|
pure virtual |
Adds a pairwise term E(x, y) where x, y ∈ {0, 1}.
The values must satisfy E00 + E11 ≤ E01 + E10 (submodularity requirement).
| x | First variable handle. |
| y | Second variable handle. |
| E00 | Energy when x=0, y=0. |
| E01 | Energy when x=0, y=1. |
| E10 | Energy when x=1, y=0. |
| E11 | Energy when x=1, y=1. |
|
pure virtual |
Introduces a new binary variable and returns its handle.
Implemented in BKSolver< T >, and ORToolsSolver< T >.
|
pure virtual |
Returns the optimal value of variable x (0 or 1) after minimize().
|
pure virtual |
Minimizes the energy and returns the minimum value.
Implemented in BKSolver< T >, and ORToolsSolver< T >.