Sobel π¦βπ₯
Edge detection the OpenCV way β the node that finds your lines
- nparrays
- dst
Sobel is the workhorse edge detector of computer vision, and if you're in this pack for its stated purpose - architectural and floor-plan image analysis - this is one of the nodes you'll live in. It computes image gradients: the rate of brightness change at every pixel, which lights up along edges and lines. In an architecture context that means walls, windows, and structural lines popping out of a render or a sketch so you can find contours, extract floor plans, or build edge maps to feed into other processing.
How it works
Under the hood it's a thin wrapper over OpenCV's cv2.Sobel, which is where the pack's name for its array type comes from - everything here operates on numpy arrays in the NPARRAY type. The node first converts a 3-channel BGR array to grayscale internally (so you can feed it color without thinking), then computes the derivative of order dx in x and dy in y. The result depends heavily on those two numbers, and that's where the "extended Sobel" part of the description lives: unlike plain Canny-style edge detection, Sobel lets you emphasize edges by orientation. dx=1, dy=0 (the default) highlights vertical edges; dx=0, dy=1 highlights horizontal ones.
By default the output is then run through cv2.convertScaleAbs() to squeeze it into an 8-bit unsigned image - that's the converted flag, on by default. Turn it off and you get the raw floating-point gradient, negative values and all, which you'd want if you're doing serious math downstream rather than just eyeballing edges.
The inputs that matter
Five, and only three you'll usually touch:
nparrays- the input array (batch supported).dx/dy- derivative order in x and y, each0β2. Defaults1and0. The one hard rule:dx + dymust be at least 1, or OpenCV throws.ksize- aperture size, odd,1β31, default3. Bigger kernel = smoother, thicker edges.ddepth- output depth, defaultCV_32F. If you're not sure, leave it;convertedhandles the 8-bit conversion.converted-true(default) gives you a viewable 8-bit edge map;falsegives raw float gradients.
Output is dst, a single-channel grayscale NPARRAY.
Installing it
It's in ComfyUI-ArchiGraph. ComfyUI Manager β search "ArchiGraph" β install β restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/vincentfs/ComfyUI-ArchiGraph
cd ComfyUI-ArchiGraph
pip install -r requirements.txt # or install.bat / install.sh on Windows
This node genuinely needs the OpenCV dependency - opencv-python (and opencv-contrib-python) is in the requirements, and the first install is slow because those wheels are large. This is also the category where OpenCV dependency conflicts with other packs show up; if you see cv2 import errors after installing, it's usually a version clash between packs - reinstalling the requirements usually settles it.
Where people get burned
Beyond the dx + dy rule: the output is single-channel, so it won't preview correctly through a plain image preview - run it through AG To Image or AG Preview Nparray Image to see it. With converted=false, the float output can contain negatives and values past 255, so don't try to save it directly as an image. And remember the input is expected to be an 8-bit NPARRAY from AG To Nparray; feeding it a float 0β1 array will give you edges that are barely there. Pair it with AG Threshold afterward to turn the gradient into a clean binary edge map.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| nparrays | NPARRAY | β | |
| dx | INT | 10β2 | Order of the derivative x. |
| dy | INT | 00β2 | Order of the derivative y. |
| ksize | INT | 31β31 | Aperture size for the Sobel operator. Must be odd and greater than 1. |
| ddepth | COMBO | CV_32F | Desired depth of the destination image. Use CV_32F/64F for float output. |
| converted | BOOLEAN | true | If true, the output will be converted with cv2.convertScaleAbs() to 8-bit unsigned integer. If false, the output will remain unprocessed. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| dst | NPARRAY | β |