Hi All, <br><br>As a newbie, I am running to an issue of how to use Demons registration correctly. With ITK4.2, I modified the example "DeformableRegistration16.cxx" for 3D cases. However, CommandIterationUpdate always prints out random metric values like 1.79769e+308. Here is part of my code:<br>
----------------------------------------------------------------------------------------------------------------------------------<br> // Histogram matching<br> typedef itk::HistogramMatchingImageFilter<ImageType, ImageType> MatchingFilterType;<br>
MatchingFilterType::Pointer vMatcher = MatchingFilterType::New();<br> vMatcher->SetInput(vMovImage);<br> vMatcher->SetReferenceImage(vFixImage);<br> vMatcher->SetNumberOfHistogramLevels(1024);<br> vMatcher->SetNumberOfMatchPoints(7);<br>
vMatcher->ThresholdAtMeanIntensityOn();<br> vMatcher->Update();<br><br> //- Setup the deformation field and filter<br> typedef itk::Vector<float, 3> VectorPixelType;<br> typedef itk::Image<VectorPixelType, 3> DisplacementFieldType;<br>
typedef itk::DemonsRegistrationFilter<ImageType, ImageType, <br> DisplacementFieldType> RegistrationFilterType;<br> RegistrationFilterType::Pointer vFilter = RegistrationFilterType::New();<br>
vFilter->SetStandardDeviations(5.0);<br><br> //- Create the Command observer and register it with the registration filter.<br> CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New();<br> vFilter->AddObserver( itk::IterationEvent(), observer );<br>
<br><br> //- Use multiresolution scheme<br> typedef itk::MultiResolutionPDEDeformableRegistration<ImageType,<br> ImageType, DisplacementFieldType> MultiResRegistrationFilterType;<br><br> MultiResRegistrationFilterType::Pointer vRegistration = MultiResRegistrationFilterType::New();<br>
<br> vRegistration->SetRegistrationFilter(vFilter);<br> vRegistration->SetNumberOfLevels(4);<br> vRegistration->SetFixedImage(vFixImage);<br> vRegistration->SetMovingImage(vMatcher->GetOutput());<br>
unsigned int nIterations[4] = {40, 40, 32, 32};<br> vRegistration->SetNumberOfIterations(nIterations);<br><br> //- Create the Command observer and register it with the registration filter.<br> CommandResolutionLevelUpdate::Pointer vLevelObserver = CommandResolutionLevelUpdate::New();<br>
vRegistration->AddObserver(itk::IterationEvent(), vLevelObserver);<br><br> //- Apply the registration filter<br> try<br> {<br> vRegistration->Update();<br> }<br> catch( itk::ExceptionObject & excp )<br>
{<br> std::cerr << excp << std::endl;<br> return false;<br> }<br>----------------------------------------------------------------------------------------------------------------------------------<br>
<br>Am I wrong with anything? Thanks!<br><br>