The Image class reads and write images, and is responsible for simple image processing tasks.

The supported image formats are: pbm, pgm, ppm, and jpeg.

  • name_ stores image name with format;
  • width_, height_, and channel_ store the dimensions of the image.
  • vector<vector<unsigned char> > m_image stores the image data.
int read(const string r_name);
int write(const string r_name);

methods to read from an image and write to an image. The format is determined by the format in the image name.

static int read_pbm(const string r_name, vector<unsigned char>& r_image, int &r_width, int &r_height);
static int write_pbm(const string r_name, vector<unsigned char>& r_image, int &r_width, int &r_height);

methods to read from and write to a pbm image.

static int read_pgm(const string r_name, vector<unsigned char>& r_image, int& r_width, int& r_height);
static int write_pgm(const string r_name, vector<unsigned char>& r_image, int& r_width, int& r_height);

methods to read from and write to a pgm image.

static int read_ppm(const string r_name, vector<unsigned char>& r_image, int& r_width, int& r_height, int& r_channel);
static int write_ppm(const string r_name, vector<unsigned char>& r_image, int& r_width, int& r_height, int& r_channel);

methods to read from and write to a ppm image.

static int read_jpeg(const string r_name, vector<unsigned char>& r_image, int& r_width, int& r_height, int& r_channel);
static void write_jpeg(const string r_name, vector<unsigned char>& r_image, int& r_width, int& r_height, int& r_channel, const int flip = 0);

methods to read from and write to a jpeg image.

const unsigned char operator[](int ind) const;
unsigned char& operator[](int ind);

methods to access the pixel intensity/color value.

void rgb2grey(const Image& img);

convert an rgb image into a grey-scale image.

const int& width() const;
const int& height() const;
const int& channel() const;
const string& name() const;

methods to retrieve image information