Cover

OMG This Image got POSTERED!

Yashraje
My Design Journey
Published in
4 min readOct 26, 2022

--

I feel like I should apologize for the title of this post, but the NBA is finally back and it’s safe to say I’m excited for the new season. In this week’s update of my Processing journey, we’re continuing to work with images editing. Continuing along the theme of editing pixels, this week was a great example of the principles of Photoshop, and how we can re-create it with Processing. This week was definitely a bit of fun for me. The goal was to try a create the image in the style of Barack Obama’s 2008 election, which was one of the first few project that inspired my love for graphic design.

Obama 2008 Election Poster

Jumping into Processing, the first step was to load the image in that I wanted to recreate the effect on. Easy enough, the code from last week works perfectly.

PImage img;
void setup(){
img = loadImage (“Website_Gallery_1–6.jpg”);
size(1024, 683);
background(0);
textAlign(CENTER);
noStroke();
image(img, 0, 0);
img.loadPixels();
int pixelSize = 1;
}

The real challenge came when trying to select which pixels would receive the colours , I started off by choosing the colours I wanted to use for my recreation. After choosing my colours, the next step was to set thresholds that would differentiate which colour would be assigned to each pixel that was being called. In order to measure thresholds I used the brightness of each pixels which each value falling between 0 and 255, 0 for black and 256 for white. With the structure set, it was time to start inputting value. I played around with a few colour options, eventually setting on an autumn theme of sorts(more on this later). I created variables for each colour for easier use going froward, as well as variables that divided the total brightness scale into four sections, once for each colour. From here it was just a matter of creating if statements that set each colour to a certain brightness range, which got a bit tricky working to make sure that all the statements were following appropriate JS structure.

color copper = color(#be7c4d);
color red = color(#92140c);
color jet = color(#353238);
color yellow = color(#ffbb00);
//brightness goes from 0…255
//0, 64, 128, 192, 256
int t1 = 20;
int t2 = 50;
int t3 = 120;
int t4 = 256;
for (int x=0; x<img.width; x+=pixelSize) {
for (int y=0; y<img.height; y+=pixelSize) {
int i = y * img.width + x;
color c = img.pixels[i];
int b = (int)brightness(c);
if (b >=0 && b < t1) {//dark range
fill(copper);
square(x, y, pixelSize);
} else if ( b >= t1 && b < t2 ) {//shadows
fill(red);
square(x, y, pixelSize);
} else if ( b >= t2 && b < t3 ) {//shadows
fill(jet);
circle(x, y, pixelSize);
} else if ( b >= t3 && b < t4 ) {//shadows
fill(yellow);
circle(x, y, pixelSize);
}
}
}
}

When added together the result was definitely what I was hoping the outcome to be, with a bit of a twist. The autumn colour palette I decided to work with ended up looking a bit to “gross”, with a lot of the colours looking a bit too similar to one another. In hindsight, it probably would have been a better idea to use more distinct colours to create a stronger contrast, but I’m still very happy that the foundation of the code works and that in theory I can work with different colours to improve the aesthetic, which I will be looking into in the near future. As always, the code is below, and the final image. A quick warning in advance, sometimes true beauty lies beyond the exterior. Thanks for reading!😄

Final Posterized Image

PImage img;
void setup() {
img = loadImage (“Website_Gallery_1–6.jpg”);
size(1024, 683);
background(0);
textAlign(CENTER);
noStroke();
image(img, 0, 0);
img.loadPixels();
int pixelSize = 1;
color copper = color(#be7c4d);
color red = color(#92140c);
color jet = color(#353238);
color yellow = color(#ffbb00);
//brightness goes from 0…255
//0, 64, 128, 192, 256
int t1 = 20;
int t2 = 50;
int t3 = 120;
int t4 = 256;
for (int x=0; x<img.width; x+=pixelSize) {
for (int y=0; y<img.height; y+=pixelSize) {
int i = y * img.width + x;
color c = img.pixels[i];
int b = (int)brightness(c);
if (b >=0 && b < t1) {//dark range
fill(copper);
square(x, y, pixelSize);
} else if ( b >= t1 && b < t2 ) {//shadows
fill(red);
square(x, y, pixelSize);
} else if ( b >= t2 && b < t3 ) {//shadows
fill(jet);
circle(x, y, pixelSize);
} else if ( b >= t3 && b < t4 ) {//shadows
fill(yellow);
circle(x, y, pixelSize);
}
}
}
}

--

--