Scribble XDoG (Soze)
XDoG Line Art, the Sketchy ControlNet Preprocessor With Real Character
- image
- image
- mask
- status
Most edge detectors are honest: Canny gives you thin hard lines, HED gives you soft structure. XDoG is the one with an opinion. It's a sketch filter - the "eXtended Difference-of-Gaussians" trick from Winnemöller's line-art rendering work - and it produces bold, ink-like, slightly expressive linework that reads as a drawing rather than a technical diagram. If you're feeding a ControlNet scribble model and want the conditioning to look like a human sketch instead of a wiring schematic, this is the preprocessor you didn't know you wanted.
The algorithm is simple enough to trust: it converts to grayscale, blurs the image twice with two different Gaussian sigmas (σ and k·σ), subtracts them to get an edge response, and pushes that through a soft-threshold with a tanh ramp. The result is a clean black-on-white line map - which is where the very first controlnet gotcha lives. ControlNet scribble models expect white lines on a black background, while XDoG naturally outputs black lines on white. That's exactly why there's an invert toggle; turn it on before feeding the output to a ControlNet and you've matched the convention. The node even has a second, subtler gotcha handled for you: it runs on CPU, because the kernels are tiny and a GPU would just sit there.
The knobs that actually matter
sigma- the base Gaussian width (default 0.5). Higher = thicker, coarser lines. This is your "line weight" dial.k- the ratio between the two Gaussians (default 1.6, the classic DoG sweet spot). Leave it alone until you know why you're touching it.sharpness- the XDoGpparameter (default 10). Emphasizes edges; higher = bolder, more assertive strokes.epsilonandphi- together they shape the threshold:epsilon(default 0, negative widens lines) sets where the soft step kicks in,phi(default 10) controls how hard/binary the edge becomes. Crankphiand you approach a pure line drawing.gamma- output brightness (default 1). Below 1 darkens, above brightens.invert- flip to white-on-black for ControlNet scribble.binarize+binarize_threshold- a hard threshold for crisp, poster-like B&W when the tanh softness isn't clean enough.
The defaults (σ=0.5, k=1.6, p=10, ε=0, φ=10) are genuinely good starting points for general line art, which is more than most preprocessing nodes can claim.
Outputs
image is the line map as an IMAGE (batch-aware - it processes every frame). The mask output is the same content as a MASK tensor, which is a nice bonus: you can use it for compositing, for masking, or to feed a ControlNet that prefers mask-typed inputs. Plus a status string.
Where it fits
Scribble conditioning is the most creative-friendly ControlNet input - it's the "draw a rough layout, the model fills it in" lane, and the KB has the goods on how lineart and scribble sit next to each other (lineart for clean structure, scribble for loose creative sketching). XDoG gives you that lane with less noise than raw scribble preprocessors and more soul than Canny. Pair it with a scribble-capable ControlNet at modest weight (0.4–0.8 is a good first guess) and let the prompt do the rest.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/SozeInc/ComfyUI_Soze.git
pip install -r ComfyUI_Soze/requirements.txt
Requires torchvision for the Gaussian blur - that ships with any standard ComfyUI install. No models, no keys. If your output looks washed out, check gamma; if it looks like noise, raise sigma; if it looks like a child's scribble (in the bad way), raise phi.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| sigma | FLOAT | 0.500.1–10 | Base Gaussian sigma. Higher = thicker/coarser lines. |
| k | FLOAT | 1.601.05–5 | Sigma ratio between the two Gaussians. 1.6 is the classic DoG sweet spot. |
| sharpness | FLOAT | 10.00–200 | XDoG 'p' parameter — emphasizes edges. Higher = bolder lines. |
| epsilon | FLOAT | 0.00-1–1 | Threshold below which the soft-step kicks in. Negative widens lines. |
| phi | FLOAT | 10.00.1–500 | Soft-threshold steepness. Higher = harder edges (more binary feel). |
| gamma | FLOAT | 1.000.1–5 | Output gamma. <1 darkens, >1 brightens. |
| invert | BOOLEAN | false | On: white lines on black background (ControlNet scribble convention). Off: black lines on white. |
| binarize | BOOLEAN | false | Hard threshold for crisp B&W. Use with binarize_threshold. |
| binarize_threshold | FLOAT | 0.500–1 | Only used when binarize=True. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| status | STRING | — |