Edge detection: photo to line drawing
Detect the edges of a photo and turn it into a colouring-page line drawing or a classic edge map
Your files stay with you. Conversion happens inside the browser; no file is ever uploaded to a server.
Did this tool do the job?
Thanks, your feedback came through.
How it works
Tap or click the box to choose one or more photos, pick a look and press "Detect edges". The tool converts the photo to grey, smooths it slightly and then measures how quickly the brightness changes left-to-right and top-to-bottom at every pixel; where it changes fast, there is an edge. "Black lines on white" draws only the clear edges and looks like a colouring page; "Bright edges on black" shows every edge as brightness according to its strength. Example: on a well-lit portrait against a plain wall, density 40 draws the face outline, hair and clothing edges; above 80 it also turns skin texture into lines. Too few lines? Raise the density. Too busy? Lower it. The output is PNG and everything runs in your browser.
This tool is also known as edge detection online, photo to line drawing, sobel edge detection, image to line art, photo to coloring page, edge detector, outline from photo.
What is Edge detection?
Edge detection is the image processing step that finds where brightness or colour changes sharply — the boundaries of objects. It is one of the first stages of computer vision and usually the first assignment in an image processing course. The result is a black-and-white map that keeps only the outlines of the photo, which also works as a drawing template, a colouring page or a draft for laser cutting.
What is Sobel operator?
The Sobel operator is a pair of small 3×3 weight tables applied around each pixel: one measures the difference between right and left neighbours, the other between bottom and top neighbours, with the middle row and column weighted twice. Combining the two gives the strength of the edge at that point. It is simple and fast; on a sharp black-to-white boundary it marks the two pixel columns that touch the boundary.
Sobel vs. Canny edge detection: what is the difference?
Sobel measures edge strength at every pixel and shows it directly; edges can be a few pixels thick and break up where they are weak. Canny takes the change Sobel finds, thins lines down to one pixel, uses two thresholds to keep weak edges that connect to strong ones and drops isolated noise. Canny gives cleaner, thinner lines but involves more steps. This tool uses Sobel — fine for colouring pages; if your assignment asks for Canny, say so in your write-up.
Which photos make a good colouring page?
Well-lit photos where the subject stands out clearly from the background give clean lines: a pet in front of a plain wall, a building against the sky, a portrait with a simple backdrop. Textured surfaces like grass, carpet or leafy trees turn into lots of tiny lines; lower the density for those.
On a very large photo the lines can look thin and broken, because an edge spreads over several pixels. If the result is faint, scale the photo down to about 1000–1500 pixels wide first; that is plenty for a Letter or A4 colouring page.
For assignments and analysis: method details
The image is first converted to luminance (0.299 R + 0.587 G + 0.114 B), then smoothed with a 3×3 Gaussian kernel ([1 2 1] horizontally and vertically). The Sobel kernels are gx = [−1 0 1; −2 0 2; −1 0 1] and its transpose. Edge strength is scaled as √(gx² + gy²) / 4, so a sharp black-to-white step gives 255. Border pixels repeat their nearest neighbour, so the frame of the image produces no fake lines.
In "Bright edges on black" the edge strength becomes the grey value directly (multiplied by the density). In "Black lines on white" a threshold is applied: weak edges below it stay white and those close to it fade in with a grey ramp. Canny's non-maximum suppression and hysteresis steps are not applied.
Frequently asked questions
How do I turn a photo into a line drawing?
Choose the photo on this page, keep the "Black lines on white" look and press "Detect edges". The outlines appear as black lines on white; download the PNG and print it.
I got too few or too many lines. What should I do?
Move the "Line density" slider. A higher value also draws weaker edges and adds detail; a lower value keeps only the strongest outlines. On textured backgrounds a lower value gives a cleaner result.
Does this tool use the Canny method?
No, it uses the Sobel operator. Lines are not thinned to one pixel as in Canny; that is fine for colouring pages and templates, but name the method correctly in an assignment.
Can I print the result as a colouring page?
Yes. Print the PNG with the "fit to page" option. The white background uses no ink; only the lines are printed.