Caps - Attempt at making computer generated pixel art from bottle caps

Related tags

Routers caps
Overview

I started sorting the caps and realised that there are significantly more Alexander Keiths than anything else. Counting them while sorting was something I considered, but it was harder than you'd think. The plan is to use a scale to weigh them and avoid having to count at all.

These are the main caps. The individual cropped photos can be found in the images/caps/ directory. The two budwiser cap types are pretty similar but I decided to keep them separate just in case. Mixing them is a lot easier than re-sorting.

While I figure out where to find a scale, I might as well start thinking about the cap layout. The shape and pattern packages define some simple layout algorithms. This is the output of the pattern.Grid implementation.

This seemed ok until I started actually arranging the caps manually. The pattern wasn't a square grid at all...

A bit of googling I found that it's called Circle Packing. A set of 3 touching caps can be viewed as an equilateral triangle with a point at the center of each cap. Each side is two times the radius of a cap so all we need is the Pythagorean Theorem for this one.

Based on this, I implemented pattern.Triangular. Here's an example of the output.

Time to see how this might actually work. This is the source image I'm working with:

I set the circle radius to be 20 pixels which results in 1863 circles. For each circle, I am taking the bounding box and padding it with 5 additiona pixels. I'm then computing the average RGB color for that rectangle in the source image. Finally, I draw the circle with the color as the fill.

Now let's replace the circles with bottlecaps! I'm choosing a bottle cap image by comparing the circle color with the cap image's average color. The huristic is pretty simplistic: DISTANCE = ABS(a.R - b.R) + ABS(a.G - b.G) + ABS(a.B - b.B).

Not what we wanted ... I'm assuming the color difference function is too shitty. I found the Wikipedia page for Color Difference and it says that I should be using a weighted Euclidean distance function. That's basically what I was doing before except you square each component difference before adding and then take the square root of the sum. Since I'm just comparing them, I can skip the last step.

I tried a different approach to color selection. First I find N prominent colors in the image (using k-means) where N is number of cap types (in our case 6). Then I match each promiment color to a bottlecap that has a similar color (each color is only used once). This seems to produce better contrast in certain features. I also stopped drawing caps in tiles with no pixels. I'll need to figure out how to deal with those edges.

Someone threw out all the caps, so I'm not going to be working on this anymore.

You might also like...
An attempt to manage session and prevent ddos attack

This is an attempt to manage the session and prevent ddos attack. A session_id is an int64, inscrease by 1 when issue a new session. Server has a tabl

Attempt to plot light sensor data from lunarsensor.
Attempt to plot light sensor data from lunarsensor.

lightsensor Attempt to plot light sensor data from lunarsensor. Buy the components, install firmware on Ambient Light Sensor. Build the go app that po

Gones - An attempt to program a NES emulator

Gones - An attempt to program a NES emulator The following resources were used for the project: The great work on wiki.nesdev.org R650X and R651X Data

This app is an attempt towards using go lang with graphql data fetch in react front end.

go_movies _A React js + GraphQL supported with backend in GoLang. This app is an attempt towards using go lang with graphql data fetch in react front

First attempt to trace a shell script with Datadog's go tracer
First attempt to trace a shell script with Datadog's go tracer

dd-trace-shell First attempt to trace a shell script with Datadog's go tracer. W

Attempt at rewriting ltv in golang
Attempt at rewriting ltv in golang

ltv-go my attempt at rewriting ltv in go. Install and Usage Download binaries fo

Email-searcher - Given a domain name and real name, attempt to find an existing email for that user.

email-searcher Given a domain name and real name, attempt to find an existing email for that user. Using Run it with both the domain and name flags, l

An attempt to clone the mechanics from the game Majesty.

An attempt to clone the mechanics from the game Majesty. Basically, an indirect control kingdom building simulation.

Go implementation of a vanity attempt to generate Bitcoin private keys and subsequently checking whether the corresponding Bitcoin address has a non-zero balance.

vanity-BTC-miner Go implementation of a vanity attempt to generate Bitcoin private keys and subsequently checking whether the corresponding Bitcoin ad

Go-indexeddb - This expirement will attempt to implement IndexedDB features for Go

go-indexeddb This expirement will attempt to implement IndexedDB features for Go

A (attempt to create a) multiversion gophertunnel proxy to join the latest MC version without renderdragon

draco a multiversion gophertunnel proxy to join the latest MC version without renderdragon Purpose mojang can't seem to actually make a good update to

Go package for computer vision using OpenCV 4 and beyond.
Go package for computer vision using OpenCV 4 and beyond.

GoCV The GoCV package provides Go language bindings for the OpenCV 4 computer vision library. The GoCV package supports the latest releases of Go and

Helpers for making the use of reflection easier

go-xray This is a Golang library with reflection related functions which I use in my different projects. KeyValue This type is used to construct a key

golang long polling library.  Makes web pub-sub easy via HTTP long-poll server :smiley: :coffee: :computer:
golang long polling library. Makes web pub-sub easy via HTTP long-poll server :smiley: :coffee: :computer:

golongpoll Golang long polling library. Makes web pub-sub easy via an HTTP long-poll server. New in v1.1 Deprecated CreateManager and CreateCustomMana

Making it easy to write shell-like scripts in Go
Making it easy to write shell-like scripts in Go

import github.com/bitfield/script What is script? script is a Go library for doing the kind of tasks that shell scripts are good at: reading files, ex

Monitor your Website and APIs from your Computer. Get Notified through Slack, E-mail when your server is down or response time is more than expected.
Monitor your Website and APIs from your Computer. Get Notified through Slack, E-mail when your server is down or response time is more than expected.

StatusOK Monitor your Website and APIs from your computer.Get notified through Slack or E-mail when your server is down or response time is more than

DockerSlim (docker-slim): Don't change anything in your Docker container image and minify it by up to 30x (and for compiled languages even more) making it secure too! (free and open source)
DockerSlim (docker-slim): Don't change anything in your Docker container image and minify it by up to 30x (and for compiled languages even more) making it secure too! (free and open source)

Minify and Secure Docker containers (free and open source!) Don't change anything in your Docker container image and minify it by up to 30x making it

:zap: Transfer files over wifi from your computer to your mobile device by scanning a QR code without leaving the terminal.
:zap: Transfer files over wifi from your computer to your mobile device by scanning a QR code without leaving the terminal.

$ qrcp Transfer files over Wi-Fi from your computer to a mobile device by scanning a QR code without leaving the terminal. You can support development

Sabre is highly customisable, embeddable LISP engine for Go. :computer:

Sabre DEPRECATED: This repository is deprecated in favour much better slurp project and will be archived/removed soon. Sabre is highly customizable, e

Owner
Ilia Choly
Ilia Choly
Faster than the fastest in the world pixel-by-pixel image difference tool.

imgdiff Faster than the fastest in the world pixel-by-pixel image difference tool. Why? imgdiff isn't as fast as a tool like this should be and I'm no

Nikita Tolkachev 1.6k Nov 12, 2022
Convert images to computer generated art using delaunay triangulation.

▲ Triangle is a tool for generating triangulated image using delaunay triangulation. It takes a source image and converts it to an abstract image comp

Endre Simo 2k Nov 18, 2022
Simple attempt at making a program to Brute Force Gift codes for Roberts Space Industries AKA Star Citizen.

Roberts Space Industries: Gift Generator Simple attempt at making a program to Brute Force Gift codes for Roberts Space Industries AKA Star Citizen. I

SaturnsVoid 2 Nov 2, 2021
Build apps for pixel-based displays.

Pixlet Pixlet is an app runtime and UX toolkit for highly-constrained displays. We use Pixlet to develop applets for Tidbyt, which has a 64x32 RGB LED

Tidbyt 526 Nov 21, 2022
Example of how to achieve pixel perfect shadows in a 2D view

Lights and Shadows Example of how to achieve pixel perfect shadows in a 2D view. The sample is based on the following sources: 2D Pixel Perfect Shadow

Defold 13 Oct 26, 2022
Comparison of Pixel and Ebiten API on the trees tutorial

Rewriting the trees tutorial of Pixel with Ebiten for API comparison I tried Pixel and really liked the clean API but the dev seems to be on pause sin

null 4 Dec 7, 2021
A golang implementation of the Open Pixel Control protocol

__ ___ ___ _____ ___ /'_ `\ / __`\ _______ / __`\/\ '__`\ /'___\ /\ \L\ \/\ \L\ \/\______\/\ \L\ \ \ \L\ \/\ \__/ \ \

Kelly 18 Jul 3, 2022
SLOs, Error windows and alerts are complicated. Here an attempt to make it easy

slo-computer SLOs, Error windows and alerts are complicated. Here's an attempt to make it easy SLO, burn_rate, error_rate, budget_spend are convoluted

last9 61 Nov 15, 2022
An attempt to make a cli for dev.to in Go

Devto a cli for dev.to This is a work in progress so don't a expect a full support for Dev API(beta). Table of contents Devto a cli for dev.to Table o

Gealber Morales 5 Mar 13, 2022
Jeff Buchbinder 7 Nov 17, 2022