How fascinating is it that we can process an image through code? Creative coding is so fun, but basics first. Did you know a digital image is data? An RGB color represents each pixel, and the pixels can be altered to fit any texture, shape, or color.

To get started, we declare a variable type.

PImage img;

To upload an image:

img = loadImage("image.jpg");

So let’s manipulate a funny cat’s image.

PImage img;void setup(){
img = loadImage("cat.jpeg");
size(1200,800);
image(img, 0, 0);
noStroke();
loadPixels();
int pixelSize = 15;
for( int x=0; x<width; x+=pixelSize)
{
for (int y=0; y<height; y+=pixelSize)
{
int index = y * width + x;
color c= pixels[index];
fill(c);
{circle(x,y,pixelSize); //turning pixel into circles
}
}
}
}

--

--