ITK  4.9.0
Insight Segmentation and Registration Toolkit
WikiExamples/ImageProcessing/CastImageFilter.cxx
#include "itkImage.h"
#include "QuickView.h"
int main(int argc, char *argv[])
{
if(argc < 2)
{
std::cerr << "Required: filename" << std::endl;
return EXIT_FAILURE;
}
std::string fileName = argv[1];
std::cout << "FileName: " << fileName << std::endl;
typedef itk::Image<unsigned char, 2> UnsignedCharImageType;
typedef itk::Image<float, 2> FloatImageType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(fileName);
CastFilterType::Pointer castFilter = CastFilterType::New();
castFilter->SetInput(reader->GetOutput());
QuickView viewer;
viewer.AddImage<FloatImageType>(reader->GetOutput());
viewer.AddImage<UnsignedCharImageType>(castFilter->GetOutput());
viewer.Visualize();
return EXIT_SUCCESS;
}