I am trying to use the Boost Graph Library to use a graph cut in a two-dimensional image. My goal is to represent each pixel as a node with 4 float edges (less at the borders). The pixel neighborhood of the pixels will have a value depending on the gradient or intensity, or something else.
For this, I tried to use boost :: grid_graph with boost :: boykov_kolmogorov_max_flow (), without success. Doc says grid_graph models the โVertex Listโ, โBorder Listโ and โIncident Graphโ, which are requirements for boykov_kolmogorov_max_flow, so I think it should work.
Here is my code:
const unsigned int D = 2; typedef boost::grid_graph<D> Graph; typedef boost::graph_traits<Graph>::vertex_descriptor VertexDescriptor; boost::array<unsigned int, D> lengths = { { 3, 3 } }; Graph graph(lengths, false);
I know that s and t must be initialized, but I want the program to compile. Is it possible to use grid_graph with boykov_kolmogorov_max_flow? If so, how? If not, then I probably have to use a more general (and probably slower) boost :: adjacency_list? Thanks.
source share