[Insight-users] Simple resampling problem

Luis Ibanez luis.ibanez at kitware.com
Tue Mar 16 13:06:41 EDT 2010


Hi Darren,

Yes, your summary is correct.

and you are right in that, this is probably the most common
usage of the SetReferenceImage() functionality.

Just for completeness, here is what the itkResampleImageFilter
does internally with the Reference image:


Insight/Code/BasicFilters/itkResampleImageFilter.txx

Lines 605-631:

  // Set the size of the output region
  if( m_UseReferenceImage && referenceImage )
    {
    outputPtr->SetLargestPossibleRegion(
referenceImage->GetLargestPossibleRegion() );
    }
  else
    {
    typename TOutputImage::RegionType outputLargestPossibleRegion;
    outputLargestPossibleRegion.SetSize( m_Size );
    outputLargestPossibleRegion.SetIndex( m_OutputStartIndex );
    outputPtr->SetLargestPossibleRegion( outputLargestPossibleRegion );
    }

  // Set spacing and origin
  if (m_UseReferenceImage && referenceImage)
    {
    outputPtr->SetOrigin( referenceImage->GetOrigin() );
    outputPtr->SetSpacing( referenceImage->GetSpacing() );
    outputPtr->SetDirection( referenceImage->GetDirection() );
    }
  else
    {
    outputPtr->SetOrigin( m_OutputOrigin );
    outputPtr->SetSpacing( m_OutputSpacing );
    outputPtr->SetDirection( m_OutputDirection );
    }
  return;
}


              "Glimpsing at the source,
               leaves no doubt"



-------------------


   Regards,


        Luis


-------------------------------------------------------------
On Mon, Mar 15, 2010 at 3:28 PM, Darren Weber
<darren.weber.lists at gmail.com> wrote:
>
>
> On Mon, Mar 1, 2010 at 4:34 PM, Luis Ibanez <luis.ibanez at kitware.com> wrote:
>>
>> Hi Richard,
>>
>> Thanks for letting us know what was wrong.
>>
>> --
>>
>> In general, you may find useful the "ReferenceImage"
>> functionality of the ResampleImageFitler.
>>
>> It takes care of using the Origin, Spacing, Direction
>> and number of pixels from a given image, instead
>> of you having to specify all of them one by one.
>>
>> Providing a reference image is typically what you
>> want to use after an image registration process.
>>
>
>
> Oh, this is interesting.  Something like the following is common practice:
>
>         typedef itk::ResampleImageFilter< iImgType, oImgType >
> ResampleFilterType;
>         ResampleFilterType::Pointer Resampler = ResampleFilterType::New();
>         Resampler->SetTransform( transform );
>         Resampler->SetInterpolator( interpolator );
>         Resampler->SetInput( MovReader->GetOutput() );
>         Resampler->SetSize( FixInfo.size ); // assume this struct works
>         Resampler->SetOutputOrigin( FixReader->GetOutputOrigin() );
>         Resampler->SetOutputSpacing( FixReader->GetOutputSpacing() );
>         Resampler->SetOutputDirection( FixReader->GetOutputDirection() );
>         Resampler->SetDefaultPixelValue( 100 ); // highlight outside regions
>
> So that could be replaced with (?):
>
>         typedef itk::ResampleImageFilter< iImgType, oImgType >
> ResampleFilterType;
>         ResampleFilterType::Pointer Resampler = ResampleFilterType::New();
>         Resampler->SetTransform( transform );
>         Resampler->SetInterpolator( interpolator );
>         Resampler->SetInput( MovReader->GetOutput() );
>         Resampler->SetUseReferenceImage( true );
>         Resampler->SetReferenceImage( FixReader->GetOutput() );
>         Resampler->SetDefaultPixelValue( 100 ); // highlight outside regions
>
>
> Is that right?  This would resample the moving image from MovReader into the
> fixed image (based on size, origin, spacing, direction from the FixReader
> reference).
>
> TIA,
> Darren
>
>


More information about the Insight-users mailing list