imageIO_tutorial.cxx
|
 |
A complete image I/O example
Usage: imageIO_tutorial infile outfile
#include <iostream>
#include <vigra/multi_array.hxx>
#include <vigra/stdimage.hxx>
int main(int argc, char ** argv)
{
if(argc != 3)
{
std::cout << "Usage: " << argv[0] << " infile outfile" << std::endl;
std::cout <<
"(grayscale only, supported formats: " <<
impexListFormats() <<
")" << std::endl;
return 1;
}
try
{
char * in_filename = argv[1];
char * out_filename = argv[2];
ImageImportInfo imageInfo(in_filename);
MultiArray<2, UInt8> imageArray(imageInfo.shape());
for (int i = 0; i<imageInfo.height(); i+=2)
{
imageArray.bind<1>(i) = 0;
}
exportImage(imageArray, ImageExportInfo(out_filename));
}
catch (std::exception & e)
{
std::cout << e.what() << std::endl;
return 1;
}
return 0;
}
void importImage(...)
Read an image from a file.
void exportImage(...)
Write an image to a file.
image import and export functions
std::string impexListFormats()
List the image formats VIGRA can read and write.