Prototyping Tile Selection in Processing

A project log for Tile Pick and Place

Ever wanted to create your own mosaic patterns? While putting up a tile backsplash I said, I want a robot for this!

jpcutlerjpcutler 06/21/2014 at 04:140 Comments

I'm a Ruby programmer by day so it's highly likely that the processing of images will eventually end up occurring in that type of environment (or perhaps Python). To get started however I decided to whip something up quick in Processing since I've got a little bit of experience doing some image processing from a project I did a few years ago. 

Obviously tiles are a relatively low resolution 'pixel'. If I were to use 3/8" tiles with no grout spacing a 640 x 480 image would be 20 x 15 feet and would use 307,200 tiles! So the first task is to reduce the resolution of the image. Processing provides a bunch of functions for manipulating images, however if we want to manipulate individual pixels we need to know how to reference each pixel.

Processing stores images as a one dimensional array of Red Green Blue and Alpha (transparency) values. Since you know the width of the image you know where the second row starts by adding the width of the image to 0. The third row starts at 3 times the width, etc...

To reduce the image size I'll need to know the height and width of the space to be filled, then I'll figure out which dimension constrains the size of mosaic. From these pieces of information, as well as the size of the tile and grout lines I can calculate how many pixels will represent one tile. Then I can average the RGB values of those pixels and reduce the image to a series of tiles. I'll cover that in my next post.