Repaints any image so that every pixel is a different color — no shade is ever used twice — while keeping the picture recognizable.
Left: Hokusai's Great Wave. Right: the same image, repainted so that every one of its ~21,800 pixels is a different color.
UniquePixels is a Java/Swing desktop app that reconstructs a source image from a palette of distinct colors, giving each pixel a color that appears exactly once. It samples a large candidate palette across the RGB cube, stores it in a 3-D k-d tree, and for every pixel pulls the nearest still-unused color — then deletes that color so it can never appear again. The effect is strongest over large smooth areas: a plain sky has nowhere to hide, so it spreads across the whole spectrum into rainbow noise while edges stay sharp.
- Every pixel unique. Candidate colors are sampled across the RGB cube and each is used at most once — placing a color removes it from the palette.
- Fast nearest-color search via a 3-D k-d tree over RGB space, periodically pruned and rebalanced as colors are consumed.
- Six fill orders — left, right, up, down, and inward / outward spirals — that change how the reconstruction grows.
- Four color-target modes — exact single pixel, 3×3 source average, 5×5 output average, and random 5×5 sampling.
- Adjustable accuracy (0.25×–5×), trading palette size (match quality) against speed.
- Live side-by-side preview with a running completion percentage; the finished picture is written to
image.png.
Requires a JDK (the project targets Java 8, and also builds and runs on current JDKs) and a desktop environment for the Swing UI.
cd Painting
javac -d bin $(find src -name '*.java')
java -cp bin main.ProgramThen Pick image to load a source (max area ~255³ pixels), choose a direction, comparison mode, and accuracy, and click Run. The result is written to image.png in the working directory. (Painting/ is also an Eclipse project you can import directly.)
The candidate palette is a uniform grid sampled through the RGB cube — sized to cover every pixel, scaled by the accuracy setting — and inserted into a 3-D k-d tree. Pixels are visited in the chosen order; for each one the app computes a target color (the source pixel, or a neighborhood average), asks the tree for the nearest color still available, paints it, and deletes it so it cannot recur. Every ~2,500 placements the tree is pruned and rebalanced so lookups stay fast as the palette shrinks.
The same smiley, filled two of six ways — a linear column sweep (center) vs. an outward spiral (right). Because colors run out as you go, the visiting order decides where the leftover hues pool: horizontal bands vs. a radial vignette.
Tech: Java (Swing/AWT). The bundled kdtree package is adapted from the Java Machine Learning Library (Simon Levy / Thomas Abeel), GPLv2.
Showcase inputs: Hokusai's The Great Wave off Kanagawa, da Vinci's Mona Lisa, and van Gogh's The Starry Night are public domain; the hot-air-balloon photo is public domain (David E. Lucas / DPLA); the sunset and smiley are drawn by the program itself.