template<typename TImageType>
static void ReadFile(std::string filename, typename TImageType::Pointer image);
int main(int argc, char *argv[])
{
if(argc < 2)
{
std::cerr << "Required: filename" << std::endl;
return EXIT_FAILURE;
}
std::string inputFilename = argv[1];
if( !imageIO )
{
std::cerr << "Could not CreateImageIO for: " << inputFilename << std::endl;
return EXIT_FAILURE;
}
imageIO->SetFileName(inputFilename);
imageIO->ReadImageInformation();
const ScalarPixelType pixelType = imageIO->GetComponentType();
std::cout << "Pixel Type is " << imageIO->GetComponentTypeAsString(pixelType)
<< std::endl;
const size_t numDimensions = imageIO->GetNumberOfDimensions();
std::cout << "numDimensions: " << numDimensions << std::endl;
std::cout << "component size: " << imageIO->GetComponentSize() << std::endl;
std::cout << "pixel type (string): " << imageIO->GetPixelTypeAsString(imageIO->GetPixelType()) << std::endl;
std::cout << "pixel type: " << imageIO->GetPixelType() << std::endl;
return EXIT_SUCCESS;
}
template<typename TImageType>
void ReadFile(std::string filename, typename TImageType::Pointer image)
{
typename ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(filename);
reader->Update();
image->Graft(reader->GetOutput());
}