int
main(int argc, char * argv[])
{
if (argc < 5)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile outputImageFile lower upper "
<< std::endl;
return EXIT_FAILURE;
}
using InputPixelType = unsigned short;
using InternalPixelType = float;
reader->SetFileName(argv[1]);
try
{
reader->Update();
}
{
std::cerr << "Exception caught!" << std::endl;
std::cerr << excep << std::endl;
}
using IntensityFilterType =
intensityWindowing->SetWindowMinimum(std::stoi(argv[3]));
intensityWindowing->SetWindowMaximum(std::stoi(argv[4]));
intensityWindowing->SetOutputMinimum(0.0);
intensityWindowing->SetOutputMaximum(
255.0);
intensityWindowing->SetInput(reader->GetOutput());
using GaussianFilterType =
smootherX->SetInput(intensityWindowing->GetOutput());
smootherY->SetInput(smootherX->GetOutput());
const InputImageType::SpacingType & inputSpacing = inputImage->GetSpacing();
const double isoSpacing = std::sqrt(inputSpacing[2] * inputSpacing[0]);
smootherX->SetSigma(isoSpacing);
smootherY->SetSigma(isoSpacing);
smootherX->SetDirection(0);
smootherY->SetDirection(1);
using OutputPixelType = unsigned char;
using ResampleFilterType =
transform->SetIdentity();
resampler->SetTransform(transform);
using InterpolatorType =
resampler->SetInterpolator(interpolator);
resampler->SetDefaultPixelValue(255);
OutputImageType::SpacingType spacing;
spacing[0] = isoSpacing;
spacing[1] = isoSpacing;
spacing[2] = isoSpacing;
resampler->SetOutputSpacing(spacing);
resampler->SetOutputOrigin(inputImage->GetOrigin());
resampler->SetOutputDirection(inputImage->GetDirection());
inputImage->GetLargestPossibleRegion().
GetSize();
const double dx = inputSize[0] * inputSpacing[0] / isoSpacing;
const double dy = inputSize[1] * inputSpacing[1] / isoSpacing;
const double dz = (inputSize[2] - 1) * inputSpacing[2] / isoSpacing;
size[0] = static_cast<SizeValueType>(dx);
size[1] = static_cast<SizeValueType>(dy);
size[2] = static_cast<SizeValueType>(dz);
resampler->SetSize(size);
resampler->SetInput(smootherY->GetOutput());
resampler->Update();
writer->SetFileName(argv[2]);
writer->SetInput(resampler->GetOutput());
try
{
writer->Update();
}
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << excep << std::endl;
}
return EXIT_SUCCESS;
}