Resampling by halfing spacing in Z directions
This commit is contained in:
@ -511,21 +511,22 @@ int itkImageProcessor::load3DSerieFromFiles( std::vector<std::string> v_fnames){
|
||||
////////////////////////*****************//////////////////////////
|
||||
// here is where voume should be resampled IMO
|
||||
|
||||
typedef itk::LinearInterpolateImageFunction<ImageType3D, double>
|
||||
LinearInterpolatorType;
|
||||
// typedef itk::LinearInterpolateImageFunction<ImageType3D, double>
|
||||
// LinearInterpolatorType;
|
||||
|
||||
|
||||
typedef itk::ResampleImageFilter<ImageType3D, ImageType3D>
|
||||
ResampleFilterType;
|
||||
// typedef itk::ResampleImageFilter<ImageType3D, ImageType3D>
|
||||
// ResampleFilterType;
|
||||
|
||||
// 2) Resample the series
|
||||
typename LinearInterpolatorType::Pointer linearInterpolator = LinearInterpolatorType::New();
|
||||
LinearInterpolatorType::Pointer
|
||||
linearInterpolator = LinearInterpolatorType::New();
|
||||
|
||||
// Set identity transform
|
||||
typename TransformType::Pointer transform = TransformType::New();
|
||||
TransformType::Pointer
|
||||
transform = TransformType::New();
|
||||
transform->SetIdentity();
|
||||
|
||||
|
||||
const typename ImageType3D::SpacingType& inputSpacing =
|
||||
imageSeriesReader3D->GetOutput()->GetSpacing();
|
||||
const typename ImageType3D::RegionType& inputRegion =
|
||||
@ -533,26 +534,37 @@ int itkImageProcessor::load3DSerieFromFiles( std::vector<std::string> v_fnames){
|
||||
const typename ImageType3D::SizeType& inputSize =
|
||||
inputRegion.GetSize();
|
||||
|
||||
typename ImageType3D::SpacingType outputSpacing;
|
||||
// Inputs Info
|
||||
// std::cout << "inputSpacing " << std::endl;
|
||||
// std::cout << inputSpacing << std::endl;
|
||||
// std::cout << "inputRegion " << std::endl;
|
||||
// std::cout << inputRegion << std::endl;
|
||||
// std::cout << "inputSize " << std::endl;
|
||||
// std::cout << inputSize << std::endl;
|
||||
|
||||
|
||||
ImageType3D::SpacingType outputSpacing;
|
||||
outputSpacing[0] = inputSpacing[0];
|
||||
outputSpacing[1] = inputSpacing[1];
|
||||
outputSpacing[2] = inputSpacing[2]/2;
|
||||
|
||||
ImageType3D::SizeType outputSize;
|
||||
// typedef typename ImageType3D::SizeType::SizeValueType SizeValueType;
|
||||
outputSize[0] = static_cast<SizeValueType>(
|
||||
inputSize[0] * inputSpacing[0] / outputSpacing[0] + .5);
|
||||
outputSize[1] = static_cast<SizeValueType>(
|
||||
inputSize[1] * inputSpacing[1] / outputSpacing[1] + .5);
|
||||
outputSize[2] = static_cast<SizeValueType>(
|
||||
inputSize[2] * inputSpacing[2] / outputSpacing[2] + .5);
|
||||
|
||||
typename ImageType3D::SizeType outputSize;
|
||||
typedef typename ImageType3D::SizeType::SizeValueType SizeValueType;
|
||||
outputSize[0] = static_cast<SizeValueType>(inputSize[0] * inputSpacing[0] / outputSpacing[0] + .5);
|
||||
outputSize[1] = static_cast<SizeValueType>(inputSize[1] * inputSpacing[1] / outputSpacing[1] + .5);
|
||||
outputSize[2] = static_cast<SizeValueType>(inputSize[2] * inputSpacing[2] / outputSpacing[2] + .5);
|
||||
|
||||
typename ResampleFilterType::Pointer resampler = ResampleFilterType::New();
|
||||
ResampleInputFilterType::Pointer
|
||||
resampler = ResampleInputFilterType::New();
|
||||
|
||||
resampler->SetInput( imageSeriesReader3D->GetOutput() );
|
||||
resampler->SetTransform( transform );
|
||||
|
||||
resampler->SetInterpolator( linearInterpolator );
|
||||
|
||||
|
||||
resampler->SetOutputOrigin( imageSeriesReader3D->GetOutput()->GetOrigin() );
|
||||
resampler->SetOutputSpacing( outputSpacing );
|
||||
resampler->SetOutputDirection( imageSeriesReader3D->GetOutput()->GetDirection() );
|
||||
@ -560,6 +572,22 @@ int itkImageProcessor::load3DSerieFromFiles( std::vector<std::string> v_fnames){
|
||||
resampler->Update();
|
||||
|
||||
|
||||
// const ImageType3D::SpacingType& outSpacing =
|
||||
// resampler->GetOutput()->GetSpacing();
|
||||
// const ImageType3D::RegionType& outRegion =
|
||||
// resampler->GetOutput()->GetLargestPossibleRegion();
|
||||
// const ImageType3D::SizeType& outSize =
|
||||
// outRegion.GetSize();
|
||||
|
||||
// Resampled Info
|
||||
// std::cout << "outSpacing " << std::endl;
|
||||
// std::cout << outSpacing << std::endl;
|
||||
// std::cout << "outRegion " << std::endl;
|
||||
// std::cout << outRegion << std::endl;
|
||||
// std::cout << "outSize " << std::endl;
|
||||
// std::cout << outSize << std::endl;
|
||||
|
||||
|
||||
////////////////////////*****************//////////////////////////
|
||||
|
||||
CastFilterType3D::Pointer caster3D =
|
||||
|
@ -290,6 +290,11 @@ private:
|
||||
using ImageIOType = itk::GDCMImageIO;
|
||||
using DuplicatorType = itk::ImageDuplicator<InternalImageType>;
|
||||
|
||||
/** Image input resampling Types */
|
||||
using ResampleInputFilterType = itk::ResampleImageFilter<ImageType3D, ImageType3D>;
|
||||
using LinearInterpolatorType = itk::LinearInterpolateImageFunction<ImageType3D, double>;
|
||||
using SizeValueType = ImageType3D::SizeType::SizeValueType;
|
||||
|
||||
/** widely used filters: flip, cast, rescale, ... */
|
||||
using Input2DRescaleFilterType = itk::RescaleIntensityImageFilter<InternalImageType, InternalImageType>;
|
||||
using CastFilterType3D = itk::CastImageFilter<ImageType3D, InternalImageType>;
|
||||
|
Reference in New Issue
Block a user