<html><div style='background-color:'><DIV class=RTE>When I run the outputimage is like movingimage and i hope the outputimage like fixedimage I dont know what happend does it?.</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE><FONT color=#ff3300>#include "itkImageRegistrationMethod.h"<BR></FONT><FONT color=#336600>#include "itkMeanSquaresImageToImageMetric.h"</FONT><BR><FONT color=#3333ff>#include "itkBSplineInterpolateImageFunction.h"</FONT><BR>#include "itkImage.h"<BR>#include "itkTimeProbesCollectorBase.h"<BR><FONT color=#660000>#include "itkBSplineDeformableTransform.h"</FONT><BR><FONT color=#ff6600>#include "itkLBFGSBOptimizer.h"</FONT><BR>#include "itkImageFileReader.h"<BR>#include "itkImageFileWriter.h"<BR>#include "itkResampleImageFilter.h"<BR>#include "itkCastImageFilter.h"<BR>#include "itkCommand.h"<BR>#include &lt;fstream&gt;</DIV>
<DIV class=RTE>class CommandIterationUpdate : public itk::Command <BR>{<BR>public:<BR>&nbsp; typedef&nbsp; CommandIterationUpdate&nbsp;&nbsp; Self;<BR>&nbsp; typedef&nbsp; itk::Command&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Superclass;<BR>&nbsp; typedef itk::SmartPointer&lt;Self&gt;&nbsp; Pointer;<BR>&nbsp; itkNewMacro( Self );<BR>protected:<BR>&nbsp; CommandIterationUpdate() {};<BR>&nbsp; std::ofstream m_file;</DIV>
<DIV class=RTE>public:<BR>&nbsp; typedef itk::LBFGSBOptimizer&nbsp;&nbsp;&nbsp;&nbsp; OptimizerType;<BR>&nbsp; typedef&nbsp;&nbsp; const OptimizerType&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp; OptimizerPointer;</DIV>
<DIV class=RTE>&nbsp; void SetFileName(const char* str)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp; try{<BR>&nbsp;&nbsp;&nbsp; m_file.open(str, std::ios::trunc); <BR>&nbsp;&nbsp; }<BR>&nbsp;&nbsp; catch(itk::ExceptionObject &amp; err)<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "ExceptionObject caught !" &lt;&lt; std::endl; <BR>&nbsp;std::cerr &lt;&lt; "Error al tratar de leer el archivo de los valores" &lt;&lt; std::endl; <BR>&nbsp;std::cerr &lt;&lt; err &lt;&lt; std::endl; <BR>&nbsp;&nbsp;&nbsp;&nbsp; };<BR>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV class=RTE><BR>&nbsp; void Execute(itk::Object *caller, const itk::EventObject &amp; event)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Execute( (const itk::Object *)caller, event);<BR>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV class=RTE>&nbsp; void Execute(const itk::Object * object, const itk::EventObject &amp; event)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OptimizerPointer optimizer = <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dynamic_cast&lt; OptimizerPointer &gt;( object );<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( typeid( event ) != typeid( itk::IterationEvent ) )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; optimizer-&gt;GetCurrentIteration() &lt;&lt; "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; optimizer-&gt;GetValue() &lt;&lt; "&nbsp;&nbsp;&nbsp; ";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; optimizer-&gt;GetInfinityNormOfProjectedGradient() &lt;&lt; std::endl;</DIV>
<DIV class=RTE>&nbsp;&nbsp; m_file &lt;&lt; optimizer-&gt;GetCurrentIteration() &lt;&lt; "&nbsp;&nbsp; ";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_file &lt;&lt; optimizer-&gt;GetValue() &lt;&lt; "&nbsp;&nbsp;&nbsp; ";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_file &lt;&lt; optimizer-&gt;GetInfinityNormOfProjectedGradient() &lt;&lt;std::endl;</DIV>
<DIV class=RTE>&nbsp;&nbsp;&nbsp; }<BR>};</DIV>
<DIV class=RTE><BR>int main( int argc, char *argv[] )<BR>{<BR><BR>&nbsp;if( argc &lt; 3 )<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "Missing Parameters " &lt;&lt; std::endl;<BR>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "Usage: " &lt;&lt; argv[0];<BR>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; " fixedImageFile&nbsp; movingImageFile outputImagefile&nbsp; ";<BR>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; " [ValuesField] ";<BR>&nbsp;&nbsp;&nbsp; return 1;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; <BR>&nbsp; <BR>&nbsp; std::cout &lt;&lt; "Inicio del programa " &lt;&lt; std::endl;<BR>&nbsp; const&nbsp;&nbsp;&nbsp; unsigned int&nbsp;&nbsp;&nbsp; ImageDimension = 2;<BR>&nbsp; typedef&nbsp; float&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PixelType;</DIV>
<DIV class=RTE>&nbsp; typedef itk::Image&lt; PixelType, ImageDimension &gt;&nbsp; FixedImageType;<BR>&nbsp; typedef itk::Image&lt; PixelType, ImageDimension &gt;&nbsp; MovingImageType;</DIV>
<DIV class=RTE><BR>&nbsp; const unsigned int SpaceDimension = ImageDimension;<BR>&nbsp; const unsigned int SplineOrder = 3;<BR>&nbsp; typedef double CoordinateRepType;</DIV>
<DIV class=RTE>&nbsp; <FONT color=#660000>typedef itk::BSplineDeformableTransform&lt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CoordinateRepType,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SpaceDimension,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SplineOrder &gt;&nbsp;&nbsp;&nbsp;&nbsp; TransformType;</FONT></DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE><FONT color=#ff6600>&nbsp; typedef itk::LBFGSBOptimizer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OptimizerType;</FONT></DIV>
<DIV class=RTE><BR>&nbsp;<FONT color=#336600> typedef itk::MeanSquaresImageToImageMetric&lt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FixedImageType, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MovingImageType &gt;&nbsp;&nbsp;&nbsp; MetricType;<BR></FONT><BR><FONT color=#3333ff>&nbsp; typedef itk::BSplineInterpolateImageFunction&lt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
MovingImageType,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; double,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; double&gt; InterpolatorType;</FONT></DIV>
<DIV class=RTE><BR><FONT color=#ff3300>&nbsp; typedef itk::ImageRegistrationMethod&lt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FixedImageType, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MovingImageType &gt;&nbsp;&nbsp;&nbsp; RegistrationType;</FONT></DIV>
<DIV class=RTE><FONT color=#336600>&nbsp; MetricType::Pointer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; metric&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = MetricType::New();</FONT><BR><FONT color=#ff6600>&nbsp; OptimizerType::Pointer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; optimizer&nbsp;&nbsp;&nbsp;&nbsp; = OptimizerType::New();</FONT><BR><FONT color=#3333ff>&nbsp; InterpolatorType::Pointer&nbsp;&nbsp; interpolator&nbsp; = InterpolatorType::New();</FONT><BR><FONT color=#ff3300>&nbsp; RegistrationType::Pointer&nbsp;&nbsp; registration&nbsp; = RegistrationType::New();</FONT><BR>&nbsp; <BR><FONT color=#3333ff>&nbsp; interpolator-&gt;SetSplineOrder(SplineOrder);</FONT><BR>&nbsp; <BR><FONT color=#ff3300>&nbsp; registration-&gt;SetMetric(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#336600>metric</FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );</FONT><BR><FONT color=#ff3300>&nbsp; 
registration-&gt;SetOptimizer(&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#ff6600>optimizer&nbsp;</FONT>&nbsp;&nbsp;&nbsp; );</FONT><BR><FONT color=#ff3300>&nbsp; registration-&gt;SetInterpolator(&nbsp; <FONT color=#3333ff>interpolator</FONT>&nbsp; );</FONT></DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>&nbsp; <FONT color=#990000>TransformType::Pointer&nbsp; transform = TransformType::New();<BR></FONT><FONT color=#ff3300>&nbsp; registration-&gt;SetTransform( <FONT color=#990000>transform</FONT> );</FONT></DIV>
<DIV class=RTE><BR>&nbsp; typedef itk::ImageFileReader&lt; FixedImageType&nbsp; &gt; FixedImageReaderType;<BR>&nbsp; typedef itk::ImageFileReader&lt; MovingImageType &gt; MovingImageReaderType;</DIV>
<DIV class=RTE>&nbsp; FixedImageReaderType::Pointer&nbsp; fixedImageReader&nbsp; = FixedImageReaderType::New();<BR>&nbsp; MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New();</DIV>
<DIV class=RTE>&nbsp; fixedImageReader-&gt;SetFileName(&nbsp; argv[1] );<BR>&nbsp; movingImageReader-&gt;SetFileName( argv[2] );</DIV>
<DIV class=RTE>&nbsp; FixedImageType::ConstPointer fixedImage = fixedImageReader-&gt;GetOutput();</DIV>
<DIV class=RTE>&nbsp; <FONT color=#ff3300>registration-&gt;SetFixedImage(&nbsp; fixedImage&nbsp;&nbsp; );<BR></FONT><FONT color=#ff3300>&nbsp; registration-&gt;SetMovingImage(&nbsp;&nbsp; movingImageReader-&gt;GetOutput()&nbsp;&nbsp; );<BR></FONT>&nbsp; try{<BR>&nbsp; fixedImageReader-&gt;Update();<BR>&nbsp; }<BR>&nbsp; catch(itk::ExceptionObject &amp; err)<BR>&nbsp; {<BR>&nbsp;&nbsp; std::cerr&lt;&lt;"Error al leer Archivo"&lt;&lt;std::endl;<BR>&nbsp;&nbsp; std::cerr&lt;&lt;err&lt;&lt;std::endl;<BR>&nbsp;&nbsp; return -1;<BR>&nbsp; }<BR>&nbsp; FixedImageType::RegionType fixedRegion = fixedImage-&gt;GetBufferedRegion();<BR>&nbsp; <BR>&nbsp; registration-&gt;SetFixedImageRegion( fixedRegion );</DIV>
<DIV class=RTE>&nbsp; typedef TransformType::RegionType RegionType;<BR>&nbsp; RegionType bsplineRegion;<BR>&nbsp; RegionType::SizeType&nbsp;&nbsp; gridSizeOnImage;<BR>&nbsp; RegionType::SizeType&nbsp;&nbsp; gridBorderSize;<BR>&nbsp; RegionType::SizeType&nbsp;&nbsp; totalGridSize;</DIV>
<DIV class=RTE>&nbsp; gridSizeOnImage.Fill( 15 );<BR>&nbsp; gridBorderSize.Fill( 3 );&nbsp;&nbsp;&nbsp; // Border for spline order = 3 ( 1 lower, 2 upper )<BR>&nbsp; totalGridSize = gridSizeOnImage + gridBorderSize;</DIV>
<DIV class=RTE>&nbsp; bsplineRegion.SetSize( totalGridSize );</DIV>
<DIV class=RTE>&nbsp; typedef TransformType::SpacingType SpacingType;<BR>&nbsp; SpacingType spacing = fixedImage-&gt;GetSpacing();</DIV>
<DIV class=RTE>&nbsp; typedef TransformType::OriginType OriginType;<BR>&nbsp; OriginType origin = fixedImage-&gt;GetOrigin();;</DIV>
<DIV class=RTE>&nbsp; FixedImageType::SizeType fixedImageSize = fixedRegion.GetSize();</DIV>
<DIV class=RTE>&nbsp; for(unsigned int r=0; r&lt;ImageDimension; r++)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; spacing[r] *= floor( static_cast&lt;double&gt;(fixedImageSize[r] - 1)&nbsp; / <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static_cast&lt;double&gt;(gridSizeOnImage[r] - 1) );<BR>&nbsp;&nbsp;&nbsp; origin[r]&nbsp; -=&nbsp; spacing[r]; <BR>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV class=RTE>&nbsp; <FONT color=#990000>transform-&gt;SetGridSpacing( spacing );<BR>&nbsp; transform-&gt;SetGridOrigin( origin );<BR>&nbsp; transform-&gt;SetGridRegion( bsplineRegion );<BR></FONT>&nbsp; </DIV>
<DIV class=RTE>&nbsp; typedef TransformType::ParametersType&nbsp;&nbsp;&nbsp;&nbsp; ParametersType;</DIV>
<DIV class=RTE>&nbsp; const unsigned int numberOfParameters =<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transform-&gt;GetNumberOfParameters();<BR>&nbsp; <BR>&nbsp; ParametersType parameters( numberOfParameters );</DIV>
<DIV class=RTE>&nbsp; parameters.Fill( 0.0 );</DIV>
<DIV class=RTE>&nbsp; transform-&gt;SetParameters( parameters );</DIV>
<DIV class=RTE>&nbsp; <FONT color=#ff3300>registration-&gt;SetInitialTransformParameters( <FONT color=#990000>transform-&gt;GetParameters()</FONT> );</FONT></DIV>
<DIV class=RTE>&nbsp; <FONT color=#ff6600>OptimizerType::BoundSelectionType boundSelect( <FONT color=#990000>transform-&gt;GetNumberOfParameters() </FONT>);<BR>&nbsp; OptimizerType::BoundValueType upperBound( <FONT color=#990000>transform-&gt;GetNumberOfParameters() </FONT>);<BR>&nbsp; OptimizerType::BoundValueType lowerBound( <FONT color=#990000>transform-&gt;GetNumberOfParameters()</FONT> );</FONT></DIV>
<DIV class=RTE><FONT color=#ff6600>&nbsp; boundSelect.Fill( 0 );<BR>&nbsp; upperBound.Fill( 0.0 );<BR>&nbsp; lowerBound.Fill( 0.0 );</FONT></DIV>
<DIV class=RTE><FONT color=#ff6600>&nbsp; optimizer-&gt;SetBoundSelection( boundSelect );<BR>&nbsp; optimizer-&gt;SetUpperBound( upperBound );<BR>&nbsp; optimizer-&gt;SetLowerBound( lowerBound );</FONT></DIV>
<DIV class=RTE><FONT color=#ff6600>&nbsp; optimizer-&gt;SetCostFunctionConvergenceFactor( 1e+1 );<BR>&nbsp; optimizer-&gt;SetProjectedGradientTolerance( 0.155555 );//1.0<BR>&nbsp; optimizer-&gt;SetMaximumNumberOfIterations( 100 );<BR>&nbsp; optimizer-&gt;SetMaximumNumberOfEvaluations( 500 );<BR>&nbsp; optimizer-&gt;SetMaximumNumberOfCorrections( 12 );<BR>&nbsp; std::cout &lt;&lt; " SetProjectedGradientTolerance 0.155555&nbsp; " &lt;&lt; std::endl;</FONT></DIV>
<DIV class=RTE>&nbsp; CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New();<BR>&nbsp; try{<BR>&nbsp; observer-&gt;SetFileName(argv[4]);<BR>&nbsp; }<BR>&nbsp; catch(itk::ExceptionObject &amp; err)<BR>&nbsp; {<BR>&nbsp;&nbsp; std::cerr &lt;&lt;" Error al leer Archivo "&lt;&lt;std::endl;<BR>&nbsp;&nbsp; std::cerr &lt;&lt;err&lt;&lt;std::endl;<BR>&nbsp; }<BR>&nbsp; optimizer-&gt;AddObserver( itk::IterationEvent(), observer );</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>&nbsp; itk::TimeProbesCollectorBase collector;</DIV>
<DIV class=RTE>&nbsp; std::cout &lt;&lt; std::endl &lt;&lt; "Starting Registration" &lt;&lt; std::endl;<BR>&nbsp; std::cout &lt;&lt; " Iteracion&nbsp; Valor&nbsp;&nbsp; InfinityNormOfProjectedGradient&nbsp; " &lt;&lt; std::endl;</DIV>
<DIV class=RTE>&nbsp; try <BR>&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp; collector.Start( "Registration" );<BR>&nbsp;&nbsp;&nbsp; <FONT color=#ff3300>registration-&gt;StartRegistration(); <BR></FONT>&nbsp;&nbsp;&nbsp; collector.Stop( "Registration" );<BR>&nbsp;&nbsp;&nbsp; } <BR>&nbsp; catch( itk::ExceptionObject &amp; err ) <BR>&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "ExceptionObject caught !" &lt;&lt; std::endl; <BR>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; err &lt;&lt; std::endl; <BR>&nbsp;&nbsp;&nbsp; return -1;<BR>&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; collector.Report();<BR>&nbsp; <BR>&nbsp; OptimizerType::ParametersType finalParameters = <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; registration-&gt;GetLastTransformParameters();</DIV>
<DIV class=RTE>&nbsp; <FONT color=#990000>transform-&gt;SetParameters( finalParameters );</FONT></DIV>
<DIV class=RTE>&nbsp; typedef itk::ResampleImageFilter&lt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MovingImageType, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FixedImageType&gt;&nbsp;&nbsp;&nbsp; ResampleFilterType;</DIV>
<DIV class=RTE>&nbsp; ResampleFilterType::Pointer resample = ResampleFilterType::New();<BR>&nbsp; <BR>&nbsp; resample-&gt;SetTransform( <FONT color=#990000>transform</FONT> );<BR>&nbsp; resample-&gt;SetInput( movingImageReader-&gt;GetOutput() );<BR>&nbsp; resample-&gt;SetInterpolator(<FONT color=#3333ff>interpolator</FONT>);<BR>&nbsp; resample-&gt;SetSize(&nbsp;&nbsp;&nbsp; fixedImage-&gt;GetLargestPossibleRegion().GetSize() );<BR>&nbsp; resample-&gt;SetOutputOrigin(&nbsp; fixedImage-&gt;GetOrigin() );<BR>&nbsp; resample-&gt;SetOutputSpacing( fixedImage-&gt;GetSpacing() );<BR>&nbsp; resample-&gt;SetDefaultPixelValue( 100 );<BR>&nbsp; <BR>&nbsp; typedef&nbsp; unsigned char&nbsp; OutputPixelType;</DIV>
<DIV class=RTE>&nbsp; typedef itk::Image&lt; OutputPixelType, ImageDimension &gt; OutputImageType;<BR>&nbsp; <BR>&nbsp; typedef itk::CastImageFilter&lt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FixedImageType,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OutputImageType &gt; CastFilterType;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp; typedef itk::ImageFileWriter&lt; OutputImageType &gt;&nbsp; WriterType;</DIV>
<DIV class=RTE><BR>&nbsp; WriterType::Pointer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writer =&nbsp; WriterType::New();<BR>&nbsp; CastFilterType::Pointer&nbsp; caster =&nbsp; CastFilterType::New();</DIV>
<DIV class=RTE><BR>&nbsp; writer-&gt;SetFileName( argv[3] );</DIV>
<DIV class=RTE><BR>&nbsp; caster-&gt;SetInput( resample-&gt;GetOutput() );<BR>&nbsp; writer-&gt;SetInput( caster-&gt;GetOutput()&nbsp;&nbsp; );</DIV>
<DIV class=RTE>&nbsp; std::cout &lt;&lt; "Creando Imagen De Salida ..." &lt;&lt; std::endl;<BR>&nbsp; try<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; writer-&gt;Update();<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; catch( itk::ExceptionObject &amp; err ) <BR>&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "ExceptionObject caught !" &lt;&lt; std::endl; <BR>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; err &lt;&lt; std::endl; <BR>&nbsp;&nbsp;&nbsp; return -1;<BR>&nbsp;&nbsp;&nbsp; }  std::cout &lt;&lt; "El programa termino satisfactoriamente" &lt;&lt; std::endl;<BR>&nbsp; return 0;<BR>}<BR></DIV></div><br clear=all><hr>Visita MSN Latino Noticias: Todo lo que pasa en el mundo y en tu país, ¡en tu idioma! <a href="http://g.msn.com/8HMBESUS/2731??PS=47575" target="_top">Clic aquí</a> </html>