<div class="gmail_quote">On Tue, Sep 1, 2009 at 1:56 PM, Nicholas Tustison <span dir="ltr"><<a href="mailto:ntustison@gmail.com">ntustison@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style="word-wrap: break-word;"><div>Hi David,</div><div><br></div><div>You are going to have to write a MeshToGraphFilter as I never thought to perform graph cuts on a mesh. Let me know if you have any questions.</div>
<div><br></div><div>Good luck,</div><div>Nick</div><div><br></div><div></div></div></blockquote><div><br>Hi Nick,<br><br>I've seen graph cuts on a mesh a few times point cloud segmentation - it will be straight forward to convert a mesh into a graph, as a mesh is already a graph! I'll post the filter on the IJ when it's working.<br>
<br>I have a question about the usage of your existing tools, though. The example that shipped with the IJ paper is very involved. I tried to extract the simplest example possible - I created 2 nodes, put 3 edges between them, each of weight 2, and I would expect the cut to tell me that node 0 is in one set and node 1 is in the second set, and the cut weight is 6. How would I get those pieces of information? <br>
<br>Right now, when I run the cut filter, number of nodes stays at 2, but the number of edges goes from 3 to 5!?<br><br>Here is the example:<br><br>#include <iostream><br>
<br>
#include "itkGraph.h"<br>
#include "itkBoykovGraphTraits.h"<br>
#include "itkBoykovMinCutGraphFilter.h"<br>
<br>
int main( int argc, char * argv[] )<br>
{<br>
typedef itk::BoykovGraphTraits<short, 3> GraphTraitsType;<br>
<br>
typedef itk::Graph<GraphTraitsType> GraphType;<br>
GraphType::Pointer graph = GraphType::New();<br>
graph->DebugOn();<br>
<br>
typedef GraphType::NodeType NodeType;<br>
typedef GraphType::EdgeType EdgeType;<br>
typedef GraphType::NodePointerType NodePointerType;<br>
typedef GraphType::EdgePointerType EdgePointerType;<br>
<br>
<br>
// Create graph<br>
NodePointerType Nodes[2];<br>
//EdgePointerType Edges[3];<br>
<br>
for( unsigned int i = 0; i < 2; i++ )<br>
{<br>
graph->CreateNewNode( 2 );<br>
}<br>
<br>
for( unsigned int i = 0; i < 2; i++ )<br>
{<br>
Nodes[i] = graph->GetNodePointer( i );<br>
}<br>
<br>
//create three edges between nodes 0 and 1, each with weight 2<br>
graph->CreateNewEdge( Nodes[0], Nodes[1], 2 );<br>
graph->CreateNewEdge( Nodes[0], Nodes[1], 2 );<br>
graph->CreateNewEdge( Nodes[0], Nodes[1], 2 );<br>
<br>
/*<br>
for( unsigned int i = 0; i < 3; i++ )<br>
{<br>
Edges[i] = graph->GetEdgePointer( i );<br>
}<br>
*/<br>
/** Set the reverse edges */<br>
graph->SetAllReverseEdges();<br>
<br>
std::cout << "Input graph" << std::endl << " --------- " << std::endl;<br>
std::cout << "Total number of nodes: "<br>
<< graph->GetTotalNumberOfNodes() << std::endl;<br>
std::cout << "Total number of edges: "<br>
<< graph->GetTotalNumberOfEdges() << std::endl;<br>
<br>
typedef itk::BoykovMinCutGraphFilter <GraphType> FilterType;<br>
FilterType::Pointer filter = FilterType::New();<br>
filter->SetInput(graph);<br>
filter->Update();<br>
<br>
<br>
std::cout << "Output graph" << std::endl << " --------- " << std::endl;<br>
std::cout << "Total number of nodes: "<br>
<< graph->GetTotalNumberOfNodes() << std::endl;<br>
std::cout << "Total number of edges: "<br>
<< graph->GetTotalNumberOfEdges() << std::endl;<br>
<b><br>//how would I see which edges are cut? (and hence be able to see the weight of the cut?)<br><br>//how would I see which vertices are in set 0 and set 1?</b><br><br><br>
return EXIT_SUCCESS;<br>
}<br>
<br>Any help would be great.<br><br clear="all">Thanks!<br><br>David<br></div></div>