Multi dimension arrays

I just started working with pictures a little bit and you can see in my code somewhat what I am trying to do but I have commented it out to try a much simpler thing and my code still crashes. Can anyone please tell me what I have done wrong? It seems so simple and I just see no reason why the printf statement causes a crash…

#include "ofApp.h"
int width, height;
ofImage myImage;
void ofApp::setup(){
width = myImage.width;
height = myImage.height;
printf("W: %d   H: %d",width,height);

unsigned char *pixles;
pixles = myImage.getPixels();
unsigned char pixColor[10000][10000];
unsigned char pixBlack[3000][30000];

myImage.setFromPixels((unsigned char*)pixles,width,height,OF_IMAGE_COLOR);

int i,j,counter = 0;
for( i = 0 ; i < 3*height ; i++){
for(j = 0 ; j < 3*width ; j++){
    pixColor[i][j] = *(pixles);
pixColor[0][0] = 15;


images are not bidimensional in memory, they are a 1 dimension array and you access them by calculating the position in the array from the x and y, the formula is x + y * w. or simply by incrementing the position by 1 (or the number of channels in the image) to iterate through the whole image,

the easiest way to work with pixels in OF is by using ofPixels to do the allocation and iterate through the pixels:

ofPixels pixColor, pixBlack;

for(auto line: pixColor){
    for(auto pixel: line){
        pixel[0] = // red
        pixel[1] = // green
        pixel[2] = // blue

if you want to simply copy an image you can just use = like pixels1 = pixels2

I am not sure I follow whats wrong.

The statement:

unsigned char *pixles;
pixles = myImage.getPixels();

myImage.setFromPixels((unsigned char*)pixles,width,height,OF_IMAGE_COLOR);

I believe creates the 1 dimensional array as you are describing. I am then trying to manually separate it into a multi dimensional array of unsigned char. At this point OF should have no idea I am even dealing with an image.

All it would know is I have another matrix of unsigned chars. I should be able the then use them however I like…