[Insight-users] Using ResampleImageFilter and OutputOrigin to resample and spatially center two volumes.

Luis Ibanez luis.ibanez at kitware.com
Sat May 21 15:37:09 EDT 2011


Hi Jan,

The CheckerBoardFilter ignores the values of the image Origin
(at least the one that is given in physical coordinates).


Could you please post screenshots of what you are getting,
preferably to a public web site. ?

And also, provide some annotation of what you are hopping
to get ?


    Thanks


            Luis


----------------------------
On Mon, May 16, 2011 at 12:30 PM, Jan Margeta <jmargeta at gmail.com> wrote:
> Hi all,
>
> This is to follow up on my previous question on ResampleImageFilter where I
> wanted to resample a volume
> to new spacing, direction and size. I would like to be able to have the
> resampled volumes aligned when visualized
> (i.e. if I would do a checkerboard visualization, the edges would
> correspond).
>
> The default behaviour is that the images are aligned with their borders and
> the extrapolated values (or null regions)
> appear only on half of the sides. The alignement works perfectly.
>
> However, I would now like to have the resulting image region be centered
> with the original image so that the extrapolated
> value regions are equal all both sides and also have the images intensity
> values well aligned.
>
> Therefore I would expect that when I appropriatelly change the OutputOrigin
> in the resampler, the images will be
> sampled and aligned properly and the volumes centered in space at the same
> time.
>
> What I get instead are two volumes that whose outlines are centered as I
> would want, but the image intensity
> values do not correspond anymore (checkerboard edges do not correspond at
> all). What did I forget?
> Or is there any better way?
>
> Here is the piece of code:
>
>     typedef itk::ResampleImageFilter< InputImageType, InputImageType >
> ResampleFilterType;
>
>     // Calculate new origin to center the images
>     ResampleFilterType::PointType oldOrigin =
> inputReader->GetOutput()->GetOrigin();



Have you *already* called

                            inputReader->Update()

before these lines ?



>     ResampleFilterType::PointType newOrigin; newOrigin.Fill(0);
>
>     for(size_t i = 0; i < 3; ++i)
>     {
>         double oldPhysicalSize = inputSpacing[i]*inputSize[i];
>         double newPhysicalSize = outputSpacing[i]*outputSize[i];
>
>         newOrigin[i] = oldOrigin[i] +
>             0.5*(outputSpacing[i] - inputSpacing[i] +
>                  oldPhysicalSize - newPhysicalSize);
>
>     }
>
>
>     ResampleFilterType::Pointer resampler = ResampleFilterType::New();
>     resampler->SetInput( inputReader->GetOutput() );
>     resampler->SetTransform( transform );
>     resampler->SetInterpolator( interpolator );
>     resampler->SetOutputOrigin( newOrigin );
>     resampler->SetOutputSpacing( outputSpacing );
>     resampler->SetOutputDirection(
> inputReader->GetOutput()->GetDirection());
>     resampler->SetSize( outputSize );
>     resampler->SetDefaultPixelValue(0);
>     resampler->Update();
>
> The reader is just an instance of itk::ImageSeriesReader<InputImageType>,
> interpolation is linear, transformation is set to identity
>
>
> Many thanks,
>
> Jan
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>


More information about the Insight-users mailing list