OpenCV Laplacian_1
OpenCV Laplacian_1 — the duplicate edge detector (and why it exists)
- src
- dst
- nparray
Here's the first thing to know: OpenCV Laplacian_1 and OpenCV Laplacian_0 are the same node. Same inputs, same behavior, same output. This isn't a bug - it's a side effect of how the whole opencv-comfyui pack is built, and it applies to every node in the pack that ends in _0 or _1. Once you understand that, half the confusion around this pack evaporates.
Why there are two of them
OpenCV's type definitions declare every function twice - once for regular matrices (cv2.typing.MatLike) and once for OpenCL-backed UMat images. When the pack's generator walked those definitions it numbered the overloads: _0 gets the first, _1 the second. In the generated node both overloads collapse to the same NPARRAY handling, so functionally you get two identical nodes. Pick whichever one is closer on the canvas. Don't hunt for a difference; there isn't one.
What it actually does
It's a Laplacian edge detector - the second-derivative filter that lights up wherever pixel intensity changes direction. Grab a generated image, push it through this, and you get a gray-on-black edge map in about the time it takes to blink. No model, no VRAM. People use it for line art passes, feeding edges into ControlNet, and the classic sharpen trick of subtracting the Laplacian from the source.
The inputs are the boring-but-must-know set:
- src - an
NPARRAY. Remember the pack rule: ComfyUIIMAGEdoesn't work here. Convert withImage2Nparrayin,Nparrays2Imageout. - ddepth -
-1keeps the input depth; that's the value you want for a viewable uint8 edge map. Float depths mean float output you'll have to normalize. - ksize - kernel size, must be odd (1, 3, 5, 7).
3is the sane default. - scale / delta - a gain and offset applied after the convolution. Defaults (
1.0,0.0) are fine. - borderType - edge-handling mode. Default is fine.
The optional dst out-parameter is a trap the README warns about: it's a legacy call-by-reference thing that doesn't fit ComfyUI's flow. Leave it unplugged; the node returns the result on its nparray output.
Install
Same as every node in this pack:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python
Then restart ComfyUI. Or just search "opencv" in ComfyUI Manager and install it there. Nothing to download beyond the pip packages - no models, no weights.
The gotchas that actually bite
- Grayscale assertion. The Laplacian works on color images fine, but a lot of the neighboring functions in this pack (
Cannyetc.) assertCV_8UC1. If you hiterror: (-215:Assertion failed) img.type() == CV_8UC1, convert withcvtColor(code=6forBGR2GRAY) first. - Batch error.
Only images with batch_size==1 are supported!- slice withImageFromBatch, length=1. - Noisy output. A Laplacian on an unprocessed noisy image looks like static. Blur before or accept it. If you want a smoother, more forgiving edge map, that's what the
_0... sorry, that's what a Gaussian-then-Laplacian or Canny will give you instead.
Real talk: for anything serious you probably want the ControlNet Auxiliary Preprocessors pack, which wraps the same OpenCV algorithms with the ComfyUI IMAGE conversion handled for you. This pack exists for people who want the raw cv2 functions, intentional channel conversions and all.
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 | — |