Alpha Expansion Library
C++ library for the Alpha-Expansion graph-cut algorithm with Python bindings
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
AlphaExpansion< T > Class Template Reference

Performs alpha-expansion moves on an EnergyModel using a pluggable max-flow solver. More...

#include <AlphaExpansion.hpp>

Public Types

using SolverFactory = std::function< std::unique_ptr< MaxFlowSolver< T > >(int num_vars, int num_edges)>
 

Public Member Functions

 AlphaExpansion (EnergyModel< T > &model, SolverFactory solver_factory)
 Constructs the optimizer.
 
bool perform_expansion_move (const int alpha_label) const
 Attempts a single alpha-expansion move for alpha_label.
 

Detailed Description

template<typename T>
class AlphaExpansion< T >

Performs alpha-expansion moves on an EnergyModel using a pluggable max-flow solver.

An AlphaExpansion object holds a reference to an EnergyModel and a factory function that creates a new MaxFlowSolver for each expansion move. The model must outlive the optimizer, so do not destroy the model while the optimizer is still being used.

The optimizer is usually driven by an ExpansionStrategy, which decides the order of label expansions and when to stop.

Template Parameters
TNumeric cost type. Must match the type of the associated EnergyModel<T>.

Member Typedef Documentation

◆ SolverFactory

template<typename T >
using AlphaExpansion< T >::SolverFactory = std::function<std::unique_ptr<MaxFlowSolver<T> >(int num_vars, int num_edges)>

Factory function that creates a new solver instance.

Parameters
num_varsNumber of binary variables (active nodes in the expansion subgraph).
num_edgesEstimated number of edges (used for pre-allocation; may be exceeded).

Constructor & Destructor Documentation

◆ AlphaExpansion()

template<typename T >
AlphaExpansion< T >::AlphaExpansion ( EnergyModel< T > &  model,
SolverFactory  solver_factory 
)
inline

Constructs the optimizer.

Parameters
modelEnergy model to optimize. Must outlive this object.
solver_factoryFactory used to create a fresh solver for each expansion move.

Member Function Documentation

◆ perform_expansion_move()

template<typename T >
bool AlphaExpansion< T >::perform_expansion_move ( const int  alpha_label) const
inline

Attempts a single alpha-expansion move for alpha_label.

Builds the binary subgraph for alpha_label and runs max-flow. If the resulting label assignment reduces the total energy, it is applied to the model.

Parameters
alpha_labelThe label to expand (0 ≤ alpha_label < num_labels).
Returns
true if any node's label changed and energy decreased; false otherwise.

The documentation for this class was generated from the following file: