I am stuck on how to perform these transformations on a PPM image.
This is what I have so far, these are close to the solution but a few pixels are wrong for each of them, and I have no idea why?
void vertical_flip(PpmImage &ppm) {
for (unsigned int r = 0; r < ppm.height/2; r++) {
for (unsigned int c = 0; c < ppm.width; c++) {
Pixel temp = ppm.pixels[r][c];
ppm.pixels[r][c] = ppm.pixels[ppm.height-r-1][c];
ppm.pixels[ppm.height-r-1][c] = temp;
}
}
}
void grey_scale(PpmImage &ppm) {
for (unsigned int r = 0; r < ppm.height; r++) {
for (unsigned int c = 0; c < ppm.width; c++) {
Pixel p = ppm.pixels[r][c];
p.r = p.g = p.b = p.r/3.0 + p.g/3.0 + p.b/3.0;
ppm.pixels[r][c] = p;
}
}
}