<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">This is the error I get: <br><br>Building CXX object CMakeFiles/ImageRegistration1.dir/ImageRegistration1.o<br>Linking CXX executable ImageRegistration1<br>CMakeFiles/ImageRegistration1.dir/ImageRegistration1.o: In function `itk::ObjectFactory&lt;itk::Statistics::DenseFrequencyContainer&gt;::Create()':<br>ImageRegistration1.cxx:(.text._ZN3itk13ObjectFactoryINS_10Statistics23DenseFrequencyContainerEE6CreateEv[itk::ObjectFactory&lt;itk::Statistics::DenseFrequencyContainer&gt;::Create()]+0x8): undefined reference to `typeinfo for itk::Statistics::DenseFrequencyContainer'<br>ImageRegistration1.cxx:(.text._ZN3itk13ObjectFactoryINS_10Statistics23DenseFrequencyContainerEE6CreateEv[itk::ObjectFactory&lt;itk::Statistics::DenseFrequencyContainer&gt;::Create()]+0x55): undefined reference to `typeinfo for
 itk::Statistics::DenseFrequencyContainer'<br>CMakeFiles/ImageRegistration1..dir/ImageRegistration1.o: In function `itk::Statistics::Histogram&lt;float, 1u, itk::Statistics::DenseFrequencyContainer&gt;::SetToZero()':<br>ImageRegistration1.cxx:(.text._ZN3itk10Statistics9HistogramIfLj1ENS0_23DenseFrequencyContainerEE9SetToZeroEv[itk::Statistics::Histogram&lt;float, 1u, itk::Statistics::DenseFrequencyContainer&gt;::SetToZero()]+0x18): undefined reference to `itk::Statistics::DenseFrequencyContainer::SetToZero()'<br>CMakeFiles/ImageRegistration1.dir/ImageRegistration1.o: In function `itk::Statistics::Histogram&lt;float, 1u, itk::Statistics::DenseFrequencyContainer&gt;::Initialize(itk::Size&lt;1u&gt; const&amp;)':<br>ImageRegistration1.cxx:(.text.._ZN3itk10Statistics9HistogramIfLj1ENS0_23DenseFrequencyContainerEE10InitializeERKNS_4SizeILj1EEE[itk::Statistics::Histogram&lt;float, 1u, itk::Statistics::DenseFrequencyContainer&gt;::Initialize(itk::Size&lt;1u&gt;
 const&amp;)]+0x236): undefined reference to `itk::Statistics::DenseFrequencyContainer::Initialize(unsigned long)'<br>CMakeFiles/ImageRegistration1.dir/ImageRegistration1.o: In function `itk::Statistics::Histogram&lt;float, 1u, itk::Statistics::DenseFrequencyContainer&gt;::IncreaseFrequency(unsigned long const&amp;, float)':<br>ImageRegistration1.cxx:(.text._ZN3itk10Statistics9HistogramIfLj1ENS0_23DenseFrequencyContainerEE17IncreaseFrequencyERKmf[itk::Statistics::Histogram&lt;float, 1u, itk::Statistics::DenseFrequencyContainer&gt;::IncreaseFrequency(unsigned long const&amp;, float)]+0x2b): undefined reference to `itk::Statistics::DenseFrequencyContainer::IncreaseFrequency(unsigned long, float)'<br>CMakeFiles/ImageRegistration1.dir/ImageRegistration1.o: In function `itk::Statistics::Histogram&lt;float, 1u, itk::Statistics::DenseFrequencyContainer&gt;::GetFrequency(unsigned long const&amp;)
 const':<br>ImageRegistration1.cxx:(.text._ZNK3itk10Statistics9HistogramIfLj1ENS0_23DenseFrequencyContainerEE12GetFrequencyERKm[itk::Statistics::Histogram&lt;float, 1u, itk::Statistics::DenseFrequencyContainer&gt;::GetFrequency(unsigned long const&amp;) const]+0x22): undefined reference to `itk::Statistics::DenseFrequencyContainer::GetFrequency(unsigned long) const'<br>CMakeFiles/ImageRegistration1.dir/ImageRegistration1.o: In function `itk::Statistics::DenseFrequencyContainer::New()':<br>ImageRegistration1.cxx:(.text._ZN3itk10Statistics23DenseFrequencyContainer3NewEv[itk::Statistics::DenseFrequencyContainer::New()]+0x3f): undefined reference to `itk::Statistics::DenseFrequencyContainer::DenseFrequencyContainer()'<br>collect2: ld returned 1 exit status<br>make[2]: *** [ImageRegistration1] Error 1<br>make[1]: *** [CMakeFiles/ImageRegistration1.dir/all] Error 2<br>make: *** [all] Error 2<br><br><br>Thanks,<br>Sarah<br><br>--- On <b>Mon, 10/5/09, Gabriele
 Arnulfo <i>&lt;tartuz@gmail.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Gabriele Arnulfo &lt;tartuz@gmail.com&gt;<br>Subject: Re: [Insight-users] Fw:  problem<br>To: "Sarah Waldron" &lt;sarah.waldron11@yahoo..com&gt;<br>Cc: insight-users@itk.org<br>Date: Monday, October 5, 2009, 2:51 PM<br><br><div class="plainMail">Hi Sarah,<br><br>&gt;The code performs a linking error.<br><br>try to paste here the error that occurs with your code, maybe you can<br>receive better answer.<br><br><br><br>On Mon, Oct 05, 2009 at 07:21:13AM -0700, Sarah Waldron wrote:<br>&gt; Did everyone get this email? I'm not getting any response from anyone<br>&gt; Thanks<br>&gt; <br>&gt; <a ymailto="mailto:insight-users@itk.org" href="/mc/compose?to=insight-users@itk.org">insight-users@itk.org</a><br>&gt; <br>&gt; --- On Fri, 10/2/09, Sarah Waldron &lt;<a ymailto="mailto:sarah.waldron11@yahoo..com"
 href="/mc/compose?to=sarah.waldron11@yahoo.com">sarah.waldron11@yahoo.com</a>&gt; wrote:<br>&gt; <br>&gt; From: Sarah Waldron &lt;<a ymailto="mailto:sarah.waldron11@yahoo.com" href="/mc/compose?to=sarah.waldron11@yahoo.com">sarah.waldron11@yahoo.com</a>&gt;<br>&gt; Subject: [Insight-users] problem<br>&gt; To: <a ymailto="mailto:insight-users@itk.org" href="/mc/compose?to=insight-users@itk.org">insight-users@itk.org</a><br>&gt; Date: Friday, October 2, 2009, 6:01 PM<br>&gt; <br>&gt; Hi ,<br>&gt; Im new to ITK and I'm having some trouble with this program I'm writing. I want the program to perform rigid registration (translation only) but perform histogram matching first. The code performs a linking error. I've attached the *..cxx and cmakelists file. <br>&gt; Thanks,<br>&gt; Sarah<br>&gt; <br>&gt; <br>&gt; <br>&gt; <br>&gt; <br>&gt;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;<br>&gt; -----Inline Attachment Follows-----<br>&gt; <br>&gt;
 _____________________________________<br>&gt; Powered by www.kitware.com<br>&gt; <br>&gt; Visit other Kitware open-source projects at<br>&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>&gt; <br>&gt; Please keep messages on-topic and check the ITK FAQ at: <a href="http://www.itk..org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>&gt; <br>&gt; Follow this link to subscribe/unsubscribe:<br>&gt; <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>&gt; <br>&gt; <br>&gt; <br>&gt;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;<br>&gt; #include "itkImageRegistrationMethod.h"<br>&gt; #include "itkTranslationTransform.h"<br>&gt; #include "itkMeanSquaresImageToImageMetric.h"<br>&gt; #include "itkLinearInterpolateImageFunction.h"<br>&gt; #include
 "itkRegularStepGradientDescentOptimizer.h"<br>&gt; #include "itkImage.h"<br>&gt; #include "itkImageFileReader.h"<br>&gt; #include "itkImageFileWriter..h"<br>&gt; #include "itkResampleImageFilter.h"<br>&gt; #include "itkCastImageFilter.h"<br>&gt; #include "itkRescaleIntensityImageFilter.h"<br>&gt; #include "itkSubtractImageFilter.h"<br>&gt; #include "itkHistogramMatchingImageFilter.h"<br>&gt; <br>&gt; <br>&gt; <br>&gt; class CommandIterationUpdate : public itk::Command <br>&gt; {<br>&gt; public:<br>&gt;&nbsp;&nbsp;&nbsp;typedef&nbsp; CommandIterationUpdate&nbsp;&nbsp;&nbsp;Self;<br>&gt;&nbsp;&nbsp;&nbsp;typedef&nbsp; itk::Command&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;Superclass;<br>&gt;&nbsp;&nbsp;&nbsp;typedef itk::SmartPointer&lt;Self&gt;&nbsp; Pointer;<br>&gt;&nbsp;&nbsp;&nbsp;itkNewMacro( Self );<br>&gt; <br>&gt; protected:<br>&gt;&nbsp;&nbsp;&nbsp;CommandIterationUpdate() {};<br>&gt; <br>&gt; public:<br>&gt;
 <br>&gt;&nbsp;&nbsp;&nbsp;typedef itk::RegularStepGradientDescentOptimizer&nbsp; &nbsp;&nbsp;&nbsp;OptimizerType;<br>&gt;&nbsp;&nbsp;&nbsp;typedef const OptimizerType&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;*OptimizerPointer;<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;void Execute(itk::Object *caller, const itk::EventObject &amp; event)<br>&gt;&nbsp;&nbsp;&nbsp;{<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;Execute( (const itk::Object *)caller, event);<br>&gt;&nbsp;&nbsp;&nbsp;}<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;void Execute(const itk::Object * object, const itk::EventObject &amp; event)<br>&gt;&nbsp;&nbsp;&nbsp;{<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;OptimizerPointer optimizer = <br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dynamic_cast&lt; OptimizerPointer &gt;( object );<br>&gt; <br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;if( ! itk::IterationEvent().CheckEvent( &amp;event )
 )<br>&gt;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;{<br>&gt;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;return;<br>&gt;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;}<br>&gt; <br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;std::cout &lt;&lt; optimizer-&gt;GetCurrentIteration() &lt;&lt; " = ";<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;std::cout &lt;&lt; optimizer-&gt;GetValue() &lt;&lt; " : ";<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;std::cout &lt;&lt; optimizer-&gt;GetCurrentPosition() &lt;&lt; std::endl;<br>&gt;&nbsp;&nbsp;&nbsp;}<br>&gt;&nbsp; &nbsp; <br>&gt; };<br>&gt; <br>&gt; <br>&gt; int main( int argc, char *argv[] )<br>&gt; {<br>&gt;&nbsp;&nbsp;&nbsp;if( argc &lt; 4 )<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;{<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;std::cerr &lt;&lt; "Missing Parameters " &lt;&lt; std::endl;<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;std::cerr &lt;&lt; "Usage: " &lt;&lt; argv[0];<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;std::cerr &lt;&lt; " fixedImageFile&nbsp; movingImageFile ";<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;std::cerr &lt;&lt;
 "outputImagefile [differenceImageAfter]";<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;std::cerr &lt;&lt; "[differenceImageBefore]" &lt;&lt; std::endl;<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;return EXIT_FAILURE;<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;}<br>&gt;&nbsp;&nbsp;&nbsp;<br>&gt;&nbsp;&nbsp;&nbsp;const&nbsp; &nbsp; unsigned int&nbsp; &nbsp; Dimension = 2;<br>&gt;&nbsp;&nbsp;&nbsp;typedef&nbsp; unsigned int&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;PixelType;<br>&gt;&nbsp;&nbsp;&nbsp;typedef itk::Image&lt; PixelType, Dimension &gt;&nbsp; FixedImageType;<br>&gt;&nbsp;&nbsp;&nbsp;typedef itk::Image&lt; PixelType, Dimension &gt;&nbsp; MovingImageType;<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;typedef itk::ImageFileReader&lt; FixedImageType&nbsp; &gt; FixedImageReaderType;<br>&gt;&nbsp;&nbsp;&nbsp;typedef itk::ImageFileReader&lt; MovingImageType &gt; MovingImageReaderType;<br>&gt;&nbsp;&nbsp;&nbsp;FixedImageReaderType::Pointer&nbsp; fixedImageReader&nbsp; =
 FixedImageReaderType::New();<br>&gt;&nbsp;&nbsp;&nbsp;MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New();<br>&gt;&nbsp;&nbsp;&nbsp;fixedImageReader-&gt;SetFileName(&nbsp; argv[1] );<br>&gt;&nbsp;&nbsp;&nbsp;movingImageReader-&gt;SetFileName( argv[2] );<br>&gt;&nbsp;&nbsp;&nbsp;fixedImageReader-&gt;Update();<br>&gt;&nbsp;&nbsp;&nbsp;movingImageReader-&gt;Update();<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;typedef float InternalPixelType;<br>&gt;&nbsp;&nbsp;&nbsp;typedef itk::Image&lt; InternalPixelType, Dimension &gt; InternalImageType;<br>&gt;&nbsp;&nbsp;&nbsp;typedef itk::CastImageFilter&lt; FixedImageType, InternalImageType &gt; FixedImageCasterType;<br>&gt;&nbsp;&nbsp;&nbsp;typedef itk::CastImageFilter&lt; MovingImageType, InternalImageType &gt; MovingImageCasterType;<br>&gt;&nbsp;&nbsp;&nbsp;FixedImageCasterType::Pointer fixedImageCaster&nbsp;&nbsp;&nbsp;=
 FixedImageCasterType::New();<br>&gt;&nbsp;&nbsp;&nbsp;MovingImageCasterType::Pointer movingImageCaster = MovingImageCasterType::New();<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;fixedImageCaster-&gt;SetInput( fixedImageReader-&gt;GetOutput() );<br>&gt;&nbsp;&nbsp;&nbsp;movingImageCaster-&gt;SetInput( movingImageReader-&gt;GetOutput() );<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;fixedImageCaster-&gt;Update();<br>&gt;&nbsp;&nbsp;&nbsp;movingImageCaster-&gt;Update();<br>&gt; <br>&gt; typedef itk::HistogramMatchingImageFilter&lt; InternalImageType, InternalImageType &gt;&nbsp;&nbsp;&nbsp;MatchingFilterType;<br>&gt; MatchingFilterType::Pointer matcher = MatchingFilterType::New();<br>&gt; matcher-&gt;SetInput( movingImageCaster-&gt;GetOutput() );<br>&gt; matcher-&gt;SetReferenceImage( fixedImageCaster-&gt;GetOutput() );<br>&gt; matcher-&gt;SetNumberOfHistogramLevels( 1024 );<br>&gt; matcher-&gt;SetNumberOfMatchPoints( 7 );<br>&gt;
 matcher-&gt;ThresholdAtMeanIntensityOn();<br>&gt; <br>&gt;&nbsp; <br>&gt;&nbsp;&nbsp;&nbsp;typedef itk::TranslationTransform&lt; double, Dimension &gt; TransformType;<br>&gt;&nbsp;&nbsp;&nbsp;typedef itk::RegularStepGradientDescentOptimizer&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;OptimizerType;<br>&gt;&nbsp;&nbsp;&nbsp;typedef itk::MeanSquaresImageToImageMetric&lt; InternalImageType, InternalImageType &gt;&nbsp; &nbsp; MetricType;<br>&gt;&nbsp;&nbsp;&nbsp;typedef itk:: LinearInterpolateImageFunction&lt; InternalImageType, double&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt;&nbsp; &nbsp; InterpolatorType;<br>&gt;&nbsp;&nbsp;&nbsp;typedef itk::ImageRegistrationMethod&lt; InternalImageType, InternalImageType &gt;&nbsp; &nbsp; RegistrationType;<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;MetricType::Pointer&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;metric&nbsp; &nbsp; &nbsp; &nbsp; = MetricType::New();<br>&gt;&nbsp;&nbsp;&nbsp;TransformType::Pointer&nbsp; &nbsp; &nbsp; transform&nbsp;
 &nbsp;&nbsp;&nbsp;= TransformType::New();<br>&gt;&nbsp;&nbsp;&nbsp;OptimizerType::Pointer&nbsp; &nbsp; &nbsp; optimizer&nbsp; &nbsp;&nbsp;&nbsp;= OptimizerType::New();<br>&gt;&nbsp;&nbsp;&nbsp;InterpolatorType::Pointer&nbsp;&nbsp;&nbsp;interpolator&nbsp; = InterpolatorType::New();<br>&gt;&nbsp;&nbsp;&nbsp;RegistrationType::Pointer&nbsp;&nbsp;&nbsp;registration&nbsp; = RegistrationType::New();<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;registration-&gt;SetMetric(&nbsp; &nbsp; &nbsp; &nbsp; metric&nbsp; &nbsp; &nbsp; &nbsp; );<br>&gt;&nbsp;&nbsp;&nbsp;registration-&gt;SetOptimizer(&nbsp; &nbsp;&nbsp;&nbsp;optimizer&nbsp; &nbsp;&nbsp;&nbsp;);<br>&gt;&nbsp;&nbsp;&nbsp;registration-&gt;SetTransform(&nbsp; &nbsp;&nbsp;&nbsp;transform&nbsp; &nbsp;&nbsp;&nbsp;);<br>&gt;&nbsp;&nbsp;&nbsp;registration-&gt;SetInterpolator(&nbsp; interpolator&nbsp; );<br>&gt; <br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;registration-&gt;SetFixedImage(&nbsp; &nbsp;
 fixedImageCaster-&gt;GetOutput()&nbsp; &nbsp; );<br>&gt;&nbsp;&nbsp;&nbsp;registration-&gt;SetMovingImage(&nbsp;&nbsp;&nbsp;matcher-&gt;GetOutput()&nbsp;&nbsp;&nbsp;);<br>&gt; <br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;typedef RegistrationType::ParametersType ParametersType;<br>&gt;&nbsp;&nbsp;&nbsp;ParametersType initialParameters( transform-&gt;GetNumberOfParameters() );<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;initialParameters[0] = 0.0;&nbsp; // Initial offset in mm along X<br>&gt;&nbsp;&nbsp;&nbsp;initialParameters[1] = 0.0;&nbsp; // Initial offset in mm along Y<br>&gt;&nbsp;&nbsp;&nbsp;<br>&gt;&nbsp;&nbsp;&nbsp;registration-&gt;SetInitialTransformParameters( initialParameters );<br>&gt;&nbsp;&nbsp;&nbsp;<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; It is usually desirable to fine tune the parameters of the optimizer.<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; Each optimizer has particular parameters that must be interpreted in the<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; context of the
 optimization strategy it implements. The optimizer used in<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; this example is a variant of gradient descent that attempts to prevent it<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; from taking steps that are too large.&nbsp; At each iteration, this optimizer<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; will take a step along the direction of the \doxygen{ImageToImageMetric}<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; derivative. The initial length of the step is defined by the user. Each<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; time the direction of the derivative abruptly changes, the optimizer<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; assumes that a local extrema has been passed and reacts by reducing the<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; step length by a half. After several reductions of the step length, the<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; optimizer may be moving in a very restricted area of the transform<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; parameter space. The user
 can define how small the step length should be<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; to consider convergence to have been reached. This is equivalent to defining<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; the precision with which the final transform should be known.<br>&gt;&nbsp;&nbsp;&nbsp;//<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; The initial step length is defined with the method<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; \code{SetMaximumStepLength()}, while the tolerance for convergence is<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; defined with the method \code{SetMinimumStepLength()}.<br>&gt;&nbsp; <br>&gt;&nbsp;&nbsp;&nbsp;optimizer-&gt;SetMaximumStepLength( 4.00 );&nbsp; <br>&gt;&nbsp;&nbsp;&nbsp;optimizer-&gt;SetMinimumStepLength( 0.01 );<br>&gt;&nbsp;&nbsp;&nbsp;optimizer-&gt;SetNumberOfIterations( 200 );<br>&gt;&nbsp;&nbsp;&nbsp;// Connect an observer<br>&gt;&nbsp;&nbsp;&nbsp;CommandIterationUpdate::Pointer observer =
 CommandIterationUpdate::New();<br>&gt;&nbsp;&nbsp;&nbsp;optimizer-&gt;AddObserver( itk::IterationEvent(), observer );<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;try <br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;{ <br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;registration-&gt;Update(); <br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;} <br>&gt;&nbsp;&nbsp;&nbsp;catch( itk::ExceptionObject &amp; err ) <br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;{ <br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;std::cerr &lt;&lt; "ExceptionObject caught !" &lt;&lt; std::endl; <br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;std::cerr &lt;&lt; err &lt;&lt; std::endl; <br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;return EXIT_FAILURE;<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;} <br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; The result of the registration process is an array of parameters that<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; defines the spatial transformation in an unique way. This final result is<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; obtained using the \code{GetLastTransformParameters()}
 method.<br>&gt;&nbsp;&nbsp;&nbsp;ParametersType finalParameters = registration-&gt;GetLastTransformParameters();<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; In the case of the \doxygen{TranslationTransform}, there is a<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; straightforward interpretation of the parameters.&nbsp; Each element of the<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; array corresponds to a translation along one spatial dimension.<br>&gt;&nbsp;&nbsp;&nbsp;const double TranslationAlongX = finalParameters[0];<br>&gt;&nbsp;&nbsp;&nbsp;const double TranslationAlongY = finalParameters[1];<br>&gt;&nbsp;&nbsp;&nbsp;const unsigned int numberOfIterations = optimizer-&gt;GetCurrentIteration();<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; The value of the image metric corresponding to the last set of parameters<br>&gt;&nbsp;&nbsp;&nbsp;//&nbsp; can be obtained with the \code{GetValue()} method of the optimizer.<br>&gt;&nbsp;&nbsp;&nbsp;const double bestValue =
 optimizer-&gt;GetValue();<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; "Result = " &lt;&lt; std::endl;<br>&gt;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; " Translation X = " &lt;&lt; TranslationAlongX&nbsp; &lt;&lt; std::endl;<br>&gt;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; " Translation Y = " &lt;&lt; TranslationAlongY&nbsp; &lt;&lt; std::endl;<br>&gt;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; " Iterations&nbsp; &nbsp; = " &lt;&lt; numberOfIterations &lt;&lt; std::endl;<br>&gt;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; " Metric value&nbsp; = " &lt;&lt; bestValue&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; std::endl;<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;typedef itk::ResampleImageFilter&lt; MovingImageType, FixedImageType &gt;&nbsp; &nbsp; ResampleFilterType;<br>&gt;&nbsp;&nbsp;&nbsp;<br>&gt;&nbsp;&nbsp;&nbsp;ResampleFilterType::Pointer resampler = ResampleFilterType::New();<br>&gt;&nbsp;&nbsp;&nbsp;resampler-&gt;SetInput( movingImageReader-&gt;GetOutput()
 );<br>&gt;&nbsp;&nbsp;&nbsp;resampler-&gt;SetTransform( registration-&gt;GetOutput()-&gt;Get() );<br>&gt;&nbsp;&nbsp;&nbsp;FixedImageType::Pointer fixedImage = fixedImageReader-&gt;GetOutput();<br>&gt;&nbsp;&nbsp;&nbsp;resampler-&gt;SetSize( fixedImage-&gt;GetLargestPossibleRegion().GetSize() );<br>&gt;&nbsp;&nbsp;&nbsp;resampler-&gt;SetOutputOrigin(&nbsp; fixedImage-&gt;GetOrigin() );<br>&gt;&nbsp;&nbsp;&nbsp;resampler-&gt;SetOutputSpacing( fixedImage-&gt;GetSpacing() );<br>&gt;&nbsp;&nbsp;&nbsp;resampler-&gt;SetOutputDirection( fixedImage-&gt;GetDirection() );<br>&gt;&nbsp;&nbsp;&nbsp;resampler-&gt;SetDefaultPixelValue( 100 );<br>&gt;&nbsp;&nbsp;&nbsp;<br>&gt;&nbsp;&nbsp;&nbsp;typedef unsigned char OutputPixelType;<br>&gt;&nbsp;&nbsp;&nbsp;typedef itk::Image&lt; OutputPixelType, Dimension &gt; OutputImageType;<br>&gt;&nbsp;&nbsp;&nbsp;typedef itk::CastImageFilter&lt; FixedImageType, OutputImageType &gt; CastFilterType;<br>&gt;&nbsp;&nbsp;&nbsp;typedef
 itk::ImageFileWriter&lt; OutputImageType &gt;&nbsp; WriterType;<br>&gt;&nbsp;&nbsp;&nbsp;<br>&gt;&nbsp;&nbsp;&nbsp;WriterType::Pointer&nbsp; &nbsp; &nbsp; writer =&nbsp; WriterType::New();<br>&gt;&nbsp;&nbsp;&nbsp;CastFilterType::Pointer&nbsp; caster =&nbsp; CastFilterType::New();<br>&gt;&nbsp;&nbsp;&nbsp;writer-&gt;SetFileName( argv[3] );<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;caster-&gt;SetInput( resampler-&gt;GetOutput() );<br>&gt;&nbsp;&nbsp;&nbsp;writer-&gt;SetInput( caster-&gt;GetOutput()&nbsp;&nbsp;&nbsp;);<br>&gt;&nbsp;&nbsp;&nbsp;writer-&gt;Update();<br>&gt;&nbsp;&nbsp;&nbsp;typedef itk::SubtractImageFilter&lt; FixedImageType, FixedImageType, FixedImageType &gt; DifferenceFilterType;<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;DifferenceFilterType::Pointer difference = DifferenceFilterType::New();<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;difference-&gt;SetInput1( fixedImageReader-&gt;GetOutput() );<br>&gt;&nbsp;&nbsp;&nbsp;difference-&gt;SetInput2(
 resampler-&gt;GetOutput() );<br>&gt;&nbsp;&nbsp;&nbsp;typedef itk::RescaleIntensityImageFilter&lt; FixedImageType, OutputImageType &gt;&nbsp;&nbsp;&nbsp;RescalerType;<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;RescalerType::Pointer intensityRescaler = RescalerType::New();<br>&gt;&nbsp;&nbsp;&nbsp;<br>&gt;&nbsp;&nbsp;&nbsp;intensityRescaler-&gt;SetInput( difference-&gt;GetOutput() );<br>&gt;&nbsp;&nbsp;&nbsp;intensityRescaler-&gt;SetOutputMinimum(&nbsp;&nbsp;&nbsp;0 );<br>&gt;&nbsp;&nbsp;&nbsp;intensityRescaler-&gt;SetOutputMaximum( 255 );<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;resampler-&gt;SetDefaultPixelValue( 1 );<br>&gt;&nbsp;&nbsp;&nbsp;WriterType::Pointer writer2 = WriterType::New();<br>&gt;&nbsp;&nbsp;&nbsp;writer2-&gt;SetInput( intensityRescaler-&gt;GetOutput() );&nbsp; <br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;if( argc &gt; 4 )<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;{<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;writer2-&gt;SetFileName( argv[4] );<br>&gt;&nbsp;
 &nbsp;&nbsp;&nbsp;writer2-&gt;Update();<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;}<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;TransformType::Pointer identityTransform = TransformType::New();<br>&gt;&nbsp;&nbsp;&nbsp;identityTransform-&gt;SetIdentity();<br>&gt;&nbsp;&nbsp;&nbsp;resampler-&gt;SetTransform( identityTransform );<br>&gt;&nbsp;&nbsp;&nbsp;<br>&gt;&nbsp;&nbsp;&nbsp;if( argc &gt; 5 )<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;{<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;writer2-&gt;SetFileName( argv[5] );<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;writer2-&gt;Update();<br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;}<br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;return EXIT_SUCCESS;<br>&gt; }<br>&gt; <br><br>&gt; PROJECT(ImageRegistration1)<br>&gt; FIND_PACKAGE(ITK)<br>&gt; IF(ITK_FOUND)<br>&gt;&nbsp;&nbsp;&nbsp;INCLUDE(${ITK_USE_FILE})<br>&gt; ELSE(ITK_FOUND)<br>&gt;&nbsp;&nbsp;&nbsp;MESSAGE(FATAL_ERROR<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;"ITK not found. Please set ITK_DIR.")<br>&gt;
 ENDIF(ITK_FOUND)<br>&gt; <br>&gt; ADD_EXECUTABLE(ImageRegistration1 ImageRegistration1.cxx )<br>&gt; TARGET_LINK_LIBRARIES(ImageRegistration1 ITKIO ITKNumerics)<br><br>&gt; _____________________________________<br>&gt; Powered by www.kitware.com<br>&gt; <br>&gt; Visit other Kitware open-source projects at<br>&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>&gt; <br>&gt; Please keep messages on-topic and check the ITK FAQ at: <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>&gt; <br>&gt; Follow this link to subscribe/unsubscribe:<br>&gt; <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br><br><br>-- <br>=============================================<br>Gabriele Arnulfo<br>BioEngineering Phd Student.<br>Bio-Lab, DIST - University of
 Genoa<br>Viale Causa 13, 16145 Genova - ITALY<br>Tel&nbsp;&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; (+39) 010-353-2789<br>Fax&nbsp;&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; (+39) 010-353-2948<br>Email&nbsp;&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; gabriele.arnulfo_at_gmail.com<br>Web &nbsp;&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; <a href="http://ga.mtvl.org" target="_blank">http://ga.mtvl.org</a><br>------------------------------------<br>In a world without wall,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; who needs WindowS?<br>------------------------------------<br>=============================================<br><br><br></div></blockquote></td></tr></table><br>