OpenCV Scharr_1
The sharper gradient, UMat edition
- src
- dst
- nparray
Scharr_1 is Scharr_0's UMat overload, which is pack-speak for "the same node, generated twice because OpenCV's type stubs list every function once for numpy arrays and once for UMat." From the ComfyUI side there is no observable difference - same inputs, same behavior, same output. Grab whichever, wire it up, done.
What it does
The job: the Scharr operator, the 3×3 gradient filter that fixes Sobel's odd-size asymmetry. Run it on grayscale and it produces a gradient image highlighting edges - dx=1, dy=0 for vertical transitions, dx=0, dy=1 for horizontal. It's the accurate classical filter for edge maps and a step toward Canny-style detection. The full explanation, including the ddepth saturation trap (-1 clips on uint8 - use 5/CV_32F, 6/CV_64F, or 2/CV_16S) and the dx+dy==1 rule, lives in the Scharr_0 article.
Inputs and outputs
Inputs here: src, ddepth, dx, dy, scale, delta, borderType - all the same magic constants, same gotchas, plus the optional dst out-parameter you should leave unwired. Output: one nparray, and remember grayscale in via cvtColor (code 6) or the uint8 assertion bites.
Installing
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python
Install: ComfyUI Manager → search "opencv-comfyui", or the commands above, then pip install opencv-contrib-python for the dependency. No models to download.
Verdict
The only practical thing to remember about this pair: Scharr_0 and Scharr_1 are interchangeable. If a shared workflow references one and you have the other, it works as-is. That's the whole story of the _1 nodes in this pack - a duplicate that exists because the generator numbered every overload, not because there's a real choice to make.
And the workflow tip that saves the most debugging: feed Scharr a genuinely grayscale image - the pack's cvtColor with code 6 (BGR2GRAY) - because a color input either trips the channel-count assertion or produces a per-channel gradient you never meant to compute.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| ddepth | INT | — | |
| dx | INT | — | |
| dy | INT | — | |
| scale | FLOAT | — | |
| delta | FLOAT | — | |
| borderType | INT | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |