ITK  4.8.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];
typedef itk::Image<itk::CovariantVector<float, 3>, 2> FloatImageType;
typedef itk::Image<itk::CovariantVector<unsigned char, 3>, 2> UnsignedCharImageType;
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;
}