Nodes/opencv-comfyui/OpenCV getDerivKernels_1
ComfyUI Node

OpenCV getDerivKernels_1

The Same Edge-Kernel Generator, Under a Second Name

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV getDerivKernels_1
  • kx
  • ky
  • nparray_0
  • nparray_1
dx
dy
ksize
normalize
ktype

OpenCV getDerivKernels_1 is the duplicate twin of getDerivKernels_0. The opencv-comfyui pack auto-generates one node per OpenCV overload it finds in the type stubs, and cv2.getDerivKernels has two overloads that flatten to the same signature - so you get two identical nodes. Same inputs, same outputs, same behavior. There's no reason to use both, and no hidden difference to discover. If this is the one you found, it does everything the _0 one does.

What it produces

It manufactures the two 1D convolution kernels behind Sobel/Scharr edge detection: nparray_0 (the x-derivative kernel) and nparray_1 (the y-derivative kernel). You feed those into a separable filter node like sepFilter2D (in this pack) to actually apply edge detection, or into your own custom convolution code. It's for people who want the filter guts - custom aperture sizes, separated x/y passes, hand-built pipelines - rather than the one-shot Sobel or Canny nodes.

The inputs are the straightforward ones:

  • dx / dy (INT) - derivative order in each axis; keep one at 0 for a pure horizontal or vertical edge detector.
  • ksize (INT) - odd aperture from 1 (Scharr-style) up to 7.
  • normalize (BOOLEAN) - unit-gain normalization; False keeps the classic integer Sobel coefficients.
  • ktype (INT) - kernel dtype, -1 for same-as-source, 5 for CV_32F, 6 for CV_64F.
  • kx / ky (NPARRAY, optional) - OpenCV out-parameters; ignore them, the outputs already carry the kernels.

When you'd bother

The convenience edge nodes exist for a reason - if all you want is a sharpened outline, call Sobel or Canny and be done. getDerivKernels earns its keep when you need control: a ksize the convenience wrappers won't give you, or the actual coefficient arrays to inspect, debug, or reuse in a hand-rolled filter. That's a niche, but it's a real one, and this is the honest way to reach it.

Install

Standard for the pack - ComfyUI Manager, search opencv-comfyui (display name "OpenCV"):

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python

Restart ComfyUI. No model downloads.

The pack's standing gotchas apply: outputs are NPARRAY (numpy, not IMAGE), batch size must be 1, and composite literals need bracket syntax. An even ksize throws an OpenCV assertion, and dx=dy=0 returns a smoothing kernel with no derivative - legal but pointless. Since this node is a pure duplicate, pick one variant, bookmark it, and forget the other exists.

Categoryimage/OpenCV

Inputs (7)

NameTypeDefaultDescription
dxINT
dyINT
ksizeINT
normalizeBOOLEAN
ktypeINT
kxoptNPARRAY
kyoptNPARRAY

Outputs (2)

NameTypeDescription
nparray_0NPARRAY
nparray_1NPARRAY