Processing's pixels[] array gives direct read-write access to every pixel of the display window
After calling loadPixels(), the array pixels[] contains a color value for every pixel, stored in row-major order. The index of pixel (x,y) is y*width + x. Reading or writing pixels[] and then calling updatePixels() applies the changes to the display. This is more powerful but slower than shape-based drawing: pixel manipulation enables image processing, generative textures, and per-pixel effects. GIF images support 1-bit transparency (fully opaque or fully transparent); PNG supports 8-bit (256 levels). get(x,y) and set(x,y,c) are higher-level alternatives that skip direct array access.
Examples
loadPixels(); for (int i = 0; i < pixels.length; i++) { pixels[i] = color(random(255)); } updatePixels();
Assessment
Write code that converts a loaded image to grayscale by replacing each pixel’s color with the average of its red, green, and blue components.