<p>Hi,luis,<br>   I have several questions about ITK deformable registration.<br>  First, I use the Demons for 3D deformable registration, when I set the parameter &quot;SetStandardDeviations&quot; smaller(for example 1.0), <br>
  the image whose size is 256*176*16 will have black regions in each slice, but when I set this paremeter bigger (for example 10.0),<br>  only the first and the last slice have  black regions, so I do not know why this phenomena will happen? <br>
  second, since the phenomena happened, so I use the &quot;MirrorPadImageFilter&quot; to pad the image in the slice direction in order to <br>  make its size 256*176*18, and set the &quot;SetStandardDeviations&quot;  parameter 10.0, then after registration, <br>
  I use the WarpImageFilter to warp the movingImage according to the deformable field, at last I use the &quot;RegionOfInterestImageFilter&quot; extract the image from second slice to the seventeenth slice. Thus I can get better result, but I don&#39;t know this method is whether correct.<br>
    In order to explain these problem, I copy the part programs in the email, and the result images in the inclosure.<br> Thank you for your answers as soon as possible.<br> <br> With best regards!<br>  <br>                 HuaJiang,<br>
 </p>
<p>The Program:(this is the part of the my program, the read and write parts arenot attached)<br>FixedImageCasterType::Pointer fixedImageCaster   = FixedImageCasterType::New();<br>    MovingImageCasterType::Pointer movingImageCaster = MovingImageCasterType::New();<br>
 fixedImageCaster-&gt;SetInput( fixedImage );<br>    movingImageCaster-&gt;SetInput( movingImage ); <br>/*<br> HistogramMatchFilterType::Pointer matcher = HistogramMatchFilterType::New();<br> matcher-&gt;SetInput( movingImageCaster-&gt;GetOutput() );<br>
    matcher-&gt;SetReferenceImage( fixedImageCaster-&gt;GetOutput() );<br>    <br> matcher-&gt;SetNumberOfHistogramLevels( 1024 );<br>    matcher-&gt;SetNumberOfMatchPoints( 7 );<br>    matcher-&gt;ThresholdAtMeanIntensityOn();<br>
    */<br> <br> <br> Demons3RegistrationFilterType::Pointer filter = Demons3RegistrationFilterType::New();<br>    <br> filter-&gt;SetStandardDeviations( 10.0 );<br> MultiResRegistrationFilterType:: Pointer multires = MultiResRegistrationFilterType::New();<br>
    <br> multires-&gt;SetRegistrationFilter( filter );<br> multires-&gt;SetNumberOfLevels( 3 );<br> <br> unsigned int nIterations[4] = {32, 16, 4 };<br>    multires-&gt;SetNumberOfIterations( nIterations );<br> DemonsCommandIterationUpdate::Pointer observer = DemonsCommandIterationUpdate::New();<br>
 filter-&gt;AddObserver(itk::IterationEvent(), observer);<br>    <br> CommandResolutionLevelUpdate::Pointer levelobserver = CommandResolutionLevelUpdate::New();<br>    multires-&gt;AddObserver( itk::IterationEvent(), levelobserver );<br>
    <br> // Pad the image.<br>    unsigned long upFactor[3] = {0,0,1};<br> unsigned long lowFactor[3] = {0,0,1};<br>    InternalPixelType defaultPixel = 0;<br> // define warp filter.<br> WarperType::Pointer warper = WarperType::New();<br>
 typedef itk::LinearInterpolateImageFunction&lt; InternalImageType, double &gt; LinearInterpolatorType;<br> LinearInterpolatorType::Pointer linearInterpolator = LinearInterpolatorType::New();<br>    <br> warper-&gt;SetInterpolator( linearInterpolator );<br>
    ConstantPadImageFilterType::Pointer constantPadFixedFilter; <br> ConstantPadImageFilterType::Pointer constantPadMovingFilter; <br> MirrorPadImageFilterType::Pointer mirrorPadFixedFilter;<br> MirrorPadImageFilterType::Pointer mirrorPadMovingFilter; <br>
 if (m_padMode == ConstantPad)<br> {<br>     constantPadFixedFilter = ConstantPadImageFilterType::New();<br>     constantPadMovingFilter = ConstantPadImageFilterType::New();<br>        <br>  constantPadFixedFilter-&gt;SetInput(fixedImageCaster-&gt;GetOutput());<br>
  constantPadMovingFilter-&gt;SetInput(movingImageCaster-&gt;GetOutput());<br>   <br>  constantPadFixedFilter-&gt;SetPadLowerBound(lowFactor);<br>  constantPadFixedFilter-&gt;SetPadUpperBound(upFactor);<br>        constantPadFixedFilter-&gt;SetConstant(defaultPixel);<br>
        constantPadMovingFilter-&gt;SetPadLowerBound(lowFactor);<br>  constantPadMovingFilter-&gt;SetPadUpperBound(upFactor);<br>        constantPadMovingFilter-&gt;SetConstant(defaultPixel);<br>  multires-&gt;SetFixedImage( constantPadFixedFilter-&gt;GetOutput() );<br>
     multires-&gt;SetMovingImage( constantPadMovingFilter-&gt;GetOutput() );<br> <br>  try<br>  {<br>   multires-&gt;Update();<br>  }<br>  catch( itk::ExceptionObject &amp; excp )<br>  {<br>   std::cerr &lt;&lt; excp &lt;&lt; std::endl;<br>
   return ;<br>    }<br>        warper-&gt;SetInput(constantPadMovingFilter-&gt;GetOutput());<br>        warper-&gt;SetOutputSpacing( constantPadFixedFilter-&gt;GetOutput()-&gt;GetSpacing() );<br>  warper-&gt;SetOutputOrigin( constantPadFixedFilter-&gt;GetOutput()-&gt;GetOrigin() );<br>
  <br>  warper-&gt;SetDeformationField( multires-&gt;GetOutput() );<br>        warper-&gt;Update();<br> }<br> else if (m_padMode == MirrorPad)<br> {<br>     mirrorPadFixedFilter = MirrorPadImageFilterType::New();<br>  mirrorPadMovingFilter = MirrorPadImageFilterType::New();</p>

<p>  mirrorPadFixedFilter-&gt;SetInput(fixedImageCaster-&gt;GetOutput());<br>  mirrorPadMovingFilter-&gt;SetInput(movingImageCaster-&gt;GetOutput());<br>  <br>  mirrorPadFixedFilter-&gt;SetPadLowerBound(lowFactor);<br>  mirrorPadFixedFilter-&gt;SetPadUpperBound(upFactor);<br>
  <br>        mirrorPadMovingFilter-&gt;SetPadLowerBound(lowFactor);<br>  mirrorPadMovingFilter-&gt;SetPadUpperBound(upFactor);<br>  <br>  multires-&gt;SetFixedImage( mirrorPadFixedFilter-&gt;GetOutput() );<br>  multires-&gt;SetMovingImage( mirrorPadMovingFilter-&gt;GetOutput() );<br>
  <br>  try<br>  {<br>   multires-&gt;Update();<br>  }<br>  catch( itk::ExceptionObject &amp; excp )<br>  {<br>   std::cerr &lt;&lt; excp &lt;&lt; std::endl;<br>   return ;<br>  }<br>        <br>  warper-&gt;SetInput(mirrorPadMovingFilter-&gt;GetOutput());<br>
        warper-&gt;SetOutputSpacing( mirrorPadFixedFilter-&gt;GetOutput()-&gt;GetSpacing() );<br>  warper-&gt;SetOutputOrigin( mirrorPadFixedFilter-&gt;GetOutput()-&gt;GetOrigin() );<br>  <br>  warper-&gt;SetDeformationField( multires-&gt;GetOutput() );<br>
        warper-&gt;Update();<br> }<br>    <br>    // extract the image.<br>    RegionOfInterestImageFilterType::Pointer regionExtractFitler<br>  = RegionOfInterestImageFilterType::New();<br> <br>    regionExtractFitler-&gt;SetInput(warper-&gt;GetOutput());<br>
 InternalImageType::RegionType desiredRegion ;<br> InternalImageType::SizeType size = fixedImage-&gt;GetLargestPossibleRegion().GetSize();<br> InternalImageType::IndexType index;<br> index[0] = 0;<br> index[1] = 0;<br> index[2] = 0;<br>
    desiredRegion.SetSize(size);<br> desiredRegion.SetIndex(index);<br> regionExtractFitler-&gt;SetRegionOfInterest(desiredRegion);<br> InternalImageCasterType::Pointer internalCaster = InternalImageCasterType::New();<br>
 internalCaster-&gt;SetInput(regionExtractFitler-&gt;GetOutput());<br>    internalCaster-&gt;Update();</p>