I'm testing the greyscale function for the filter problem in the Memory problem set. The compiler doesn't seem to have a problem with the code, but when I type in the command (./filter -g yard.bmp out.bmp) in the compiler,, it returns "Could not open yard.bmp."
As far as I can see the file name match those in the directory and the infile is the same directroy as the outfile (see below).
Some pointers in the right direction would be appreciated, below is my code:
void grayscale(int height, int width, RGBTRIPLE image[height][width])
{
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++) {
int red = image[i][j].rgbtRed;
int green = image[i][j].rgbtGreen;
int blue = image[i][j].rgbtBlue;
int average = (red + green + blue) / 3.0;
int new_value = round((double)average);
red = 255 - new_value;
green = 255 - new_value;
blue = 255 - new_value;
}
}
I typed in the command expecting the out.bmp to appear in greyscale.