imageImportInfo_tutorial.cxx
|
|
Read an image and print its header information
Usage: imageImportInfo_tutorial infile
#include <iostream>
int main(int argc, char ** argv)
{
if(argc != 2)
{
std::cout << "Usage: " << argv[0] << " infile" << std::endl;
return 1;
}
try
{
std::cout << "Image information:\n";
std::cout <<
" file format: " << imageInfo.
getFileType() << std::endl;
std::cout <<
" width: " << imageInfo.
width() << std::endl;
std::cout <<
" height: " << imageInfo.
height() << std::endl;
std::cout <<
" pixel type: " << imageInfo.
getPixelType() << std::endl;
std::cout << " color image: ";
if (imageInfo.
isColor()) std::cout <<
"yes (";
else std::cout << "no (";
std::cout <<
"number of channels: " << imageInfo.
numBands() <<
")\n";
}
catch (std::exception & e)
{
std::cout << e.what() << std::endl;
return 1;
}
return 0;
}