int
main(int argc, char * argv[])
{
if (argc < 6)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0]
<< " inputImageFile outputImageFile factorX factorY factorZ"
<< std::endl;
return EXIT_FAILURE;
}
using InputPixelType = unsigned char;
using InternalPixelType = float;
using OutputPixelType = unsigned char;
reader->SetFileName(argv[1]);
const double factorX = std::stod(argv[3]);
const double factorY = std::stod(argv[4]);
const double factorZ = std::stod(argv[5]);
try
{
reader->Update();
}
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << excep << std::endl;
}
using CastFilterType =
caster->SetInput(inputImage);
using GaussianFilterType =
smootherX->SetInput(caster->GetOutput());
smootherY->SetInput(smootherX->GetOutput());
smootherZ->SetInput(smootherY->GetOutput());
const InputImageType::SpacingType & inputSpacing = inputImage->GetSpacing();
const double sigmaX = inputSpacing[0] * factorX;
const double sigmaY = inputSpacing[1] * factorY;
const double sigmaZ = inputSpacing[2] * factorZ;
smootherX->SetSigma(sigmaX);
smootherY->SetSigma(sigmaY);
smootherZ->SetSigma(sigmaZ);
smootherX->SetDirection(0);
smootherY->SetDirection(1);
smootherZ->SetDirection(2);
smootherX->SetNormalizeAcrossScale(false);
smootherY->SetNormalizeAcrossScale(false);
smootherZ->SetNormalizeAcrossScale(false);
using ResampleFilterType =
transform->SetIdentity();
resampler->SetTransform(transform);
using InterpolatorType =
resampler->SetInterpolator(interpolator);
resampler->SetDefaultPixelValue(0);
OutputImageType::SpacingType spacing;
spacing[0] = inputSpacing[0] * factorX;
spacing[1] = inputSpacing[1] * factorY;
spacing[2] = inputSpacing[2] * factorZ;
resampler->SetOutputSpacing(spacing);
resampler->SetOutputOrigin(inputImage->GetOrigin());
resampler->SetOutputDirection(inputImage->GetDirection());
inputImage->GetLargestPossibleRegion().
GetSize();
resampler->SetSize(size);
resampler->SetInput(smootherZ->GetOutput());
writer->SetInput(resampler->GetOutput());
writer->SetFileName(argv[2]);
try
{
writer->Update();
}
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << excep << std::endl;
}
std::cout << "Resampling Done !" << std::endl;
return EXIT_SUCCESS;
}
Casts input pixels to output pixel type.
Standard exception handling object.
Data source that reads image data from a single file.
Writes image data to a single file.
Templated n-dimensional image class.
Linearly interpolate an image at specified positions.
Base class for computing IIR convolution with an approximation of a Gaussian kernel.
Resample an image via a coordinate transform.
SmartPointer< const Self > ConstPointer
constexpr unsigned int Dimension
ImageBaseType::SizeType SizeType
unsigned long SizeValueType
const SizeValueType * GetSize() const