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