As an example, consider the 4x3 image below on the left (there are three rows, four columns), a 3x2 expansion replaces each pixel by a 3x2 rectangle of the same pixel resulting in the image on the right. Note that the resulting image is 12x6. Note that the expansion is specified essentially by the size of the rectangle of pixels that "replaces" each original pixel.
abcd aaabbbcccddd
efgh aaabbbcccddd
xyzw eeefffggghhh
eeefffggghhh
xxxyyyzzzwww
xxxyyyzzzwww
The image is given as an array of pixels in row-major order, that is the pixels are listed moving across rows and then down the columns.
Write the method expand that returns an int[]
representing the expansion of the image given by
parameters pixels , rows, and
cols. The size of the expansion is given by the
added parameters. See the examples for details.
pixels contains no more than 200 elements.
pixels is between 0 and 255 inclusive.
int parameters are positive
{1}
1
1
3
4
Returns: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
{1, 2, 3, 4}
2
2
2
2
Returns: {1, 1, 2, 2, 1, 1, 2, 2, 3, 3, 4, 4, 3, 3, 4, 4}
{1, 2, 3, 4, 5, 6, 7, 8}
2
4
2
1
Returns: {1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 7, 8, 5, 6, 7, 8}