<div>Hello Luis,</div>
<div>&nbsp;</div>
<div>I am a new user of itk, but no one in my lab have used it. So, when some problems comes, I am so sad.</div>
<div>Looking forward of your help~~~</div>
<div>&nbsp;</div>
<div>I have some problems in the registration of RGB images.</div>
<div>Now I explain my problems in detail:</div>
<div>&nbsp;</div>
<div>my work is to register two RGB images using the CenteredRigid2DTransform</div>
<div>I have set the VectorResampleFilter&nbsp; and VectorInterpolater</div>
<div>but still the complier error is </div>
<div>&nbsp;</div>
<div>d:\program files\itk\insighttoolkit-3.4.0\code\common\itkCovariantVector.h(75) : error C2039: &#39;RealType&#39; : is not a member of &#39;itk::NumericTraits&lt;T&gt;&#39;<br>1&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; with<br>1&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [<br>1&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; T=itk::RGBPixel&lt;double&gt;
<br>1&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ]<br>1&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; D:\program files\itk\InsightToolkit-3.4.0\Code\Common\itkPixelTraits.h(39) : see reference to class template instantiation &#39;itk::CovariantVector&lt;T,NVectorDimension&gt;&#39; being compiled
<br>1&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; with<br>1&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [<br>1&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; T=itk::RGBPixel&lt;double&gt;,<br>1&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NVectorDimension=2<br>1&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ]</div>
<div>&nbsp;</div>
<div>I don&#39;t know how to settle this problem, please give me some help!</div>
<div>thanks very much</div>
<div>&nbsp;</div>
<div>my code is just refied the examples in itk</div>
<div>&nbsp;</div>
<div>#include &quot;itkImageRegistrationMethod.h&quot;<br>#include &quot;itkMeanSquaresImageToImageMetric.h&quot;<br>#include &quot;itkVectorLinearInterpolateImageFunction.h&quot;<br>#include &quot;itkRegularStepGradientDescentOptimizer.h
&quot;<br>#include &quot;itkImage.h&quot;<br>#include &quot;itkRGBPixel.h&quot;</div>
<div>#include &quot;itkCenteredRigid2DTransform.h&quot;<br>
<p>#include &quot;itkImageFileReader.h&quot;<br>#include &quot;itkImageFileWriter.h&quot;</p>
<p>#include &quot;itkVectorResampleImageFilter.h&quot;<br>#include &quot;itkSubtractImageFilter.h&quot;<br>#include &quot;itkRescaleIntensityImageFilter.h&quot;<br></p>
<p>int main( int argc, char *argv[] )<br>{<br>&nbsp;if( argc &lt; 4 )<br>&nbsp;{<br>&nbsp;&nbsp;std::cerr &lt;&lt; &quot;Missing Parameters &quot; &lt;&lt; std::endl;<br>&nbsp;&nbsp;std::cerr &lt;&lt; &quot;Usage: &quot; &lt;&lt; argv[0];<br>&nbsp;&nbsp;std::cerr &lt;&lt; &quot; fixedImageFile&nbsp; movingImageFile &quot;;
<br>&nbsp;&nbsp;std::cerr &lt;&lt; &quot; outputImagefile&nbsp; [differenceAfterRegistration] &quot;;<br>&nbsp;&nbsp;std::cerr &lt;&lt; &quot; [differenceBeforeRegistration] &quot;;<br>&nbsp;&nbsp;std::cerr &lt;&lt; &quot; [initialStepLength] &quot;&lt;&lt; std::endl;
<br>&nbsp;&nbsp;return EXIT_FAILURE;<br>&nbsp;}</p>
<p>&nbsp;const&nbsp;&nbsp;&nbsp; unsigned int&nbsp;&nbsp;&nbsp; Dimension = 2;<br>&nbsp;typedef&nbsp; itk::RGBPixel&lt; unsigned char &gt;&nbsp;&nbsp;&nbsp; PixelType;</p>
<p>&nbsp;typedef itk::Image&lt; PixelType, Dimension &gt;&nbsp; FixedImageType;<br>&nbsp;typedef itk::Image&lt; PixelType, Dimension &gt;&nbsp; MovingImageType;<br>&nbsp;typedef itk::CenteredRigid2DTransform&lt; double &gt; TransformType;<br><br>
&nbsp;typedef itk::RegularStepGradientDescentOptimizer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OptimizerType;<br>&nbsp;typedef itk::MeanSquaresImageToImageMetric&lt; <br>&nbsp;&nbsp;FixedImageType, <br>&nbsp;&nbsp;MovingImageType &gt;&nbsp;&nbsp;&nbsp; MetricType;<br>&nbsp;typedef itk:: VectorLinearInterpolateImageFunction&lt; 
<br>&nbsp;&nbsp;MovingImageType,<br>&nbsp;&nbsp;double&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &gt;&nbsp;&nbsp;&nbsp; InterpolatorType;<br>&nbsp;typedef itk::ImageRegistrationMethod&lt; <br>&nbsp;&nbsp;FixedImageType, <br>&nbsp;&nbsp;MovingImageType &gt;&nbsp;&nbsp;&nbsp; RegistrationType;</p>
<p>&nbsp;MetricType::Pointer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; metric&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = MetricType::New();<br>&nbsp;OptimizerType::Pointer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; optimizer&nbsp;&nbsp;&nbsp;&nbsp; = OptimizerType::New();<br>&nbsp;InterpolatorType::Pointer&nbsp;&nbsp; interpolator&nbsp; = InterpolatorType::New();<br>&nbsp;RegistrationType::Pointer&nbsp;&nbsp; registration&nbsp; = RegistrationType::New();
</p>
<p>&nbsp;registration-&gt;SetMetric(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; metric&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );<br>&nbsp;registration-&gt;SetOptimizer(&nbsp;&nbsp;&nbsp;&nbsp; optimizer&nbsp;&nbsp;&nbsp;&nbsp; );<br>&nbsp;registration-&gt;SetInterpolator(&nbsp; interpolator&nbsp; );</p>
<p><br>&nbsp;TransformType::Pointer&nbsp; transform = TransformType::New();<br>&nbsp;registration-&gt;SetTransform( transform );<br></p>
<p><br>&nbsp;typedef itk::ImageFileReader&lt; FixedImageType&nbsp; &gt; FixedImageReaderType;<br>&nbsp;typedef itk::ImageFileReader&lt; MovingImageType &gt; MovingImageReaderType;</p>
<p>&nbsp;FixedImageReaderType::Pointer&nbsp; fixedImageReader&nbsp; = FixedImageReaderType::New();<br>&nbsp;MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New();</p>
<p>&nbsp;fixedImageReader-&gt;SetFileName(&nbsp; argv[1] );<br>&nbsp;movingImageReader-&gt;SetFileName( argv[2] );</p>
<p><br>&nbsp;registration-&gt;SetFixedImage(&nbsp;&nbsp;&nbsp; fixedImageReader-&gt;GetOutput()&nbsp;&nbsp;&nbsp; );<br>&nbsp;registration-&gt;SetMovingImage(&nbsp;&nbsp; movingImageReader-&gt;GetOutput()&nbsp;&nbsp; );<br>&nbsp;fixedImageReader-&gt;Update();</p>
<p>&nbsp;registration-&gt;SetFixedImageRegion( <br>&nbsp;&nbsp;fixedImageReader-&gt;GetOutput()-&gt;GetBufferedRegion() );<br>&nbsp;fixedImageReader-&gt;Update();<br>&nbsp;movingImageReader-&gt;Update();<br></p>
<p>&nbsp;typedef FixedImageType::SpacingType&nbsp;&nbsp;&nbsp; SpacingType;<br>&nbsp;typedef FixedImageType::PointType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OriginType;<br>&nbsp;typedef FixedImageType::RegionType&nbsp;&nbsp;&nbsp;&nbsp; RegionType;<br>&nbsp;typedef FixedImageType::SizeType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SizeType;<br>
&nbsp;FixedImageType::Pointer fixedImage = fixedImageReader-&gt;GetOutput();</p>
<p>&nbsp;const SpacingType fixedSpacing = fixedImage-&gt;GetSpacing();<br>&nbsp;const OriginType&nbsp; fixedOrigin&nbsp; = fixedImage-&gt;GetOrigin();<br>&nbsp;const RegionType&nbsp; fixedRegion&nbsp; = fixedImage-&gt;GetLargestPossibleRegion(); <br>&nbsp;const SizeType&nbsp;&nbsp;&nbsp; fixedSize&nbsp;&nbsp;&nbsp; = 
fixedRegion.GetSize();</p>
<p>&nbsp;TransformType::InputPointType centerFixed;</p>
<p>&nbsp;centerFixed[0] = fixedOrigin[0] + fixedSpacing[0] * fixedSize[0] / 2.0;<br>&nbsp;centerFixed[1] = fixedOrigin[1] + fixedSpacing[1] * fixedSize[1] / 2.0;<br><br>&nbsp;MovingImageType::Pointer movingImage = movingImageReader-&gt;GetOutput();
</p>
<p>&nbsp;const SpacingType movingSpacing = movingImage-&gt;GetSpacing();<br>&nbsp;const OriginType&nbsp; movingOrigin&nbsp; = movingImage-&gt;GetOrigin();<br>&nbsp;const RegionType&nbsp; movingRegion&nbsp; = movingImage-&gt;GetLargestPossibleRegion();<br>
&nbsp;const SizeType&nbsp;&nbsp;&nbsp; movingSize&nbsp;&nbsp;&nbsp; = movingRegion.GetSize();</p>
<p>&nbsp;TransformType::InputPointType centerMoving;</p>
<p>&nbsp;centerMoving[0] = movingOrigin[0] + movingSpacing[0] * movingSize[0] / 2.0;<br>&nbsp;centerMoving[1] = movingOrigin[1] + movingSpacing[1] * movingSize[1] / 2.0;<br>&nbsp;<br>&nbsp;transform-&gt;SetCenter( centerFixed );<br>&nbsp;transform-&gt;SetTranslation( centerMoving - centerFixed );
<br>&nbsp;transform-&gt;SetAngle( 0.0 );</p>
<p><br>&nbsp;registration-&gt;SetInitialTransformParameters( transform-&gt;GetParameters() );<br></p>
<p>&nbsp;// Software Guide : BeginCodeSnippet<br>&nbsp;typedef OptimizerType::ScalesType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OptimizerScalesType;<br>&nbsp;OptimizerScalesType optimizerScales( transform-&gt;GetNumberOfParameters() );<br>&nbsp;const double translationScale = 
1.0 / 1000.0;</p>
<p>&nbsp;optimizerScales[0] = 1.0;<br>&nbsp;optimizerScales[1] = translationScale;<br>&nbsp;optimizerScales[2] = translationScale;<br>&nbsp;optimizerScales[3] = translationScale;<br>&nbsp;optimizerScales[4] = translationScale;</p>
<p>&nbsp;optimizer-&gt;SetScales( optimizerScales );<br><br>&nbsp;double initialStepLength = 0.1;<br>&nbsp;// Software Guide : EndCodeSnippet</p>
<p>&nbsp;if( argc &gt; 6 )<br>&nbsp;{<br>&nbsp;&nbsp;initialStepLength = atof( argv[6] );<br>&nbsp;}</p>
<p>&nbsp;// Software Guide : BeginCodeSnippet<br>&nbsp;optimizer-&gt;SetRelaxationFactor( 0.6 );<br>&nbsp;optimizer-&gt;SetMaximumStepLength( initialStepLength ); <br>&nbsp;optimizer-&gt;SetMinimumStepLength( 0.001 );<br>&nbsp;optimizer-&gt;SetNumberOfIterations( 200 );
<br>&nbsp;// Software Guide : EndCodeSnippet</p>
<p><br>&nbsp;// Create the Command observer and register it with the optimizer.<br>&nbsp;//<br>&nbsp;CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New();<br>&nbsp;optimizer-&gt;AddObserver( itk::IterationEvent(), observer );
</p>
<p>&nbsp;try <br>&nbsp;{ <br>&nbsp;&nbsp;registration-&gt;StartRegistration(); <br>&nbsp;} <br>&nbsp;catch( itk::ExceptionObject &amp; err ) <br>&nbsp;{ <br>&nbsp;&nbsp;std::cerr &lt;&lt; &quot;ExceptionObject caught !&quot; &lt;&lt; std::endl; <br>&nbsp;&nbsp;std::cerr &lt;&lt; err &lt;&lt; std::endl; 
<br>&nbsp;&nbsp;return EXIT_FAILURE;<br>&nbsp;} </p>
<p>&nbsp;OptimizerType::ParametersType finalParameters = <br>&nbsp;&nbsp;registration-&gt;GetLastTransformParameters();</p>
<p>&nbsp;const double finalAngle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = finalParameters[0];<br>&nbsp;const double finalRotationCenterX = finalParameters[1];<br>&nbsp;const double finalRotationCenterY = finalParameters[2];<br>&nbsp;const double finalTranslationX&nbsp;&nbsp;&nbsp; = finalParameters[3];
<br>&nbsp;const double finalTranslationY&nbsp;&nbsp;&nbsp; = finalParameters[4];</p>
<p>&nbsp;const unsigned int numberOfIterations = optimizer-&gt;GetCurrentIteration();</p>
<p>&nbsp;const double bestValue = optimizer-&gt;GetValue();</p>
<p>typedef itk::VectorResampleImageFilter&lt; <br>&nbsp;&nbsp;MovingImageType, <br>&nbsp;&nbsp;FixedImageType &gt;&nbsp;&nbsp;&nbsp; ResampleFilterType;</p>
<p>&nbsp;TransformType::Pointer finalTransform = TransformType::New();</p>
<p>&nbsp;finalTransform-&gt;SetParameters( finalParameters );</p>
<p>&nbsp;ResampleFilterType::Pointer resample = ResampleFilterType::New();</p>
<p>&nbsp;resample-&gt;SetTransform( finalTransform );<br>&nbsp;resample-&gt;SetInput( movingImageReader-&gt;GetOutput() );</p>
<p>&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 );
</p>
<p>&nbsp;typedef itk::ImageFileWriter&lt; FixedImageType &gt;&nbsp; WriterFixedType;</p>
<p>&nbsp;WriterFixedType::Pointer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writer =&nbsp; WriterFixedType::New();</p>
<p>&nbsp;writer-&gt;SetFileName( argv[3] );</p>
<p>&nbsp;writer-&gt;SetInput( resample-&gt;GetOutput()&nbsp;&nbsp; );</p>
<p>&nbsp;try<br>&nbsp;{<br>&nbsp;&nbsp;writer-&gt;Update();<br>&nbsp;}<br>&nbsp;catch( itk::ExceptionObject &amp; excp )<br>&nbsp;{ <br>&nbsp;&nbsp;std::cerr &lt;&lt; &quot;ExceptionObject while writing the resampled image !&quot; &lt;&lt; std::endl; <br>&nbsp;&nbsp;std::cerr &lt;&lt; excp &lt;&lt; std::endl; 
<br>&nbsp;&nbsp;return EXIT_FAILURE;<br>&nbsp;} </p></div>
<div>}</div>