[Insight-users] Bspline 3D deformable registration
Luis Ibanez
luis.ibanez at kitware.com
Thu Jul 10 16:06:39 EDT 2008
Hi Shoosh,
You should then combine the code from the examples:
DeformableRegistration15.cxx (grid multi-res)
and
MultiResImageRegistration1.cxx (image multi-res)
MultiResImageRegistration2.cxx (image multi-res)
You will find them in the directory:
Insight/Examples/Registration
Regards,
Luis
-----------------
shoosh moosh wrote:
> I need to make both multi-resolution on the images using a B-spline scaling functions for 3D deformable registration. So which code do I use, if not the demons method?
>
> ----------------------------------------
>
>>Date: Wed, 9 Jul 2008 17:39:13 -0400
>>From: luis.ibanez at kitware.com
>>To: babygirl_25 at hotmail.com
>>CC: insight-users at itk.org
>>Subject: Re: [Insight-users] Bspline 3D deformable registration
>>
>>Hi Shoosh,
>>
>>Do you want to make multi-resolution on the images ?
>>or do you want to make it on the BSpline grid ?
>>
>>Please let us know,
>>
>>In either case, you are starting from the wrong code.
>>The example that you posted is appropriate for
>>the Demons method but not for the BSplineDeformable
>>Transform.
>>
>>We can point you to the right framework once we know
>>if you want to do image multi-resolution or BSpline
>>multi-resolution.
>>
>>
>>
>> Thanks
>>
>>
>> Luis
>>
>>
>>--------------------
>>shoosh moosh wrote:
>>
>>>I'm trying to write code to register 3D images using a multiresolution first degree B-spline deformation model. I'm not sure where to include/spedify the B-spline part. The code is attached.
>>>Thanks
>>>
>>>
>>>
>>>_________________________________________________________________
>>>Explore the seven wonders of the world
>>>http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE
>>>
>>>
>>>------------------------------------------------------------------------
>>>
>>>/*******************************************************************************
>>>Program: Demons Registration using ITK
>>>Id: $Id$
>>>Language: C++
>>>*******************************************************************************/
>>>
>>>#include
>>>using std::cerr;
>>>using std::clog;
>>>using std::endl;
>>>
>>>#include
>>>
>>>#include "demons.h"
>>>
>>>// ITK IO includes
>>>#include "itkImage.h"
>>>#include "itkImageFileReader.h"
>>>#include "itkImageFileWriter.h"
>>>
>>>// ITK Registration includes
>>>#include "itkMultiResolutionPDEDeformableRegistration.h"
>>>#include "itkMultiResolutionImageRegistrationMethod.h"
>>>#include "itkMultiResolutionPyramidImageFilter.h"
>>>#include "itkDemonsRegistrationFilter.h"
>>>#include "itkHistogramMatchingImageFilter.h"
>>>#include "itkCastImageFilter.h"
>>>#include "itkWarpImageFilter.h"
>>>#include "itkLinearInterpolateImageFunction.h"
>>>
>>>int demons( std::vector< std::string> args )
>>>{
>>>
>>> // Verify the number of parameters in the command line
>>> if( args.size() != 4 ){
>>> clog << "usage: " << endl << args[0] << " target source deformation" << endl;
>>> return EXIT_FAILURE;
>>> }
>>>
>>> // define ITK short-hand types
>>> const unsigned int Dimension = 3;
>>> typedef short PixelType;
>>> typedef float InternalPixelType;
>>> typedef itk::Image< PixelType, Dimension> ImageType;
>>> typedef itk::Image< InternalPixelType, Dimension> InternalImageType;
>>> typedef itk::CastImageFilter< ImageType, InternalImageType> ImageCasterType;
>>>
>>> // setup input file readers
>>> typedef itk::ImageFileReader< ImageType> ReaderType;
>>> ReaderType::Pointer targetReader = ReaderType::New();
>>> targetReader->SetFileName( args[1] );
>>> ReaderType::Pointer sourceReader = ReaderType::New();
>>> sourceReader->SetFileName( args[2] );
>>>
>>> // cast target and source to float
>>> ImageCasterType::Pointer targetImageCaster = ImageCasterType::New();
>>> ImageCasterType::Pointer sourceImageCaster = ImageCasterType::New();
>>> targetImageCaster->SetInput( targetReader->GetOutput() );
>>> sourceImageCaster->SetInput( sourceReader->GetOutput() );
>>>
>>> // match the histograms between source and target
>>> typedef itk::HistogramMatchingImageFilter< InternalImageType, InternalImageType> MatchingFilterType;
>>> MatchingFilterType::Pointer matcher = MatchingFilterType::New();
>>> matcher->SetInput( sourceImageCaster->GetOutput() );
>>> matcher->SetReferenceImage( targetImageCaster->GetOutput() );
>>> matcher->SetNumberOfHistogramLevels( 1024 );
>>> matcher->SetNumberOfMatchPoints( 7 );
>>> matcher->ThresholdAtMeanIntensityOn();
>>>
>>> // setup the deformation field and filter
>>> typedef itk::Vector< float, Dimension> VectorPixelType;
>>> typedef itk::Image< VectorPixelType, Dimension> DeformationFieldType;
>>> typedef itk::DemonsRegistrationFilter< InternalImageType,
>>> InternalImageType, DeformationFieldType> RegistrationFilterType;
>>> RegistrationFilterType::Pointer filter = RegistrationFilterType::New();
>>> filter->SetStandardDeviations( 1.0 );
>>>
>>> // use multiresolution scheme
>>> typedef itk::MultiResolutionPDEDeformableRegistration
>>> < InternalImageType, InternalImageType, DeformationFieldType>
>>> MultiResRegistrationFilterType;
>>> MultiResRegistrationFilterType::Pointer
>>> multires = MultiResRegistrationFilterType::New();
>>> multires->SetRegistrationFilter( filter );
>>> multires->SetNumberOfLevels( 5 );
>>> multires->SetFixedImage( targetImageCaster->GetOutput() );
>>> multires->SetMovingImage( matcher->GetOutput() );
>>> unsigned int nIterations[5] = { 25, 60, 95, 130, 165 };
>>> multires->SetNumberOfIterations( nIterations );
>>>
>>> // apply the registration filter
>>> multires->Update();
>>>
>>> // write the deformation field
>>> typedef itk::ImageFileWriter< DeformationFieldType> DeformationWriterType;
>>> DeformationWriterType::Pointer defwriter = DeformationWriterType::New();
>>> defwriter->SetFileName( args[3] );
>>> defwriter->SetInput( multires->GetOutput() );
>>> defwriter->Update();
>>>
>>> return EXIT_SUCCESS;
>>>}
>>>
>>>
>>>
>>>
>>>
>>>------------------------------------------------------------------------
>>>
>>>_______________________________________________
>>>Insight-users mailing list
>>>Insight-users at itk.org
>>>http://www.itk.org/mailman/listinfo/insight-users
>
>
> _________________________________________________________________
> Explore the seven wonders of the world
> http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE
>
More information about the Insight-users
mailing list