class Pixel { int r, g, b; Pixel(int a, int b, int c) { this.r = a; this.g = b; this.b = c; } } Pixel[][] image2grid(PImage image){ int r,g,b; Pixel [][] grid = new Pixel[image.width][image.height]; for (int i =0; i < image.width; i++) { for (int j=0; j < image.height; j++) { r = int(red(image.pixels[i + j * image.width])); g = int(green(image.pixels[i + j * image.width])); b = int(blue(image.pixels[i + j * image.width])); grid[i][j] = new Pixel(r,g,b); } } return grid; }