I am working on homework for an image reduction program in C ++. My photo is represented by a two-dimensional array of pixels; each pixel is an object with elements of "red", "green" and "blue". To solve the problem, I try to access a 2D array one block at a time, and then call a function that finds the average RGB value for each block and adds a new pixel to a smaller array of images. The size of each block (or scale factor) is entered by the user.
As an example, imagine a 2D array of 100 elements, for example myArray [10] [10]. If the user enters a compression ratio of 3, I will need to split the mini-2D arrays of size 3 by 3. I do not need to take into account overflow, so in this example I can ignore the last row and last column.

I have most of the written program, including a function for finding the middle color. I am confused about how to navigate a 2D array. I know how to cycle through a 2D array sequentially (one row at a time), but I'm not sure how to get the small squares in the array.
Any help would be greatly appreciated!
kelly
source share