【发布时间】:2014-04-22 16:02:22
【问题描述】:
我的 boost 图形库有问题。
在初始化步骤,我想在这个邻接图中存储一个图像:
typedef boost::adjacency_list<boost::vecS,
boost::vecS,
boost::undirectedS,
boost::property<boost::vertex_bundle_t, unsigned int>,
boost::property<boost::edge_bundle_t, float>,
boost::no_property> GraphType
我做了第一个循环,为图像的每个像素创建一个顶点(使用 OTB 库处理图像,in_iter 只是图像像素上的迭代器):
unsigned long int curr_id = 0;
for(in_iter.GoToBegin(); !in_iter.IsAtEnd(); ++in_iter)
{
boost::add_vertex(curr_id, *_graph);
curr_id++;
}
现在我想为一个顶点创建它与其邻居的连接(4 个连接): 我试过了,但它不起作用:
curr_id = 0;
long int neighbors[4];
auto iterBounds = boost::vertices(*_graph);
for(auto v_iter = iterBounds.first; v_iter != iterBounds.second; v_iter++)
{
FindNeighboring(curr_id, neighbors, rows, cols);
for(short j = 0; j<4; j++)
{
if(neighbors[j] > -1)
{
boost::add_vertex(*_graph->m_vertices[curr_id],
*_graph->m_vertices[neighbors[j]],
std::numeric_limits<float>::max();
*_graph);
}
}
}
我想访问知道其位置的顶点描述符。 是否可以在 BGL 中做到这一点?
感谢您的帮助!
【问题讨论】:
标签: c++ image-processing boost-graph