OpenCV Laplacian_0
OpenCV Laplacian_0 for line art and sharpening
- src
- dst
- nparray
Want an edge map that costs zero VRAM and runs in milliseconds? That's what this node is. Laplacian_0 wraps OpenCV's cv2.Laplacian - a second-derivative edge detector - as a ComfyUI node, so you can pull edges out of an image without loading a single model. No ControlNet preprocessor, no depth anything, just math.
It's part of the opencv-comfyui pack, which auto-generates a node for basically every top-level cv2 function. "Expect dragons" is the author's own warning, and he's not wrong - but the Laplacian is one of the friendlier corners of the pack.
Why you'd reach for it
The classic uses are line art extraction, generating an edge pass to feed ControlNet (the kind of thing people usually reach for Canny for - Laplacian catches finer detail but is noisier), and the old sharpen trick: subtract the Laplacian from the original to get an unsharp-mask-style bump in perceived sharpness. On a generated image it's a fast way to check whether your subject has hard edges that a detail pass or line-art LoRA will have something to work with. It's deterministic and instant, so you can also just run it to look at the edges in your frame.
How it works
The Laplacian is the sum of the second derivatives in x and y - mathematically, it's a single convolution with a kernel that lights up wherever the intensity changes direction, i.e. wherever there's an edge. Unlike Sobel it's rotationally isotropic-ish, which means it doesn't care whether the edge is horizontal, vertical or diagonal. That's its whole appeal: one kernel, every direction.
The inputs that matter:
- src - your image as an
NPARRAY. This is the gotcha that trips everyone: OpenCV nodes don't take ComfyUIIMAGE. You must feed them throughImage2Nparrayfirst, and pipe the output back throughNparrays2Imageto see anything. - ddepth - output depth.
-1means "same as input", which for a normal uint8 image gives you an 8-bit edge map. Anything else (e.g.5forCV_32F) gives you float output you'll want to normalize. - ksize - the kernel size, and it must be odd: 1, 3, 5, or 7.
1is a tiny fast kernel,3is the sane default, bigger is blurrier-but-thicker edges. - scale and delta - a multiplier and a bias applied to the result. Leave
scale=1, delta=0and forget they exist. - borderType - how the kernel behaves at image edges. Default
4is fine; don't touch it.
There's an optional dst out-parameter. Skip it - the node returns the result in its single nparray output anyway, and the README explicitly says to avoid feeding dst.
Install
ComfyUI Manager: search "opencv" and install opencv-comfyui. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python
Then restart ComfyUI. The pack needs opencv-contrib-python, numpy, and torch - all standard. No model files to download, ever.
Common issues
Only images with batch_size==1 are supported!- the pack doesn't do batches. Slice your batch withImageFromBatch(length=1) before the conversion node.invalid syntax (<unknown>, line 0)- that's a composite-parameter syntax error somewhere. For this node it means you typed something weird, but on the string-based nodes it means your Python literal was wrong.Cannot import name 'guidedFilter' from 'cv2.ximgproc'- conflicting OpenCV packages in your environment (usuallyopencv-pythonandopencv-contrib-pythonboth installed). Uninstall one, keep the contrib one.
One honest caveat: on a noisy generated image a raw Laplacian looks like static. If you want clean line art, blur (or median-filter) before, or reach for the _1 variant - which, spoiler, is the same node.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| ddepth | INT | — | |
| ksize | INT | — | |
| scale | FLOAT | — | |
| delta | FLOAT | — | |
| borderType | INT | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |