This free online tool detects the edges of images: the outlines of objects, people and letters, and the lines where the colors or the brightness change. Use the Canny edge detector for thin, clean lines, the gradient magnitude of the Sobel, Scharr, Prewitt or Roberts operators for soft edges, the Laplacian of Gaussian, or XDoG to turn a photo into a drawing, and download the result as a PNG image.
Edge detection is one of the basic steps of image processing and computer vision, used to find shapes, measure objects, and prepare images for tracing, engraving, embroidery or coloring pages. The tool chooses the thresholds for your image automatically, and lets you fine-tune every step: the blur, the thresholds, the short edges to remove, the thickness and the colors of the lines.
Everything runs directly in your browser. No image is uploaded to a server, and nothing needs to be installed.
| Field | Description |
|---|---|
| Method | The edge detection algorithm. See the comparison of the methods below. |
| Operator | For Canny and gradient magnitude, the small kernel that measures how fast the brightness changes, horizontally and vertically, around every pixel. Sobel is the usual choice. Scharr is more accurate for diagonal edges, Prewitt weighs all the neighbors equally, and Roberts cross only looks at a 2 × 2 square, so it finds finer but noisier edges. |
| Blur (sigma) | The radius of the gaussian blur applied before the edges are measured, from 0 (no blur) to 20 pixels. Without blur, every grain of noise becomes an edge; with a big blur, only the outlines of the big shapes remain. 1 to 2 works well for most photos. For XDoG, it is the width of the lines. |
| Detect color edges | By default, the edges are found in the brightness of the image. When this is on, the red, green and blue channels are measured separately, and the strongest one is used, so edges between colors of the same brightness are found too. |
| Automatic thresholds | Chooses the thresholds from the strength of the edges of your image, so that dark, low-contrast and bright images all give useful results. The chosen values are shown in the threshold fields. Turn it off to change them. |
| Low and high threshold | For Canny, in percent of a sharp change from black to white. Edges stronger than the high threshold are always kept. Edges between the two thresholds are kept only when they are connected to a strong edge, which keeps the outlines continuous without adding noise. Lower values find more edges. |
| Black point and white point | For gradient magnitude. Changes weaker than the black point become the background, changes stronger than the white point get the full edge color, and the changes in between get a mix of both. |
| Threshold | For the Laplacian of Gaussian. The zero crossings where the change of brightness is weaker than this are ignored, which removes the lines of noise in flat areas. |
| Line strength | For XDoG, how much the difference of the two blurs darkens the lines (the "p" parameter). Bigger values draw more and darker lines. |
| Shading | For XDoG, the brightness, in percent, below which the areas of the image are filled with the edge color (the "epsilon" parameter). At 0 only the lines are drawn; higher values add solid shadows, like a comic book, a stencil or a woodcut. |
| Sharpness | For XDoG, how fast the lines go from the background color to the edge color (the "phi" parameter). Low values give soft, gray lines like a pencil sketch; high values give solid lines like ink. |
| Remove short edges | For Canny and the Laplacian of Gaussian. Groups of connected edge pixels smaller than this number of pixels are removed. It cleans up the dots and short dashes left by noise, grass, skin or textures, and keeps the long outlines. |
| Thickness | The width of the lines, in pixels. Canny and the Laplacian of Gaussian give lines of 1 pixel; thicker lines are easier to see, print, cut or engrave. |
| Edge color | A single color for all the edges; the original color of the image under every edge; or a rainbow, where the color shows the direction in which the brightness increases. |
| Background | A solid color, a transparent background (to put the lines over another image), or the original image, to see the edges over it. |
| Method | Lines | Description |
|---|---|---|
| Canny | 1 pixel, continuous | The edge detector created by John Canny in 1986, still the most used one. It blurs the image, measures the gradient with an operator such as Sobel, keeps only the pixels at the center of each edge (non-maximum suppression), and then follows the edges with two thresholds (hysteresis), so weak parts of an outline are kept when they continue a strong one. The best choice for clean outlines, tracing and computer vision. |
| Gradient magnitude | Soft, of varying width | The strength of the gradient measured by the operator, without thinning or thresholds: the stronger the change, the brighter the edge. It is what the Sobel, Scharr, Prewitt and Roberts filters of photo editors give, and it keeps the soft, glowing look of the edges. With the rainbow edge color, it shows the direction of every edge. |
| Laplacian of Gaussian | 1 to 2 pixels, closed | The method of Marr and Hildreth (1980). It blurs the image and takes its Laplacian, the second derivative, which changes sign exactly at the edges (zero crossings). The lines tend to form closed loops around the shapes, which is useful to separate regions, but it finds more false edges in smooth areas than Canny. |
| XDoG | Smooth, of varying width | The eXtended Difference of Gaussians of Winnemöller and others (2012), designed to make images look drawn. The difference between two blurs of the image finds the edges, which are turned into smooth lines with a soft threshold. The lines are thicker where the edges are stronger, like strokes of a pen, and dark areas can be filled to create a comic or stencil effect. |
An edge is a place where the brightness of the image changes quickly, such as the outline of an object against the sky. To find it, the computer measures the gradient of the image: how much the brightness changes from left to right, and from top to bottom, around every pixel. The Sobel operator does this with two small 3 × 3 kernels, one for each direction. The length of the gradient, √(Gx² + Gy²), is the strength of the edge, and its angle is the direction across the edge.
Real images have noise, so every grain would become a tiny edge. That is why the image is blurred first: the blur averages out the noise but keeps the big changes. The gradient of a blurred edge is several pixels wide, so the Canny detector then thins it, keeping only the pixel where the gradient is the strongest across the edge.
Finally, the edges must be separated from the remaining noise with a threshold. A single threshold either keeps noise or breaks the outlines into dashes. Canny uses two: strong edges are always kept, and weaker pixels are kept only when they are connected to a strong edge. The automatic thresholds of this tool take the high threshold as the strength above which the strongest 20% of the thin edges are, and the low threshold as 40% of it.
To learn more about the small kernels behind the gradient, and to try your own, see the Convolution Matrix tool.
Yes, this tool is 100% free and works directly in your browser, with no installation and no sign-up required. There is no watermark on the result.
Are my images uploaded to a server?No. The edges are calculated by your own browser and the image never leaves your computer.
How do I turn a photo into line art or a coloring page?Choose XDoG for lines that look drawn by hand, or Canny for clean outlines, and click "Black on white". Then increase the blur until the small details disappear, increase "Remove short edges" to clean up the noise, and choose a thickness of 2 or 3 pixels so the lines print well.
There are too many edges. How do I keep only the main outlines?Increase the blur, which removes textures and noise before the edges are measured. Then remove the short edges, or turn off the automatic thresholds and raise the thresholds. Photos with a busy background, such as leaves or grass, usually need a blur of 2 to 4.
Some outlines are broken or missing. What can I do?Turn off the automatic thresholds and lower the low threshold, so that weak parts of the outlines are kept when they continue a strong edge. Turning on "Detect color edges" also helps when the object and the background have different colors but a similar brightness.
How do I get the outline of a logo or a drawing with a transparent background?Upload the PNG with its transparency: the border between the transparent and the visible parts is detected as an edge. Choose "Transparent" in "Background" to download only the lines.
What is the difference between Sobel, Scharr, Prewitt and Roberts?They are different kernels to measure the gradient. Sobel and Prewitt look at the 3 × 3 neighbors, Sobel giving more weight to the closest ones. Scharr is a variant of Sobel tuned to measure all the directions equally, so diagonal edges are as strong as horizontal ones. Roberts cross, the oldest, only compares the diagonal neighbors in a 2 × 2 square, which finds finer details but is more sensitive to noise.
Why is there a line along the border of the result, like a frame?Some images have a thin line of slightly different pixels at their borders, left by resizing or compression. Canny finds it as an edge. Raise the thresholds a little, or crop 1 or 2 pixels with the Crop Image tool.
Can I use the result for laser engraving, cutting or embroidery?Yes. Use Canny with black lines on white, a thickness that fits your machine, and remove the short edges. The result is a PNG image; to cut along the lines, most software can trace it into vector paths.
How big can the image be?Any size your browser can handle. A 12 megapixel photo takes about one second on a typical computer, and changing the thresholds, the thickness or the colors is faster, because the blur and the gradient are kept.
