Open Source Beer Bottle Cap Mosaic Program
by acoens in Craft > Parties & Weddings
25754 Views, 132 Favorites, 0 Comments
Open Source Beer Bottle Cap Mosaic Program
My husband (programmer) and I (designer/tinkerer) were on the hunt for a project that would engage both of our skill sets. We had talked before about collaborations that would be fun for each of us and then slowly this one found us.
As we'd drink different favorite beers, we'd usually get a six-pack or a few from a specific brewery at a time and my husband started to make patterns on the kitchen table out of the first dozen caps. With mostly the same few colors, alternating red-blue-red-blue-etc. around a table centerpiece or in some grid was about as complicated as it got. As the number of bottle caps grew over time, we'd sit and share a beer while talking and making patterns when this idea hit us: what if we made mosaics out of the caps?
Making mosaic art out of bottle caps isn't our idea and there are many inspiring artists we've seen in the past few years that we've been collecting bottle caps (turns out mosaics require a TON of bottle caps, but more on that later).
The idea took many forms. Originally, I had wanted to make a Connect Four style frame and hang it in our kitchen (another day - I still think this could be tons of fun) or PLINKO style to create an image out of the caps. Eventually we landed on this incarnation where we can input any image and this program processes the image to show the types and number of bottles of beer you'd need to drink to create that mosaic. There's still a lot we want to do to create a mosaic, but for those who share a love of beer and art, this Instructable will serve to get you started on making your own mosaic!
Phase 1: Collect Bottle Cap Images
We were surprised to find there was no comprehensive database of bottle caps when we set out. No problem! We decided we'd just take our own images of caps, but hit a snag realizing our own consumption wouldn't yield the variety necessary for interesting images. As we were out and about, we'd snap a few images of only the bottle caps and were politely asked to stop photographing the inside of several stores.
Determined to get the high quality images we were after, I wrote to our local beverage supplier's corporate office explaining our project and asking clearly for permission to a local store to take the photos. To our delight, they agreed! Just goes to show, sometimes you just have to ask for what you want. (And good manners are always a must!)
We had a nifty little setup in the aisle. There were nearly 200 unique bottle caps to capture (which was why this store was our ideal location for this project) and to make post-processing easier, we set up a simple, small process including a small tripod, a dSLR, and a flat, black background for the photos. We set each bottle down on a small target, took a photo, and moved quickly through the aisle to gather the raw images. Early on, we learned to set an identical bottle next to the upright bottle so we'd be sure to catalog the correct beer as some caps lack any identifying marks.
Phase 2: Post Process the Images
The goals for post-processing the images were all straightforward:
1. Provide high quality images for the program output to render potential mosaics
2. Reduce any color-altering glare from the cap (hard to control lighting conditions in a retail environment)
3. Create a catalog of caps
I did this all in photoshop using a simple mask with a set diameter for the cap. Since we used a tripod, all caps were the same size in the image and this make the post work a lot easier. I also did some work with the spot healing and cloning tools to try and create an image as close as possible to the art on the cap. You can see this in the two photos included in this step.
Phase 3: Write the Program
This is my husband's domain. All of his work is open sourced here: https://github.com/JonCoens/Photo-Mosaic
Additionally, here are some of his thoughts about the program itself:
It was the product of a couple of personal hackathons doing image processing in python. I needed to experiment with color differences in various color-spaces and experimentally settled on the existing code. Adding the hex pattern came from an idea of packing more bottle caps into the same physical space. There's plenty of areas to make the algorithm more efficient, but for the amount of time put into it I'm pleased with the results.
He tweaked the output as we looked at the initial renderings. Early on, he decided to process the image to more strongly weight the two most prevalent colors on the cap as those have the largest impact on how a cap would change the photo. He noted that two caps with say the same yellow and equal amounts of it would vary quite a bit depending on the second most apparent color and the contrast between them. These tweaks were very encouraging as we started to see sample images translate into bottle caps in more and more recognizable output.
Future Work
This is where this Instructable concludes: image collecting and the program itself for rendering mosaics out of the images.
Once we hit this point, we realized that at the fidelity we liked, we'd need to collect thousands of bottle caps and have enjoyed finding creative ways to do this. Friends and family all save their caps for us now and my old office used to compete between the floors to see who could fill up their jars in the kitchens the fastest. We now have about 7,000 bottle caps (all cleaned!) ready and waiting. But now the next big question...what image should we build?
The program itself is at a stage of maturity that is hard to develop more without more processed images or additional insights. If you've done things in this space before, please leave comments for ways to improve!