Ooh, see the fire is sweepin’
Our very street today
Burns like a red coal carpet
Mad bull lost its way
(Gimme Shelter, The Rolling Stones)
After following this easy tutorial, you will be able to create tiled images from a photograph. You may want to use your own portrait or some other as I did. I use
geom_tile: one of my preferred geometries of
ggplot, which was the one I used in some other experiments like space invaders or Newton’s fractals. I used original photos from some of the most terrific monsters of the cinema: Frankenstein, Dracula and The Mummy. I love how rough squares create textures and sense of depth. This is Frankenstein after the transformation:
The process is quite simple:
- Load the image and convert it to grayscale. I use
imager, a very useful and easy to use package for image processing with R.
- Reduce the resolution of the image as well as its dimension. Each new (big) pixel is summarized with the mean of the grayscale values of the pixels inside it.
- Divide these average values into a number of groups using
- Represent pixels with
geom_tile. There are two important parameters: size and color of lines of each tile. Both of them depend on the value of the group previously calculated in which falls the tile. The graph is composed layer by layer depending on these gropus.
This is Dracula after being tiled:
And this is The Mummy:
These are the stunning original images (I love them all):
You can find the code here: let me know if you do something with it.