[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

imageImportInfo_tutorial.cxx

Read an image and print its header information
Usage: imageImportInfo_tutorial infile

#include <iostream>
#include <vigra/impex.hxx>
int main(int argc, char ** argv)
{
if(argc != 2)
{
std::cout << "Usage: " << argv[0] << " infile" << std::endl;
std::cout << "(supported formats: " << vigra::impexListFormats() << ")" << std::endl;
return 1;
}
try
{
// read image given as first command-line argument
vigra::ImageImportInfo imageInfo(argv[1]);
// print some information:
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)
{
// catch any errors that might have occurred (e.g. "file not found") and print their reason
std::cout << e.what() << std::endl;
return 1;
}
return 0;
}
vigra::ImageImportInfo
Argument object for the function importImage().
Definition imageinfo.hxx:391
vigra::ImageImportInfo::getPixelType
const char * getPixelType() const
vigra::ImageImportInfo::numBands
int numBands() const
vigra::ImageImportInfo::height
int height() const
vigra::ImageImportInfo::width
int width() const
vigra::ImageImportInfo::isColor
bool isColor() const
vigra::ImageImportInfo::getFileType
const char * getFileType() const
impex.hxx
image import and export functions
vigra::impexListFormats
std::string impexListFormats()
List the image formats VIGRA can read and write.

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python vigra 1.12.4