Hi Elli, The OutputOrigin and OutputDirection may need to be set so the sampling grids overlap.
HTH, Matt On Fri, Sep 8, 2017 at 9:13 AM, Pfaehler, EAG (ngmb) <e.a.g.pfaeh...@umcg.nl> wrote: > Thanks, I did this. Now I get an image, with the desired size, but there all > image values are 0. I get the same when I use linear interpolation… > > Does someone know, what could be the reason? > > > > Thanks in advance, > > > > Regards > > > > Elli > > > > Van: Samuel Gerber [mailto:samuel.ger...@kitware.com] > Verzonden: vrijdag 8 september 2017 14:51 > Aan: Pfaehler, EAG (ngmb) > CC: insight-developers@itk.org > Onderwerp: Re: [ITK] [ITK-dev] problems itk resample filter > > > > I believe you might need to call resizeFilter2->Update() > > > > > > > > On Fri, Sep 8, 2017 at 8:32 AM, Pfaehler, EAG (ngmb) > <e.a.g.pfaeh...@umcg.nl> wrote: > > Dear all, > > > > I would need some help to resample so that it has isotropic voxels in the > end. > > For this, I wanted to use the Nearest Neighbor Interpolator and the > ResampleFilterType. > > My code is running, but the output of the filter has always the dimensions > [0 0 0], so is not existent. > > What am I doing wrong? (see code below) > > > > Thanks in advance! > > Elli > > > > typedef itk::NearestNeighborInterpolateImageFunction<ImageType, T> > NearestNeighborInterpolatorType; > > typedef itk::ResampleImageFilter<ImageType, ImageType> > ResampleFilterType; > > typedef itk::AffineTransform <double, 3> TransformType; > > //use nearest neighbor interpolation > > typename NearestNeighborInterpolatorType::Pointer > nearestNeighborInterpolator = NearestNeighborInterpolatorType::New(); > > typename ImageType::DirectionType direction; > > typename TransformType::Pointer transform = TransformType::New(); > > //transform->SetIdentity(); > > typedef itk::NearestNeighborInterpolateImageFunction<ImageType, double> > InterpolatorType; > > //typedef itk::LinearInterpolateImageFunction<ImageType, double > > InterpolatorType; > > typename InterpolatorType::Pointer interpolator = InterpolatorType::New(); > > > > typename ResampleFilterType::Pointer resizeFilter2 = > ResampleFilterType::New(); > > resizeFilter2->SetTransform(transform); > > > > resizeFilter2->SetInterpolator( interpolator ); > > resizeFilter2->SetDefaultPixelValue(0); > > //resizeFilter2->SetInterpolator(); > > > > const typename ImageType::SpacingType& inputSpacing = image->GetSpacing(); > > //sampling > > double outputSpacing[3]; > > // Fetch original image size > > const typename ImageType::RegionType& inputRegion = > image->GetLargestPossibleRegion(); > > const typename ImageType::SizeType& inputSize = inputRegion.GetSize(); > > unsigned int oldWidth = inputSize[0]; > > unsigned int oldHeight = inputSize[1]; > > unsigned int oldDepth = inputSize[2]; > > unsigned int newWidth; > > unsigned int newHeight; > > unsigned int newDepth; > > //get the new height etc of image > > double minimum = inputSpacing[0]; > > if (inputSpacing[1]<minimum){ > > minimum = inputSpacing[1]; > > } > > if (inputSpacing[2] < minimum){ > > minimum = inputSpacing[2]; > > } > > outputSpacing[0] = minimum; > > outputSpacing[1] = minimum; > > outputSpacing[2] = minimum; > > newWidth = (double) oldWidth * inputSpacing[0]/minimum; > > ewHeight = (double) oldHeight * inputSpacing[1]/minimum; > > newDepth = (double) oldDepth * inputSpacing[2]/minimum; > > // Set the output spacing as specified on the command line > > resizeFilter2->SetOutputSpacing(outputSpacing); > > // Set the computed size > > itk::Size<3> outputSize = { {newWidth, newHeight, newDepth} }; > > resizeFilter2->SetSize(outputSize); > > // Specify the input for the resamplers > > resizeFilter2->SetInput(image); > > ImageType::Pointer imageNew = resizeFilter2->GetOutput(); > > const typename ImageType::RegionType& outputRegion = > imageNew->GetLargestPossibleRegion(); > > const typename ImageType::SizeType& outputSize2 = > outputRegion.GetSize(); > > > > ________________________________ > > De inhoud van dit bericht is vertrouwelijk en alleen bestemd voor de > geadresseerde(n). Anderen dan de geadresseerde(n) mogen geen gebruik maken > van dit bericht, het niet openbaar maken of op enige wijze verspreiden of > vermenigvuldigen. Het UMCG kan niet aansprakelijk gesteld worden voor een > incomplete aankomst of vertraging van dit verzonden bericht. > > The contents of this message are confidential and only intended for the eyes > of the addressee(s). Others than the addressee(s) are not allowed to use > this message, to make it public or to distribute or multiply this message in > any way. The UMCG cannot be held responsible for incomplete reception or > delay of this transferred message. > > > _______________________________________________ > 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://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-developers > > _______________________________________________ > Community mailing list > commun...@itk.org > http://public.kitware.com/mailman/listinfo/community > > > > > > -- > > Samuel Gerber > R&D Engineer > Kitware, Inc. > > ________________________________ > De inhoud van dit bericht is vertrouwelijk en alleen bestemd voor de > geadresseerde(n). Anderen dan de geadresseerde(n) mogen geen gebruik maken > van dit bericht, het niet openbaar maken of op enige wijze verspreiden of > vermenigvuldigen. Het UMCG kan niet aansprakelijk gesteld worden voor een > incomplete aankomst of vertraging van dit verzonden bericht. > > The contents of this message are confidential and only intended for the eyes > of the addressee(s). Others than the addressee(s) are not allowed to use > this message, to make it public or to distribute or multiply this message in > any way. The UMCG cannot be held responsible for incomplete reception or > delay of this transferred message. > > _______________________________________________ > 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://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-developers > _______________________________________________ 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://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-developers