Nodes/ComfyUI-Img2DrawingAssistants/Img2LineArt Assistant
ComfyUI Node

Img2LineArt Assistant

Photos to clean line art, done with plain OpenCV — no lineart model needed

By Isi-dev·Created 2 years ago·Updated 11 months ago· 22
Img2LineArt Assistant
  • image
  • lineArt
  • grayscale image
line_thickness11
Clean_up7
deep_Clean_up2
line_color
color_strength10.0
details9
smoothness1.0
bg_color
bg_light10

Line art - clean, closed, ink-ready outlines - is what a lot of people actually want when they say "sketch," and this node is the tool in the ComfyUI-Img2DrawingAssistants pack that delivers it. Where the sketch nodes give you soft graphite shading, the Img2LineArt Assistant gives you crisp thresholded lines you can drop into a ControlNet lineart pass or a coloring workflow. And like everything in this pack, there's no model involved: it's a couple of OpenCV calls on the CPU, instant and dependency-light.

The output style is a "sketchy" line art rather than the clean anime outlines a dedicated lineart preprocessor produces - think ink on paper, with line thickness you control. That's a feature if you want a hand-drawn feel, and the author's own advice for polish is to keep it in the pack: this node's sibling, lineArt2LineArt Assistant, will clean and recolor whatever comes out.

How it works

The engine is cv2.adaptiveThreshold, which compares every pixel against the weighted mean of its neighborhood and flips it to black or white. That's the same idea the ControlNet lineart preprocessors approximate with a neural net - here it's done in three lines of numpy, which is why it's free and instant.

The three line knobs map directly onto the OpenCV call. line_thickness (3–81, step 2) is the block size: the neighborhood each pixel is compared against, so bigger values give chunkier lines that ignore fine texture. Clean_up (1–49, step 2) is a Gaussian blur applied before thresholding - when it's above 1, it smooths the input so the threshold doesn't chase noise. details (1–9) sets the constant subtracted from the local mean; higher values push the threshold right up against the mean, which drags in more fine detail. Then deep_Clean_up (0–5) runs morphological noise removal on the result to kill stray specks.

The inputs that matter

  • line_thickness (default 11) - stroke chunkiness. Start here.
  • details (default 9) - how much fine line detail survives. Crank it if lines look washed out.
  • deep_Clean_up (default 2) - speckle removal passes; raise it for messy inputs.
  • line_color + color_strength - recolor the strokes into any of 16 named colors; strength 10 is full saturation, lower values wash the ink toward white.
  • bg_color + bg_light - repaint the paper behind the lines.

Outputs

lineArt is the processed line art (recolored, background painted) - wire it to Preview or Save Image. grayscale image is the plain grayscale of the source, untouched. If you're building a ControlNet lineart conditioning, the processed lineArt output is the one to feed a lineart model.

Install

ComfyUI Manager, search ComfyUI-Img2DrawingAssistants, install, restart. Or clone manually:

cd ComfyUI/custom_nodes
git clone https://github.com/Isi-dev/ComfyUI-Img2DrawingAssistants

No model downloads. The dependencies are torch, numpy, opencv-python; torch and numpy already ship with ComfyUI, and cv2 is the only one that might get pulled in - Manager installs it for you. Same pack-wide note: it wants the full opencv-python build, where ComfyUI typically has opencv-python-headless; they both provide cv2, so expect occasional pip churn but no real breakage.

Troubleshooting

Thresholded line art is brutally honest about input quality. A photo with soft gradients and weak contrast will come out as dotted fragments - that's what Clean_up (pre-blur) and deep_Clean_up (speckle removal) are for; raise both and thicken line_thickness before you give up. If lines look fat and blobby, drop line_thickness and details. And remember the author's framing: the pack is an assistant - output quality tracks input quality, and you'll likely want a cleanup pass afterward, which is exactly what the lineArt2LineArt Assistant node exists to do.

Categoryimage

Inputs (10)

NameTypeDefaultDescription
imageIMAGE
line_thicknessINT113–81
Clean_upINT71–49
deep_Clean_upINT20–5
line_colorCOMBO16 options: black, gray, white, lime, blue, yellow, +10
color_strengthFLOAT10.01–10
detailsINT91–9
smoothnessFLOAT1.01–5
bg_colorCOMBO16 options: white, black, red, lime, blue, yellow, +10
bg_lightFLOAT101–100

Outputs (2)

NameTypeDescription
lineArtIMAGE
grayscale imageIMAGE