Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Task F. Pixelate Program pixelate.cpp will be pixelating the input image. Exampl

ID: 3706506 • Letter: T

Question

Task F. Pixelate Program pixelate.cpp will be pixelating the input image. Example One way to pixelate an image is to effectively make every 2x2 non-overlapping window contain the same value (averaged over all the pixels in that window of the input). For example, the following mage 10 20 30 40 11 21 31 41 12 22 32 42 13 23 33 43 should be transformed to 16 16 36 36 16 16 36 36 18 18 37 37 18 18 37 37 where the 16 was computed by averaging 10, 20, 11, and 21 (after rounding), and so on. For simplicity, assume that the width and the height of the image are even numbers, so the picture is divisible into small 2x2 squares, like in the example above.

Explanation / Answer

/* Author: > c; assert(c == 'P'); instr >> c; assert(c == '2'); // skip the comments (if any) while ((instr>>ws).peek() == '#') { instr.ignore(4096, ' '); } instr >> width; instr >> height; assert(width max; assert(max == 255); for (int row = 0; row image[row][col]; instr.close(); return; } // Writes a PGM file // Need to provide the array data and the image dimensions void writeImage(int image[MAX_H][MAX_W], int height, int width) { ofstream ostr; ostr.open("outImage.pgm"); if (ostr.fail()) { cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote