ITK  5.0.0
Insight Segmentation and Registration Toolkit
WikiExamples/Images/VectorRescaleIntensityImageFilter.cxx
#include "itkImage.h"
int main(int argc, char *argv[])
{
if(argc < 3)
{
std::cerr << "Required: input output" << std::endl;
return EXIT_FAILURE;
}
std::string inputFilename = argv[1];
std::string outputFilename = argv[2];
using FloatImageType = itk::Image<itk::CovariantVector<float, 3>, 2>;
using UnsignedCharImageType = itk::Image<itk::CovariantVector<unsigned char, 3>, 2>;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(inputFilename);
reader->Update();
VectorRescaleFilterType::Pointer rescaleFilter = VectorRescaleFilterType::New();
rescaleFilter->SetInput(reader->GetOutput());
rescaleFilter->SetOutputMaximumMagnitude(255);
rescaleFilter->Update();
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(outputFilename);
writer->SetInput(rescaleFilter->GetOutput());
writer->Update();
return EXIT_SUCCESS;
}