[ITK] [ITK-users] Resampler to itk::image

Dženan Zukić dzenanz at gmail.com
Fri Dec 1 09:22:54 EST 2017


Hi Andrea,

what you are missing is resampler->Update();

Regards,
Dženan

On Fri, Dec 1, 2017 at 4:49 AM, AR_univr via Insight-users <
insight-users at itk.org> wrote:

> Hi,
> I'm having problems to convert Resampler Output to itk::Image .
> Here a snippet of what i'm doing :
>
>     const     unsigned int   ImageDimension = 3;
>     typedef   unsigned char  PixelType;
>     typedef   itk::Image< PixelType, ImageDimension > InputImageType;
>     typedef   itk::ResampleImageFilter< InputImageType,     InputImageType
> >  ResamplerType;
>     . . .
>     InputImageType::Pointer inputImage =  . . .
>
>     ResamplerType::Pointer resampler = ResamplerType::New();
>     InterpolatorType::Pointer interpolator = InterpolatorType::New();
>     resampler->SetInterpolator(interpolator);
>     InputImageType::SpacingType spacing = inputImage->GetSpacing();
>     InputImageType::PointType   origin = inputImage->GetOrigin();
>     InputImageType::DirectionType direction = inputImage->GetDirection();
>     InputImageType::RegionType region = inputImage->GetBufferedRegion();
>     InputImageType::SizeType   size = region.GetSize();
>
>     resampler->SetOutputSpacing(spacing);
>     resampler->SetOutputDirection(direction);
>     resampler->SetOutputOrigin(origin);
>     resampler->SetSize(size);
>     resampler->SetTransform(tps);
>
>     resampler->SetOutputStartIndex(region.GetIndex());
>     resampler->SetInput(inputImage);
>
>     std::cout << "[resampler] Written Origin   : " <<
> resampler->GetOutputOrigin()[0] << ", " << resampler->GetOutputOrigin()[1]
> << ", " << resampler->GetOutputOrigin()[2] << std::endl;
>     std::cout << "[resampler] Written Spacing  : " <<
> resampler->GetOutputSpacing()[0] << ", " << resampler->GetOutputSpacing()[
> 1]
> << ", " << resampler->GetOutputSpacing()[2] << std::endl;        std::cout
> << "[resampler] size : " << resampler->GetSize() << std::endl;
>     std::cout << "[resampler] transform : " << resampler->GetTransform() <<
> std::endl;
>     std::cout << "[resampler] num of outs : " <<
> resampler->GetNumberOfOutputs() << std::endl;
>     std::cout << "[resampler] Written Direction: \n" <<
> resampler->GetOutputDirection() << std::endl;
>
>
> Up to here i have the values, and it seems it's working.
> But when i do
>
>    InputImageType::Pointer output = resampler->GetOutput();
>
> output is empty, and i dont know why... Am i missing something?
>
> any help would be appreciated
>
> Thanks !
>
> Andrea
>
>
>
> --
> Sent from: http://itk-insight-users.2283740.n2.nabble.com/
> The ITK community is transitioning from this mailing list to
> discourse.itk.org. Please join us there!
> ________________________________
> 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.php
>
> 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://public.kitware.com/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20171201/c7ff70db/attachment.html>
-------------- next part --------------
The ITK community is transitioning from this mailing list to discourse.itk.org. Please join us there!
________________________________
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.php

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://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list