Hello everybody I am writing a c++ code that reads a ppm image and print the average brightness of the image.I have created a Color class that contains the pixels of the image as a red , green, blue triplet. I have an Image class that represents a generic data container for an image(width,height and a pointer that hold the image data).I also have readppm method that reads the image file and create an image object.My question is how can I find the average brightness of the image in my main class. Here is the main app:
using namespace std;
#include <iostream>
#include "ppm_format.h"
#include "Image.h"
#include "Color.h"
using namespace imaging;
int main() {
char fname[50];
cout << "Please enter the file name: ";
cin >> fname;
Image *img = ReadPPM(fname);
cout <<"Image Width :" << img->getWidth() << endl;
cout << "Image Height :" << img->getHeight() << endl;
int sum_r = 0;
int sum_g = 0;
int sum_b = 0;
for (int i = 0; i < img->getWidth(); i++) {
for (j = 0; j < img->getHeight(); j++) {
Color pix = img->getPixel(i,j);
}
}
}
Any help is appreciated.