I am trying to map the RGB pixels of an image to 2D arrays of R, G, B seperately.
When the image is read the pixels are stored in a 1D array in the form {r1,g1,b1,r2,g2,b2...}.
The length of array is 3*height*width. The 2D arrays will be of width X height dimensions
for(i = 0; i < length; i++) { // length = 3*height*width
image[i][2] = getc(f); // blue pixel
image[i][1] = getc(f); // green pixel
image[i][0] = getc(f); // red pixel
img[count] = (unsigned char)image[i][0];
count += 1;
img[count] = (unsigned char)image[i][1];
count += 1;
img[count] = (unsigned char)image[i][2];
count += 1;
printf("pixel %d : [%d,%d,%d]\n", i+1, image[i][0], image[i][1], image[i][2]);
}
The RGB values are in img[]. The 2d arrays are red[][], green[][] and blue[][].
Please help!