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

Abstract base class for alpha-expansion iteration strategies. More...

#include <ExpansionStrategy.hpp>

Inheritance diagram for ExpansionStrategy< T >:
[legend]

Public Member Functions

virtual ~ExpansionStrategy ()=default
 
virtual int execute (AlphaExpansion< T > &optimizer, EnergyModel< T > &model) const =0
 Runs the expansion strategy to convergence (or up to a cycle limit).
 

Detailed Description

template<typename T>
class ExpansionStrategy< T >

Abstract base class for alpha-expansion iteration strategies.

A strategy controls the order in which labels are expanded and the stopping condition. The library ships three concrete strategies: SequentialStrategy, GreedyStrategy and RandomizedStrategy. To add a custom strategy, implement this interface.

Template Parameters
TNumeric cost type. Must match the type used in the associated EnergyModel<T>.
Example: custom strategy
template <typename T>
class SinglePassStrategy : public ExpansionStrategy<T> {
public:
int execute(AlphaExpansion<T>& optimizer, EnergyModel<T>& model) const override {
for (int alpha = 0; alpha < model.num_labels(); ++alpha)
optimizer.perform_expansion_move(alpha);
return 1;
}
};
Performs alpha-expansion moves on an EnergyModel using a pluggable max-flow solver.
Definition AlphaExpansion.hpp:20
bool perform_expansion_move(const int alpha_label) const
Attempts a single alpha-expansion move for alpha_label.
Definition AlphaExpansion.hpp:41
Stores the graph and energy costs for the Alpha-Expansion algorithm.
Definition EnergyModel.hpp:17
int num_labels() const
Returns the total number of labels.
Definition EnergyModel.hpp:35
Abstract base class for alpha-expansion iteration strategies.
Definition ExpansionStrategy.hpp:32

Constructor & Destructor Documentation

◆ ~ExpansionStrategy()

template<typename T >
virtual ExpansionStrategy< T >::~ExpansionStrategy ( )
virtualdefault

Member Function Documentation

◆ execute()

template<typename T >
virtual int ExpansionStrategy< T >::execute ( AlphaExpansion< T > &  optimizer,
EnergyModel< T > &  model 
) const
pure virtual

Runs the expansion strategy to convergence (or up to a cycle limit).

Parameters
optimizerThe AlphaExpansion object that executes individual moves.
modelThe energy model being optimized (labels are updated in-place).
Returns
Number of full cycles completed.

Implemented in GreedyStrategy< T >, RandomizedStrategy< T >, and SequentialStrategy< T >.


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