OpenCV sepFilter2D_0
OpenCV's separable filter in ComfyUI
- src
- kernelX
- kernelY
- dst
- nparray
sepFilter2D_0 applies a separable convolution to your image - which is a fancy way of saying "blur or sharpen it using two 1D kernels instead of one 2D kernel." It's the engine underneath half the filters in OpenCV, exposed raw. Gaussian blur, Sobel, most box and derivative filters are all separable, which is why OpenCV implements them as two skinny passes rather than one chunky one. This node just lets you drive that machinery with kernels of your own.
Why would you reach for it over the friendlier GaussianBlur or Sobel nodes in this same pack? Mostly you wouldn't. Those cover the common cases with a single widget. You go straight to sepFilter2D when you have two 1D kernels you specifically want - a custom smoothing row and a custom derivative column, say - or when you're porting an OpenCV script into ComfyUI and want the same call. In the post-processing world this is the "do one deterministic thing to the pixels" tier, not a generative pass, so it's instant and free to run.
The mechanism: instead of convolving the whole image with a k×k kernel, it applies kernelX horizontally and kernelY vertically in sequence. Mathematically identical to one 2D convolution with the outer product of the two kernels, but for a 7-wide kernel that's 7+7 operations per pixel instead of 49. That's the entire point of the node.
The inputs that matter:
- src - your NPARRAY. In this pack that means you've already run
Image2Nparrayon a ComfyIMAGE(it flips RGB→BGR and scales to 0–255 uint8). There's no shortcut; the filter is a BGR-world citizen. - kernelX / kernelY - both NPARRAY inputs, not text. A 1D kernel like a float row
[1, 2, 1]as a 1×3 or 3×1 array. You'll need some node that produces an nparray of kernel values - the pack's owngetGaussianKernel_0is the natural source. This is where beginners get stuck: there's no simple "type your kernel here" box. - ddepth - output depth.
-1keeps the source depth (uint8 in, uint8 out). Use5(CV_32F) when you want float math and don't want values clamped. - anchor - a STRING, which is the pack's quirk: composite types are entered as Python literals and parsed with
literal_eval. Type(-1, -1)(exactly, with parentheses) for the kernel center. - delta - a constant added to every pixel after filtering, usually
0. - borderType -
0(BORDER_CONSTANT) or4(BORDER_DEFAULT) are the sane options; leave it at4.
The optional dst input is the OpenCV out-parameter. Leave it unconnected; the generator passes None and OpenCV allocates the result. You get one nparray output - wire it to Nparrays2Image to see the result.
Install via ComfyUI Manager (search "opencv-comfyui") or clone into custom_nodes and run pip install opencv-contrib-python numpy torch - the requirements are just that, and you already have numpy and torch.
Common gotchas: if ComfyUI won't start with Cannot import name 'guidedFilter' from 'cv2.ximgproc', another node installed a conflicting OpenCV - uninstall extras so only one opencv-contrib-python remains. And remember the whole pack is auto-generated from OpenCV's type stubs ("expect dragons" is literally in the README), so if the literal string in anchor isn't valid Python syntax you get invalid syntax (<unknown>, line 0).
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| ddepth | INT | — | |
| kernelX | NPARRAY | — | |
| kernelY | NPARRAY | — | |
| anchor | STRING | — | |
| delta | FLOAT | — | |
| borderType | INT | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |