<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
On 27/10/2010 02:06, Xiaopeng Yang wrote:
<blockquote cite="mid:008401cb7573$2c99b1f0$85cd15d0$@ac.kr"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<meta name="Generator" content="Microsoft Word 12 (filtered
medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Malgun Gothic";
        panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"\@Malgun Gothic";
        panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.WordSection1
        {page:WordSection1;}
-->
</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Dear Luis,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">How are you doing? Thank you very much for
your help so far.
Sorry to ask you a question again.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I am now developing a liver segmentation
program using QT,
VTK, and ITK based on CT images. In my program, fast marching
algorithm is used
to extract the liver by multiple seed points. To pick the
positions of the seed
points, vtkImagePlaneWidget is applied. The problem is how to
save the multiple
seed points I selected by left-clicking of the mouse so that I
do not need to type
those positions into the code, which is time consuming.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Please provide me with your suggestions. I
working on this
for almost one week still I cannot figure it out.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal">Xiaopeng</p>
</div>
</blockquote>
<br>
Hi Xiaopeng,<br>
<br>
Luis may well have a simpler/better way of doing this, but for what
it's worth in the meantime -- if you know how to access the seed
points in the code, then you can just save/load them the way you'd
save/load anything else. In other words, just use normal C++ file
handling. There's an example below (you'd need to work out what
format your seeds are in and adapt things accordingly).<br>
<br>
There may be a more "ITK/VTK" way of handling this, in which case
you might want to use that instead, but it's perfectly ok to just
use the standard library for things like this.<br>
<br>
Cheers,<br>
Stu<br>
<br>
#include <fstream><br>
#include <iostream><br>
#include <string><br>
<br>
#include <boost/lexical_cast.hpp><br>
<br>
struct Seed<br>
{<br>
int x;<br>
int y;<br>
Seed() : x(0), y(0) {}<br>
Seed(int x_, int y_) : x(x_), y(y_) {}<br>
};<br>
<br>
std::ostream& operator<<(std::ostream& os, const
Seed& rhs)<br>
{<br>
os << rhs.x << ' ' << rhs.y;<br>
return os;<br>
}<br>
<br>
std::istream& operator>>(std::istream& is, Seed&
rhs)<br>
{<br>
char dummy;<br>
is >> rhs.x >> dummy >> rhs.y;<br>
return is;<br>
}<br>
<br>
void output_seeds(const std::string& filename)<br>
{<br>
// More error-handling is needed here, this is just an example.<br>
std::ifstream fs(filename.c_str());<br>
std::string line;<br>
while(std::getline(fs, line))<br>
{<br>
try<br>
{<br>
std::cout << "Seed: " <<
boost::lexical_cast<Seed>(line) << '\n';<br>
}<br>
catch(boost::bad_lexical_cast&) {}<br>
}<br>
}<br>
<br>
void write_seeds(const std::string& filename)<br>
{<br>
std::ofstream fs(filename.c_str());<br>
fs << Seed(23,9) << '\n';<br>
fs << Seed(24,12) << '\n';<br>
}<br>
<br>
int main()<br>
{<br>
write_seeds("seeds.txt");<br>
output_seeds("seeds.txt");<br>
return 0;<br>
}<br>
</body>
</html>