Dev.to
5/10/2026

How I Built a Perceptual Color Quantization Engine for LEGO Mosaics
Short summary
A developer solved LEGO mosaic conversion by replacing RGB with OKLab (perceptually uniform color space) and adding material-aware distance metrics and spatial stabilization. The approach models brick properties (matte, transparent, metallic) and despeckles isolated pixels to significantly improve visual accuracy. The tool is live at bmbrick.com with a free parts list during launch.
- •OKLab color space preserves perceptual accuracy better than RGB matching
- •Material-aware distance accounts for how brick finishes affect color appearance
- •Spatial stabilization and despeckle pass eliminate visual noise and isolated pixels
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



