Paint by Numbers Generator
Operator: Abdulla Al Fahad. How tools are built and checked
A paint-by-numbers sheet is a photograph reduced to a handful of flat colours, with every patch outlined and labelled with the number of the pot to use. Making a good one is mostly about restraint: too many colours and tiny patches give a page nobody can paint, too few and the picture is lost.
This page does the reduction, the cleaning and the numbering, then lays it out on paper so you can see how large each number will print before you spend ink.
Key features
- 6 to 36 colours chosen by k-means in CIELAB, so colours that look alike to the eye are grouped together
- Smoothing of the photo before clustering, a majority clean-up filter of 0 to 4 passes, and a smallest-region setting from 0.01% to 1% of the picture
- Regions below the minimum area, and regions too thin to hold a legible number, merged into the neighbour that shares the longest border
- Numbers placed at each region's pole of inaccessibility, the point farthest from every edge, at a size that fits the inscribed circle
- A colour key page with swatches, hex values, share of the picture and number of regions for each colour, ordered light to dark
- A seed from 1 to 9999 for the colour clustering, so a run can be repeated exactly or re-rolled
- A 3-page PDF (outline, colour key, preview) on A4, A3, US Letter or a 16 × 20 in panel, plus SVG outlines and a PNG preview, with line width from 0.1 to 1 mm
Colour reduction, region merging and number placement
The working picture is 600, 900, 1200 or 1600 px on its long side, chosen by the Detail setting. A 1280 × 1742 portrait at the default 1200 gives an 882 × 1200 px kit.
Outlines are traced from the region map as simplified polylines whose tolerance you set from 0.3 to 3 px, and they are written as vector lines into the PDF and the SVG, so the page stays sharp at any print size. Digits are drawn in Helvetica at a size of 90% of the inscribed circle's diameter divided by the digit-box diagonal, capped at 3.5% of the long side.
How it works
The photo is blurred in proportion to its size, pixels are clustered in Lab with a seed you can change, and a majority filter rounds ragged edges. Connected areas of one colour become regions, and any region below the minimum area is absorbed by its neighbour.
For each region the page finds the pole of inaccessibility with the polylabel algorithm. If the largest circle that fits inside a region is under 60% of the circle the minimum area implies, the region is too thin for a number and is merged too, then the poles are found again.
The palette colour is the mean of the original pixels in each colour's regions, not the cluster centre, so the kit matches the photo.
Typical uses
- A pet portrait for a birthday: 12 colours and a smallest region of 0.15% give about 60 patches that a child can paint in an afternoon.
- A teacher preparing 24 identical A4 sheets of one landscape uses 8 colours and a 0.5 mm line so the print survives a school copier.
Building one
- Drop a photo whose subject has clear shapes; busy textures such as foliage create many small regions.
- Pick the number of colours and the detail, and press Make the kit.
- Read the line under the preview, which gives the smallest number's printed height for the chosen paper.
- Adjust smoothing, clean-up or the smallest region and press Make again, and check the outline and colour views.
- Choose the paper and line width and download the PDF, the SVG or the PNG.
Example
A 3000 × 2000 photo of a lighthouse (illustrative), A4 paper
lighthouse.jpg, 16 colours, Detail 1200, smoothing 1.5 px, smallest region 0.08%What the page produces
Kit size: 1200 × 800 px (the long side is cut to the Detail setting)
lighthouse-paint-by-numbers.pdf: 3 pages, landscape A4 because the photo is wide
lighthouse-outline.svg and lighthouse-preview.png
A notice under the preview gives the smallest number's printed height on A4 in millimetres and turns to a warning below 2 mmTips for best results
- If the notice says the smallest number is under 2 mm, raise the smallest-region setting or lower the detail; the page warns below 2 mm.
- A portrait turns out better when the background is simplified first: blur it in a photo editor, and the clusters will merge it into one calm region.
- The same seed always gives the same palette, so change the seed when two colours look alike and you want another grouping.
Things to check before you rely on it
The hex values on the colour key are screen colours measured from your photo. Paint mixed from a real set will differ, so treat the key as a target and test it on scrap card.
Printer margins differ: the page keeps 12 mm clear, but a printer that clips at 15 mm will cut a corner of the border.
Common errors and how to fix them
- Eyes, lettering or other fine detail has vanished from the kit
- Regions under the smallest-region area, and regions too thin to hold a number, are merged into a neighbour. Lower Smallest region toward 0.01% and raise Detail; the Pattern heading reports how many small regions were merged.
- The notice warns that numbers print under 2 mm
- Use fewer colours, a larger smallest region or a larger paper size, then press Make again.
- A photo is refused as too large
- Files over 25 MB are not opened. Export the photo at 4000 px wide or less first; the kit is built from at most 1600 px anyway.
Why pole of inaccessibility instead of the centre
A region shaped like a crescent or a letter C has a centre of mass outside the region itself, so a number placed there would sit in the neighbour's patch. The pole of inaccessibility is the point inside the region that is farthest from its boundary, and the distance there is the radius of the largest circle that fits, which is also what decides how large the digit can be.
Frequently asked questions
Why are there more numbers on the page than colours in the key?
Each colour can form several separate regions, and every region carries its own number. The key lists, for each colour, how many regions it has.
Is the PDF's outline page a raster image?
No. The outline and the numbers are vector lines and text; only the colour preview on page 3 is a PNG.
Which paper suits which canvas?
A4 (210 × 297 mm) and US Letter (8.5 × 11 in) suit practice sheets, A3 (297 × 420 mm) suits a framed picture, and 16 × 20 in matches common pre-printed canvas panels. The sheet turns landscape for a wide photo and keeps a 12 mm margin.