So i'm doing filter and I noticed that its not rounding up correctly.
// Convert image to grayscale
void grayscale(int height, int width, RGBTRIPLE image[height][width])
{
// Iterate over height
for (int h = 0; h < height; h++)
{
// Iterare over width
for (int w = 0; w < width; w++)
{
// Calculate the average of rgbt
int k = round((image[h][w].rgbtBlue + image[h][w].rgbtGreen + image[h][w].rgbtRed)/3);
// Update rgbt
image[h][w].rgbtBlue = k;
image[h][w].rgbtGreen = k;
image[h][w].rgbtRed = k;
}
}
return;
}
:) helpers.c exists
:) filter compiles
:) grayscale correctly filters single pixel with whole number average
:( grayscale correctly filters single pixel without whole number average expected "28 28 28\n", not "27 27 27\n"
:) grayscale leaves alone pixels that are already gray
:) grayscale correctly filters simple 3x3 image
:( grayscale correctly filters more complex 3x3 image expected "20 20 20\n50 5...", not "20 20 20\n50 5..."
:( grayscale correctly filters 4x4 image expected "20 20 20\n50 5...", not "20 20 20\n50 5..."
So I tried to run the file to se what was happening and
$ ./filter -g yard.bmp test.bmp
Could not open yard.bmp.