cv2.ximgproc.GradientDericheY
The vertical half of the Deriche gradient pair
- op
- nparray
The short version: this is cv2.ximgproc.GradientDericheX rotated 90°. Same recursive Deriche operator, same parameters, same signed float output - it just differentiates along Y, so it responds to horizontal edges (things changing top-to-bottom) where its sibling responds to vertical ones. If you're here from a search, the useful question isn't "what does this one do" but "what do I do with the pair".
What you do is combine them. Feed both nodes the same source image, wire their outputs into the generated cv2.magnitude wrapper, and you have a gradient magnitude map with Deriche's nice property: widening the smoothing costs you almost nothing per pixel, because the filter is recursive rather than a growing kernel. That's the reason to prefer it over "Gaussian blur then Sobel", which gets slower the more you smooth.
Inputs and outputs
- op - the image. It's the only image input, named
op(OpenCV's C++ parameter order leaking through), and it accepts a ComfyUI IMAGE/MASK directly - frame 0 of a batch - or an NPARRAY from a bridge node. - alpha - sharpness. Larger alpha means narrower smoothing and sharper, noisier edges; smaller means broader smoothing. Start around the middle of that range and work outward.
- omega - the spatial frequency the operator is tuned to; the tooltip suggests small values, around 0.1.
Output is one plain NPARRAY: a single-channel 32-bit float gradient, signed, where + and − mean opposite edge polarities. It's data, not a picture. Inspect CV Data for shape and range, CV Array → Image to preview (floats are min-max normalized on the way in), CV Color Map for a heatmap.
Note the schema's default: both numeric widgets start at 0, and the node passes those through. Zero is outside the useful range for either parameter, so a brand-new node with untouched widgets gives you a flat, useless map. Set them.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv
Restart ComfyUI, or install ComfyUI CV from ComfyUI Manager. Python ≥3.12, a recent ComfyUI on the V3 node API, and opencv-contrib-python-headless~=5.0.0.93. Nothing to download. ximgproc only exists in contrib builds: installing opencv-python (non-contrib) over it empties the contrib submodules and both Deriche nodes disappear from the menu. tools/repair_opencv_contrib.py --check tells you if that's what happened.
Common issues
A flat grey preview. Almost always alpha/omega left at 0, or a genuinely edge-free input (clear sky, a flat wall).
The two nodes disagree. They shouldn't - same image, same alpha, same omega, different axis. If X and Y look wildly different in scale, check that you haven't wired different bridges (one IMAGE path and one NPARRAY path can differ in depth, and depth changes the numbers a lot).
Contribution to a mask pipeline needs a normalizing step. The output is float and signed; mask consumers want 0–255 (or 0–1). CV Cast Array converts dtype with scaling; CV Array → Mask min-max normalizes. Feeding the raw float somewhere a mask is expected gives you a black mask, not an error.
Both Deriche nodes are memory-light but not free. There's no subprocess offload here - unlike the ximgproc smoothing filters next door - so a slow run means your frame is big and your graph has quietly become a per-frame loop, not that the node is stuck.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| op | NPARRAY,IMAGE,MASK | - - - Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size. | |
| alpha | FLOAT | 0.0000-1e+38–1e+38 | - - - |
| omega | FLOAT | 0.0000-1e+38–1e+38 | - - - |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |