Wednesday, June 01, 2005

Allocate 2D image array, two dimensional array memory allocation

unsigned char **pixel;

pixel = new unsigned char *[N_rows];
for(i=0;i < N_rows;i++){
pixel[i] = new unsigned char[N_columns];
}

for(i=0;i < N_rows;i++){
for(j=0;j < N_columns;j++){
pixel[i][j] = ... }
}

for(i=0;i < N_rows;i++){
delete [] pixel[i];
}
delete []pixel;


No comments:

Post a Comment