ComfyUI Node

MX_Canny

An edge-detection mask without installing a ControlNet preprocessor pack

By Intersection98·Created 2 years ago·Updated 2 years ago· 13
MX_Canny
  • image
  • IMAGE
lower_threshold0.00
upper_threshold1.00

MX_Canny is the pack's edge-detection node: it runs Canny edge detection on your image and hands you back a white-on-black line mask of everything it found. If you're feeding a Canny ControlNet, this saves you installing the entire ControlNet Aux preprocessor pack just to get one edge map - though read the "where people get burned" section before you count on that, because there's a catch.

It's part of Intersection98/ComfyUI-MX-post-processing-nodes. The output is a mask in all but name, which is why the pack's example workflow runs it through a MaskToImage step before previewing.

How it works

It converts each frame to grayscale and runs OpenCV's cv2.Canny with your two thresholds. Canny works by finding strong gradients (pixels above upper_threshold are definitely edges) and then tracing connected weak gradients (above lower_threshold) out from them. The node scales your 0–1 threshold floats by 500 internally - so lower_threshold = 0.1 becomes 50, upper_threshold = 0.6 becomes 300 in OpenCV's 0–255 scale. The result is a single-channel tensor (one value per pixel, not a color image), which is why it behaves like a mask.

The inputs that matter

  • image - your IMAGE tensor.
  • lower_threshold - 0 to 1, default 0. The weak-edge cutoff. Raise it to suppress noise and faint detail.
  • upper_threshold - 0 to 1, default 1. The strong-edge cutoff. The classic Canny problem: default 0/1 means everything with any gradient is an edge, which produces noisy, spaghetti-line masks. A saner starting pair for most renders is around 0.2–0.3 for lower and 0.5–0.7 for upper.

Output is a single-channel IMAGE tensor shaped (B, H, W) - a mask, not a viewable color image.

Install

Standard MX pack install. ComfyUI Manager (search MX or ComfyUI-MX-post-processing-nodes), or:

cd ComfyUI/custom_nodes
git clone https://github.com/Intersection98/ComfyUI_MX_post_processing-nodes
cd ComfyUI_MX_post_processing-nodes
pip install -r requirements.txt

Restart ComfyUI; it appears under postprocessing/Masks. No models, no downloads - opencv-python (already required by most installs) does the actual work.

Where people get burned

The threshold defaults are a trap: 0/1 out of the box produces an over-detected mess on most images. You almost always need to raise lower_threshold and lower upper_threshold before the mask is usable. Second, the output is typed IMAGE but shaped like a mask - if you try to preview it directly you'll get a confusing result, and if you're driving a Canny ControlNet, check that your ControlNet loader is actually accepting it (the pack's example workflow routes it through MaskToImage first). Third, don't reach for this as a "clean lineart" generator - Canny is purely gradient-based, so textured areas (grass, fabric, hair) turn into noise while smooth surfaces stay empty. For ControlNet-style clean lineart you're usually better off with the Auxiliary Preprocessors' dedicated lineart nodes; this node shines as a quick in-graph mask source for compositing and stylization instead.

Categorypostprocessing/Masks

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
lower_thresholdFLOAT0.000–1
upper_thresholdFLOAT1.000–1

Outputs (1)

NameTypeDescription
IMAGEIMAGE