<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:12pt"><div style="font-family: arial,helvetica,sans-serif; font-size: 12pt;"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div style="font-family: arial,helvetica,sans-serif; font-size: 12pt;"><div>Hi<br>I use it in this form (but in ASCII form).<br>Regards<br>Alireza<br><br style="font-weight: bold;"><span style="font-weight: bold;">#include <fstream> </span><br style="font-weight: bold;"><br><br>class CommandIterationUpdate : public itk::Command<br>{<br>public:<br> typedef CommandIterationUpdate Self;<br> typedef itk::Command Superclass;<br> typedef itk::SmartPointer<Self> Pointer;<br>
itkNewMacro( Self );<br> <span style="font-weight: bold;"> std::ofstream out;</span><br><br><br><br>protected:<br> <span style="font-weight: bold;"> CommandIterationUpdate()
{out.open("results.bin",std::ios_base::binary);};</span><br style="font-weight: bold;"><span style="font-weight: bold;"> ~CommandIterationUpdate() {out.close();};</span><br>public:<br> typedef itk::PowellOptimizer OptimizerType;<br> typedef const OptimizerType * OptimizerPointer;<br> void Execute(itk::Object *caller, const itk::EventObject & event)<br> {<br> Execute( (const itk::Object *)caller, event);<br> }<br> void Execute(const itk::Object * object, const itk::EventObject & event)<br> {<br> OptimizerPointer optimizer =dynamic_cast< OptimizerPointer >( object );<br> if( !
itk::IterationEvent().CheckEvent( &event ) )<br> {<br> return;<br> }<br> std::cout << optimizer->GetValue() << " ";<br><span style="font-weight: bold;"> out << optimizer->GetValue() << " ";</span><br> std::cout << optimizer->GetCurrentPosition() << std::endl;<br><span style="font-weight: bold;"> out << optimizer->GetCurrentPosition() << std::endl;</span><br> }<br>};<br><br><br>int main( int argc, char *argv[] )<br>{<br><br>.<br>.<br>.<br> CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New();<br> optimizer->AddObserver(
itk::IterationEvent(), observer );<br>.<br>.<br>.<br> std::cout << "final registration of all labels: " << optimizer->GetValue() << " " <<registration->GetLastTransformParameters() << std::endl;<br> <span style="font-weight: bold;"> observer->out << "final registration of all labels: " << optimizer->GetValue() << " " << registration->GetLastTransformParameters() << std::endl;</span><br><br>.<br>.<br>.<br>}<br></div><div style="font-family: arial,helvetica,sans-serif; font-size: 12pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Paolo <img-registration@live.com><br>To: insight-users@itk.org<br>Sent: Monday, September 29, 2008 6:20:01 AM<br>Subject: [Insight-users] Save data in binary file format in
CommandIterationUpdate class<br><br>
<style>
.hmmessage P
{
margin:0px;padding:0px;}
body.hmmessage
{
FONT-SIZE:10pt;FONT-FAMILY:Tahoma;}
</style>
<div style="text-align: left;">Hello,<br> as in examples, I implemented a CommandIterationUpdate class for tracking on screen the registration process.<br>I actually modifying my code in such a way I could provide a filename to the constructor in order to binary store the different values of the registration process at each execute call. Does someone have an idea how to do it ? I've been unsuccessful doing it until now.. :(<br><br>Thx in advance ! P.</div></div></div></div><br>
</div></div></div><br>
</body></html>