Moving Swiftly to Images

Yashraje
My Design Journey
3 min readOct 19, 2022

--

Of the somewhat of a moderate success of the last Processing project, this week we’re working with images. There’s some pretty interesting that can be done with images, my professor Tim described it as “coding your own Instagram”, which seems like a pretty appropriate starting point to jump into.

I started by loading up my image in Processing. After working with the data from the last project, I knew that making sure my image was actually in my Processing folder was a quick way to make sure things start smoothly. After resizing my canvas to fit the image, I called the loadPixels() function to fill my array. This would allow me to control each individual pixels.

PImage img;

void setup() {
img = loadImage(“Website_Gallery_1–6.jpg”);
size(1024, 683);
image(img, 0, 0);
noStroke();
loadPixels();

for( int x=0; x<width; x++ ) {
for( int y=0; y<height; y++ ) {
int index = y * width + x;
color c = pixels[index];
fill(c);
square(x, y, 1);
}
}
}

After calling the image, I decided to go a bit abstract a create a mosaic of my image. I created a for loop that would allot my to change each pixel, and called an ellipse every 10 pixels to create the partially clear, blocky texture of a mosaic:

PImage img;

void setup() {
img = loadImage(“Website_Gallery_1–6.jpg”);
size(1024, 683);
image(img, 0, 0);
noStroke();
loadPixels();
int pixelSize = 10;
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);
ellipse(x, y, pixelSize, pixelSize);
}
}
}

This was fun to make, but after looking at my image I realized that the mosaic style was losing the detail and colours of the image that made me take it in the first place. I wanted to play around with the image but in a way that still kept the original quality of the image. Turns out Processing has a built in filter option which can be added with one simple line of code, .filter. Adding this to the variable I sued of. my image gave me the ability to edit it multiple ways, so I tried out a few different things.

Greyscale: My personal favourite of the lot, so I kept it in my code going forward.

Blur: Made for an interesting abstract piece, but other than that not much going here.

Dilate/Erode: These two went hand in hand, with Dilate increasing light areas, and Erode doing the opposite. Erode definitely worked better with the overall image, and made it look a bit spookier, so I decided to use it as my example.

PImage img;

void setup() {
img = loadImage(“Website_Gallery_1–6.jpg”);
img.filter(GRAY);
img.filter(ERODE);
size(1024, 683);
image(img, 0, 0);
noStroke();
loadPixels();

for ( int x=0; x<width; x++ ) {
for ( int y=0; y<height; y++ ) {
int index = y * width + x;
color c = pixels[index];
fill(c);
square(x, y, 1);
}
}
}

Overall, a pretty good Processing week, I think it might be fun to see where this goes.

--

--