Image to Coloring Page
Operator: Abdulla Al Fahad. How tools are built and checked
A colouring page is a picture reduced to its outlines: closed shapes, clear lines and plenty of white. Photos are the opposite, with soft gradients, texture and noise, so simply thresholding a photo to black and white gives a muddy blob. Getting from one to the other means finding the edges first and then deciding how many of them to keep.
This tool finds the edges with one of two classic methods, lets you control how much detail survives, cleans out stray dots and thickens the lines for crayons. It then places the result on an A4 or Letter page. It is built for photos and drawings; it will not turn a picture into cartoon art with new shapes, only trace the edges that are there.
Key features
- Two edge methods: difference of Gaussians and Sobel
- A detail slider that sets the share of the picture drawn as line
- Smoothing, line thickness and a small-speck remover
- Line colour and an optional transparent PNG background
- A4 or Letter PDF with margins, orientation and an optional title
- Side-by-side original and result, with the line coverage shown
From grey levels to clean outlines
Pictures with transparency are laid on white first, and a GIF gives its first frame. The preview works on a copy of up to 1000 pixels on the longest side, and the PNG or PDF is built from a copy of up to 2400 pixels, which is about 200 dpi when the long side fills an A4 page. Every size-dependent setting is scaled by the picture's size so the preview and the final file look the same.
Edge method has two choices. Difference of Gaussians gives thinner, sketch-like lines that pick up fine detail. Sobel gives bolder, more continuous outlines that suit simple subjects such as cartoons and logos. Detail runs from 0 to 100 and decides what share of pixels become line before thickening, from about 2 percent to 22 percent. Smoothing blurs the picture before edges are found, which keeps fur, grass and film grain from becoming scribbles.
Line thickness adds up to six thousandths of the picture's longest side to each line, so 1.5 on a 2400-pixel export is a few pixels wider. The speck remover deletes any group of connected line pixels that is smaller than a chosen size, counted on a 1000-pixel picture and scaled for larger ones. You can colour the lines, and for PNG you can leave the background transparent.
The PDF is a single A4 or US Letter page, in portrait or landscape (by default whichever suits the picture), with margins from 0 to 50 mm and an optional title in bold above the picture. The picture is scaled to fit inside the margins and centred. The PDF page is always white.
How it works
The picture is converted to grey with the weights 0.299, 0.587 and 0.114. For difference of Gaussians, it is blurred twice, with a standard deviation s and with 1.6 s, and the absolute difference of the two is the edge strength; this is a band-pass filter that responds to features about the size of s. For Sobel, the picture is blurred once and the gradient is measured with the two 3 by 3 Sobel kernels, giving the magnitude at each pixel. The blur width is 0.6 plus 3.2 times the smoothing setting as a fraction, multiplied by the picture's longest side divided by 1000.
A threshold turns edge strength into lines. Instead of a fixed number, which would behave very differently on a flat drawing and a grainy photo, the tool uses a quantile: the threshold is set so that the Detail setting's share of pixels sits above it. A floor of 2.5 grey levels for difference of Gaussians and 12 for Sobel keeps a clean picture from having its noise promoted to lines when the quantile would otherwise be tiny.
Then cleanup. A flood fill labels each group of touching line pixels, including diagonal touches, and drops the groups below the speck size. Last, each remaining line pixel stamps a disc of the thickness radius onto the output. The result is black or the colour you chose on white, or on transparency.
Common use cases
- A colouring sheet of a child's pet or favourite toy for a rainy afternoon
- Classroom handouts made from a photo of the school, a leaf or a landmark
- Party activity pages with the birthday child's drawing turned into clean lines
- A drawing-practice outline to trace over from a reference photo
How to use this tool
- Drop in a photo or drawing.
- Try difference of Gaussians first, and use Sobel if the lines look too faint or broken.
- Move Detail until the main shapes are clear without a nest of small marks, and raise Smoothing for textured pictures.
- Raise the speck remover until the stray dots are gone, and set the line thickness for the age of the colourer.
- Choose paper and margins, add a title if you want one, and download the PDF or PNG.
Example
A 1200 by 900 photo of a dog on grass, difference of Gaussians, detail 40, smoothing 50
longest side 1200 -> scale 1.2
smoothing 50 -> sigma (0.6 + 0.5 x 3.2) x 1.2 = 2.64 px
detail 40 -> 0.02 + 0.4 x 0.2 = 10% of pixelsWhat it does
second blur sigma 4.2 px
threshold brightest 10% of edge strength (never below 2.5)
speck size 30 x 1.2 x 1.2 = 43 px groups removedTips for best results
- Pictures with a plain background give the cleanest pages. A pet on a sofa gives better lines than a pet in a forest.
- For toddlers, keep Detail below 25, raise thickness to 3 or 4 and set the speck size above 60 so only big shapes remain.
- For a detailed adult page, use difference of Gaussians with Detail above 60 and Smoothing near 20, and use the A4 portrait layout.
- Use a very high-resolution original. Edges found in a 600-pixel image look fuzzy when stretched across an A4 page.
Edge cases to watch
Lines come from brightness changes, so a red object on a green field of equal brightness may produce no outline at all.
Shadows and reflections make edges too, so a photo with strong shadows traces the shadows.
A flat picture with little contrast can give few lines because of the floor; add contrast to the original first.
Lines may not be closed. Gaps are possible where an edge is weak, so a colour can leak across them when painted digitally.
Transparent PNG output is for use in other software; the PDF is always on white paper.
Common errors and how to fix them
- The margins leave no room for the picture
- Reduce the margins, or remove the title. The space left for the picture has to stay above 20 points (about 7 mm) in both directions.
- The result is almost blank
- The picture has little brightness contrast. Raise Detail, lower Smoothing, or use Sobel. Brightening contrast in another editor first can also help.
Frequently asked questions
Which method is better, difference of Gaussians or Sobel?
Difference of Gaussians gives thin, detailed, sketch-like lines. Sobel gives thicker, more continuous outlines that colour well. Try both on your picture.
How big is the PDF picture?
It is built from an image of up to 2400 pixels on the longest side and scaled to fit the page inside your margins, so an A4 print is sharp.