Pixel portraits made with code

I have created a way to make a portrait by swapping pixels from existing photos. One way to create these portraits is by using code.

In my pixel portraits series I create a portrait by combining pixels from different existing photographs. When you see this new picture from a distance the pixels blend together into a new picture, when the source pictures are well aligned.

I have been creating these with photoshop where I have control over de position and size of the different pictures. This is the way the process looks in Photoshop:

The making of Kylie in Photoshop

I thought it would be interesting to see if I could achieve the same effect by using computer code to combine the pictures.

So I began writing a program in processing that would take 4 images and combine them using the ‘checkered mask’ grid I use in photoshop. 

I went through many iterations of the program and am still developing new versions. Below is a chronological overview of how the program was developed and what considerations went into the different approaches. 

With every iteration of the program I decided to generate portraits using images from one model or actress, and pick the best 8 portraits of every batch generated to mint as NFT-artworks on hicetnunc.

I will only use every model once, I will select 8 images for the code based portraits and I will also make 1 photoshop based portrait.  

The first iteration of the program takes four random images from a given set, crops out the square middle, resizes it to the target 500 x 500 pixels and combines them into one picture. 

I used this program to generate 1000 portraits of model Candice Swanepoel. I selected the best 8 portraits generated, and minted them on hicetnunc as NFTs. 

Candice 05
Candice 07

Candice Swanepoel

I wanted to see what the result would be when the source images would be more diverse. So I let the program run on a set of fashion model images that were not portraits and of various models and styles. I added a bit of randomness to the area being cropped to get more variation in the results. 

Models 02
Models 06


I was looking for a way to make it more of a clear portrait, like the ones I made by hand in photoshop. I decided to prepare the source images for the next round: I cropped the faces from the pool of source images in photoshop all in a similar aspect ratio and let the program combine them at random.

Lara 01
Lara 06

Lara Stone

Then I tried to break the grid by introducing randomness into the order that the pixels were being swapped. I wondered what the effect would be if for every batch of 4 pixels the order in which they would be swapped would be random. The result was a lot more painterly effect. I also cropped the source images to a comparable aspect ratio here. 

Fei Fei 02
Fei Fei 08

Fei Fei Sun

I went looking for facial recognition software to be able to automate the crop of the source files. I found the excellent OpenCV libraries for Processing that had exactly what I wanted. I used it to generate portraits of Bella Hadid. I discovered that in a lot of cases the software would discover faces in clothing or creases or details, so I had to check for every portrait that the source actually was faces in the composite. Although sometimes, when 1 source picture was an abstract piece of a photo that the software thought was a face, I kept it in the selection because it made for an interesting result. 

Bella 01
Bella 03

Bella Hadid

I decided to continue with the faces cropped by the software, and do a portrait of Kate Moss. I realized I could take pixels from as many source images as i wanted to if they were as similar as the computer-cropped faces, so I tried to make a portrait from ALL the Kate Moss images I collected. Both with a fixed repeated images order and a random order. The rsult was always roughly the same image, which ultimately I did not think interesting enough to really mint as an NFT: 

Kate (fixed 74 images)
Kate (random 74 images)

Kate Moss (from 74 images) 

In the end after a lot of experimentation I settled on limiting the number of random chosen source images to produce every portrait. Five images, where from every images I select a horizontal line delivered the following series of portraits of Kate, and will inspire new experiments with different kinds of masking / patterning and combining more than 4 source files: 

Kate 02
Kate 08

Kate Moss

I will be updating this page with new examples of generated portraits when I make a new version of the program.