//函数化 升采样 重置大小
void Resize(ImageType::Pointer input,ImageType::Pointer src,ImageType::Pointer* dst)
{
std::cout <<"----升采样----"<< std::endl;
typedef itk::ResampleImageFilter<ImageType, ImageType> ResampleImageFilterType;
ResampleImageFilterType::Pointer resample = ResampleImageFilterType::New();
resample->SetInput(input);
typedef itk::AffineTransform<double,2> TransformType;
TransformType::Pointer transform = TransformType::New();
resample->SetTransform(transform);
typedef itk::NearestNeighborInterpolateImageFunction<ImageType,double> InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
resample->SetInterpolator(interpolator);
resample->SetDefaultPixelValue(0);
resample->SetSize(src->GetLargestPossibleRegion().GetSize());
resample->SetOutputSpacing(src->GetSpacing());
resample->SetOutputOrigin(src->GetOrigin());
ImageType2D::DirectionType direction;
direction.SetIdentity();
resample->SetOutputDirection(direction);
try
{
resample->UpdateLargestPossibleRegion();
}
catch( itk::ExceptionObject & exp )
{
cerr << "Exception caught !" << std::endl;
cerr << exp << std::endl;
}
*dst = resample->GetOutput();
}