ComfyUI Node

Scribble XDoG (Soze)

XDoG Line Art, the Sketchy ControlNet Preprocessor With Real Character

By SozeInc·Created 2 years ago·Updated 8 days ago· 10
Scribble XDoG (Soze)
  • image
  • image
  • mask
  • status
sigma0.50
k1.60
sharpness10.0
epsilon0.00
phi10.0
gamma1.00
invertfalse
binarizefalse
binarize_threshold0.50

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 XDoG p parameter (default 10). Emphasizes edges; higher = bolder, more assertive strokes.
  • epsilon and phi - 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. Crank phi and 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.

Categoryimage/preprocessors

Inputs (10)

NameTypeDefaultDescription
imageIMAGE
sigmaFLOAT0.500.1–10Base Gaussian sigma. Higher = thicker/coarser lines.
kFLOAT1.601.05–5Sigma ratio between the two Gaussians. 1.6 is the classic DoG sweet spot.
sharpnessFLOAT10.00–200XDoG 'p' parameter — emphasizes edges. Higher = bolder lines.
epsilonFLOAT0.00-1–1Threshold below which the soft-step kicks in. Negative widens lines.
phiFLOAT10.00.1–500Soft-threshold steepness. Higher = harder edges (more binary feel).
gammaFLOAT1.000.1–5Output gamma. <1 darkens, >1 brightens.
invertBOOLEANfalseOn: white lines on black background (ControlNet scribble convention). Off: black lines on white.
binarizeBOOLEANfalseHard threshold for crisp B&W. Use with binarize_threshold.
binarize_thresholdFLOAT0.500–1Only used when binarize=True.

Outputs (3)

NameTypeDescription
imageIMAGE
maskMASK
statusSTRING