C++
C#
VB
JScript
All

Images


Copyright (C) 2005 IENT-RWTH Aachen

The image.h header file defines some usual image types and color spaces. Every image type is derived from a dense matrix.

Every needed file format has to be explicitly included.

This example loads an image, calculates its grey scale and stores it.

#include "image/image.h"
#include "image/ppm.h" // PPM format: uncompressed RGB image
#include "image/pgm.h" // PGM format: uncompressed grey scaled image
    
int main()
{
  try
  {
    PPMFile fin("x.ppm"); // the file in PPM format
    RGBImage X;
    fin >> X; //load the file
      
    PGMFile fout("y.pgm"); // The output file in PGM format
    fout << first(value_cast<YUV>(X)); // converts each pixel from RGB in YUV, takes the first component (Y), stores
  } catch (const error &e) { cout << e.what() << endl; return 1; } // a problem occured?
  return 0;
}

See Also

Tutorial