Sketch
Turn a photo into pencil-drawing lines with XDoG
- image
- image
Sketch converts a photo into pencil/ink line art - not a stylized filter approximating a sketch, but an actual edge-detection algorithm. The parameter names give it away if you know computer vision: sigma, k_sigma, epsilon, phi, gamma are the textbook parameters of XDoG (eXtended Difference-of-Gaussians), a well-established non-photorealistic rendering technique for turning images into clean line drawings. This isn't a diffusion effect and it's not learned from anything - it's classic image processing, deterministic and fast.
How it works
Difference-of-Gaussians finds edges by blurring an image at two slightly different radii and subtracting one from the other - what's left is the detail that exists at one blur level but not the other, which lines up closely with actual edges in the image. XDoG extends this with a soft threshold instead of a hard on/off cutoff, which is what lets it produce continuous, ink-like lines rather than a broken, noisy edge map.
The inputs and outputs that matter
image- your source.sigma(1–5, default 1.4) andk_sigma(1–5, default 1.6) - the two blur radii being differenced.k_sigmashould generally stay larger thansigma; leave both near default unless you're specifically after thicker or thinner base lines.epsilon(-0.2 to 0.2, default -0.03) - the threshold that decides what counts as an edge. More negative pushes toward cleaner, sparser lines with more white space; closer to zero (or positive) darkens the result and pulls in more detail as linework.phi(1–50, default 10) - controls how sharp the transition is at that threshold. Higher values make the line/no-line boundary crisper; lower values give a softer, more graphite-like gradient instead of hard black lines.gamma(0.75–1, default 1) - a soft toning adjustment on the non-edge areas.color_mode(gray/rgb) -graygives you the classic pencil-sketch look;rgbkeeps the line art in the original colors instead of converting to grayscale.scale(bool) - whether to rescale the output's value range.
One image output.
How to install it
Search ComfyUI-HakuImg in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone --recurse-submodules https://github.com/licyk/ComfyUI-HakuImg
Restart ComfyUI, find it under Image → HakuImg. No models involved - this is pure math on pixel values, runs instantly regardless of GPU.
Common issues & troubleshooting
Lines are too faint or sparse. Nudge epsilon toward zero, or raise phi a bit - both push more of the image's contrast into visible linework rather than white space.
Whole image comes out solid black or solid white. You've pushed a parameter outside its sane working range, most often epsilon too far positive or phi too extreme. Reset toward the defaults (sigma 1.4, k_sigma 1.6, epsilon -0.03, phi 10) and adjust one parameter at a time from there rather than several at once - with five interacting numbers, it's easy to lose track of which one broke it.
Result looks noisy rather than clean. Try increasing sigma slightly - a larger base blur radius smooths out fine texture noise before the edge-difference step, which tends to produce cleaner, more deliberate-looking lines on photos with a lot of surface detail (skin texture, fabric, foliage).
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| kernel_size | INT | 00–25 | — |
| sigma | FLOAT | 1.401–5 | — |
| k_sigma | FLOAT | 1.601–5 | — |
| epsilon | FLOAT | -0.030-0.2–0.2 | — |
| phi | FLOAT | 101–50 | — |
| gamma | FLOAT | 1.0000.75–1 | — |
| color_mode | COMBO | 2 options: gray, rgb | |
| scale | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |