Skip to content
Pixelate Image

How Pixelate Image matches colors and sizes patterns

Updated

Colors are compared in CIE Lab space (ΔE76) or with the faster redmean formula, gradients can be dithered with Floyd–Steinberg, Atkinson or a 4×4 Bayer matrix, and every real-world size comes from published material dimensions. All of it runs in your browser.

Color reduction

Pixelation first averages each block of source pixels into one color. To reduce a picture to, say, 16 colors, we build a histogram of those block colors, split it with median cut, and refine the result with a few rounds of weighted k-means in CIE Lab space. The seeds are deterministic, so the same photo and settings always produce the same palette.

For a fixed palette (PICO-8, Game Boy, DMC floss, Perler beads, Minecraft blocks) there is no reduction step: each block is mapped to the nearest color in that palette. Pixels with less than 50% opacity stay empty.

Color distance: ΔE76 and redmean

“Nearest color” depends on how distance is measured. Plain RGB distance treats a step in blue the same as a step in green, but the eye does not. We offer two perceptual measures.

CIE Lab ΔE76

sRGB values are linearized, converted to XYZ under the D65 white point, then to CIE L*a*b*. The distance is the straight-line gap between two Lab colors. A ΔE76 near 2.3 is often quoted as a just-noticeable difference.

ΔE76 = √( (L₁ − L₂)² + (a₁ − a₂)² + (b₁ − b₂)² )

Redmean

Redmean is a weighted RGB distance that adjusts the red and blue weights by the average red level. It is cheaper than Lab and works well for large images and live previews.

r̄ = (R₁ + R₂) / 2
ΔC = √( (2 + r̄/256)·ΔR² + 4·ΔG² + (2 + (255 − r̄)/256)·ΔB² )

Dithering

With a small palette, smooth gradients turn into flat bands. Dithering trades those bands for a fine pattern of two nearby colors that the eye blends together.

  • Floyd–Steinberg passes each pixel’s rounding error to unprocessed neighbors: 7/16 to the right, 3/16 below-left, 5/16 below and 1/16 below-right. It keeps the most tonal detail.
  • Atkinson passes 1/8 of the error to six neighbors and drops the remaining quarter. Results are higher in contrast with cleaner highlights and shadows, the classic early Macintosh look.
  • Bayer 4×4 is ordered dithering: each pixel is nudged by a fixed threshold from a repeating 4×4 matrix. The cross-hatch texture is regular and stable, which suits retro sprites and animation.
Bayer 4×4 (÷16)
 0  8  2 10
12  4 14  6
 3 11  1  9
15  7 13  5

For craft patterns, dithering adds scattered single stitches or beads. Leave it off unless a gradient really needs it.

Real-size math

Fuse beads on a 29×29 pegboard

Standard 5 mm beads sit on a 5 mm pitch, so a large square board with a 29×29 grid holds 841 beads and spans 29 × 5 mm = 145 mm, which is 5.71 × 5.71 in (14.5 × 14.5 cm). Boards needed in each direction = pattern cells ÷ 29, rounded up.

cm = beads × 0.5
inches = beads × 5 ÷ 25.4
boards across = ⌈width ÷ 29⌉

Cross stitch on Aida fabric

Aida count is the number of stitches per inch. Finished size in inches is stitches ÷ count; multiply by 2.54 for centimeters. Add margin for framing on top of that.

inches = stitches ÷ fabric count
cm = inches × 2.54
Finished width of a 100-stitch design on common Aida counts
Aida countWidth (in)Width (cm)
11 ct9.0923.09
14 ct7.1418.14
16 ct6.2515.88
18 ct5.5614.11
22 ct4.5511.55

Floss estimates assume about 1,800 full stitches per DMC skein on 14-count with two strands. Treat that as a planning figure and adjust for your fabric and tension.

Diamond painting drills

Square drills are about 2.5 mm and round drills about 2.8 mm. Counts per color include a 20% spare allowance, because drills get lost and kits rarely ship exact counts.

Minecraft blocks, stacks and shulker boxes

Most building blocks stack to 64. A shulker box holds 27 stacks, or 1,728 blocks. A full 128×128 map is 16,384 blocks: 256 stacks, or just under 10 shulker boxes.

stacks = ⌈blocks ÷ 64⌉
shulker boxes = ⌈blocks ÷ 1,728⌉

Limitations

Craft palette RGB values are screen approximations. Real beads, floss and drills vary by dye lot, finish and lighting, and every monitor shows color differently. Before you buy materials, check the suggested colors against the manufacturer’s physical swatch cards or bead samples.

Pixelation and blur can sometimes be partly reversed when blocks are small or blur is light. For faces, plates and text, use large blocks or a solid bar. Printed sizes are only correct when the PDF is printed at Actual Size or 100%.

Standards and references

Questions about a formula? Contact us.