<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi David,<div><br></div><div>Okay, it's been quite awhile since I've looked at the code but I think I can provide you with a little bit of direction. &nbsp;If you look in the Initialize() function (the lines in question are 198-205 in my copy), you'll see that Boykov's min-cut algorithm adds 2 edges to the output graph, i.e. the "terminal edge" and the "orphan edge". Also, if I remember correctly, what you do is iterate through the nodes in the graph and inspect &nbsp;the boolean variable "IsSink" which will be either true (sink node) or false (source node). &nbsp;Also, the class variable m_MaxFlow should hold the weight of the min cut. &nbsp;Simply call GetMaxFlow().</div><div><br></div><div>Nick &nbsp;&nbsp;</div><div><br></div><div><br></div><div><br><div><div>On Sep 1, 2009, at 3:27 PM, David Doria wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote">On Tue, Sep 1, 2009 at 1:56 PM, Nicholas Tustison <span dir="ltr">&lt;<a href="mailto:ntustison@gmail.com">ntustison@gmail.com</a>&gt;</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. &nbsp;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 &lt;iostream&gt;<br>
<br>
#include "itkGraph.h"<br>
#include "itkBoykovGraphTraits.h"<br>
#include "itkBoykovMinCutGraphFilter.h"<br>
<br>
int main( int argc, char * argv[] )<br>
{<br>
&nbsp; typedef itk::BoykovGraphTraits&lt;short, 3&gt; GraphTraitsType;<br>
<br>
&nbsp; typedef itk::Graph&lt;GraphTraitsType&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GraphType;<br>
&nbsp; GraphType::Pointer graph = GraphType::New();<br>
&nbsp; graph-&gt;DebugOn();<br>
<br>
&nbsp; typedef GraphType::NodeType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NodeType;<br>
&nbsp; typedef GraphType::EdgeType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EdgeType;<br>
&nbsp; typedef GraphType::NodePointerType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NodePointerType;<br>
&nbsp; typedef GraphType::EdgePointerType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EdgePointerType;<br>
<br>
&nbsp; <br>
&nbsp; // Create graph<br>
&nbsp; NodePointerType Nodes[2];<br>
&nbsp; //EdgePointerType Edges[3];<br>
<br>
&nbsp; for( unsigned int i = 0; i &lt; 2; i++ )<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; graph-&gt;CreateNewNode( 2 );<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;<br>
&nbsp; for( unsigned int i = 0; i &lt; 2; i++ )<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; Nodes[i] = graph-&gt;GetNodePointer( i );<br>
&nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;//create three edges between nodes 0 and 1, each with weight 2<br>
&nbsp; graph-&gt;CreateNewEdge( Nodes[0], Nodes[1], 2 );<br>
&nbsp; graph-&gt;CreateNewEdge( Nodes[0], Nodes[1], 2 );<br>
&nbsp; graph-&gt;CreateNewEdge( Nodes[0], Nodes[1], 2 );<br>
&nbsp; <br>
&nbsp; /*<br>
&nbsp; for( unsigned int i = 0; i &lt; 3; i++ )<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; Edges[i] = graph-&gt;GetEdgePointer( i );<br>
&nbsp;&nbsp;&nbsp; }<br>
*/<br>
&nbsp; /** Set the reverse edges */<br>
&nbsp; graph-&gt;SetAllReverseEdges();<br>
<br>
&nbsp; std::cout &lt;&lt; "Input graph" &lt;&lt; std::endl &lt;&lt; " --------- " &lt;&lt; std::endl;<br>
&nbsp; std::cout &lt;&lt; "Total number of nodes: "<br>
&nbsp;&nbsp;&nbsp; &lt;&lt; graph-&gt;GetTotalNumberOfNodes() &lt;&lt; std::endl;<br>
&nbsp; std::cout &lt;&lt; "Total number of edges: "<br>
&nbsp;&nbsp;&nbsp; &lt;&lt; graph-&gt;GetTotalNumberOfEdges() &lt;&lt; std::endl;<br>
<br>
&nbsp; typedef itk::BoykovMinCutGraphFilter&nbsp; &lt;GraphType&gt; FilterType;<br>
&nbsp; FilterType::Pointer filter = FilterType::New();<br>
&nbsp; filter-&gt;SetInput(graph);<br>
&nbsp;&nbsp;&nbsp; filter-&gt;Update();<br>
&nbsp; <br>
&nbsp; <br>
&nbsp; std::cout &lt;&lt; "Output graph" &lt;&lt; std::endl &lt;&lt; " --------- " &lt;&lt; std::endl;<br>
&nbsp; std::cout &lt;&lt; "Total number of nodes: "<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &lt;&lt; graph-&gt;GetTotalNumberOfNodes() &lt;&lt; std::endl;<br>
&nbsp; std::cout &lt;&lt; "Total number of edges: "<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &lt;&lt; graph-&gt;GetTotalNumberOfEdges() &lt;&lt; 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>
&nbsp; return EXIT_SUCCESS;<br>
}<br>
<br>Any help would be great.<br><br clear="all">Thanks!<br><br>David<br></div></div>
_____________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://www.itk.org/mailman/listinfo/insight-users<br></blockquote></div><br></div></body></html>