Nodes/VKRiez-Edge/VKriez Enhanced Edge Preprocessor
ComfyUI Node

VKriez Enhanced Edge Preprocessor

VKriez Enhanced

By vadimcro·Created 2 years ago·Updated 2 years ago· 17
VKriez Enhanced Edge Preprocessor
  • image
  • IMAGE
◄use_bilateraltrue►
◄use_gpu_accelerationtrue►
◄bilateral_d7►
◄bilateral_sigma_color75►
◄bilateral_sigma_space75►
◄use_clahetrue►
◄clip_limit2.0►
◄tile_grid_size8►
◄canny_low_threshold100►
◄canny_high_threshold200►
◄canny_aperture3►
◄use_edge_linkingtrue►
◄gap_threshold3►
◄angle_threshold30►
◄use_morphologytrue►
◄morph_kernel_size3►
◄morph_iterations1►
◄use_component_filtertrue►
◄min_component_size20►
◄use_adaptive_regionstrue►
◄use_enhanced_filteringtrue►
◄connectivity_threshold2►
◄use_edge_consistencytrue►
◄target_edge_thickness1►

Every edge preprocessor has the same two failure modes: too noisy, or broken lines. Plain Canny gives you a confetti of specks and texture; most "clean" preprocessors fix that but leave your outlines looking like a cracked windshield. The VKriez Enhanced Edge Preprocessor is the classical pipeline that tries to fix both at once - no model download, no GPU requirement, just OpenCV/skimage work that produces continuous, even-thickness lines. If you've got a technical drawing, a product shot, or a comic page and you want a deterministic edge map ControlNet actually respects, this is the one you'll reach for. It's also the classical half of the pack's fancier Hybrid MTEED node, so understanding this one teaches you the shared knob set.

How it works

It's a staged OpenCV pipeline, and you can switch each stage on or off:

  1. Adaptive regions - a saliency mask splits the image into foreground/background so later stages can treat them differently.
  2. Bilateral filter (optional) - smooths flat areas while keeping edges sharp, so skin texture and grain don't become phantom edges. The use_gpu_acceleration toggle swaps in a fast torch approximation of bilateral when CUDA is available, and falls back to cv2.bilateralFilter on CPU (or if the GPU path throws).
  3. CLAHE - local contrast enhancement so faint edges in shadows and highlights survive Canny.
  4. Canny - with low/high thresholds and aperture, using L2 gradient.
  5. Edge linking - the headline feature. It finds line endpoints with a Sobel-based trick and connects endpoints that are close (within gap_threshold pixels) and roughly aligned (angle_threshold degrees), searching only a local bounding box around each endpoint. That "local search instead of global" detail is why it's faster than naive linking algorithms. This is the stage that fixes broken lines.
  6. Morphology - closing to fuse nearby segments.
  7. Component filter - deletes small isolated specks below min_component_size.
  8. Edge consistency - skeletonizes then optionally re-dilates to target_edge_thickness (1–3), so lines are uniform rather than ragged.

Inputs and outputs that matter

Image in, one IMAGE out - the edge map, which you wire into a ControlNet Apply node (or a Preview node first). Of the ~22 inputs, a beginner sets three or four:

  • canny_low_threshold / canny_high_threshold (defaults 100/200): the classic Canny dials. Lower lows catch faint lines; raise the high to 220–250 to kill noise.
  • gap_threshold (1–10, default 3) and angle_threshold (5–90, default 30): how aggressively broken lines get stitched together. Raise both for sketches with big gaps; keep angle moderate or you'll bridge things that shouldn't connect.
  • min_component_size (5–500, default 20): the speckle killer. Crank it for noisy scans.

Everything defaults to on, which is opinionated but usually right. The use_edge_linking toggle is the single biggest speed lever - linking is the most computationally expensive stage, and turning it off makes preview iterations much faster.

Installing it

cd ComfyUI/custom_nodes/
git clone https://github.com/vadimcro/VKRiez-Edge.git

Then restart ComfyUI. That's genuinely it for this node - no model download, no pip extras, no CUDA requirement (CPU works, just slower). Or search "VKRiez-Edge" in ComfyUI Manager, which also keeps it updatable. The pack needs OpenCV and scikit-image, which ComfyUI's bundled environment already ships.

Troubleshooting

  • Too many edges / noise: raise Canny high threshold toward 220–250, bump min_component_size to 50–100, and/or increase bilateral diameter and sigmas.
  • Important edges missing: drop Canny low to 50–70, raise the CLAHE clip_limit toward 3–4.
  • Gaps: raise gap_threshold to 5–7 and angle_threshold to 45–60, or bump morphology kernel/iterations.
  • Edges too thick: reduce morphology and bilateral; set target_edge_thickness to 1.
  • Slow: disable edge linking, or smaller bilateral diameter. The GPU toggle only helps the bilateral stage - everything else is CPU OpenCV regardless.

One caveat worth knowing: it's a small, single-author pack (VKriez, March 2025) with basically no community track record yet, so treat the defaults as a starting point, not gospel. Preview before you commit a workflow to it.

CategoryVKriez/image/preprocessors

Inputs (25)

NameTypeDefaultDescription
imageIMAGE—
use_bilateralBOOLEANtrue—
use_gpu_accelerationBOOLEANtrue—
bilateral_dINT75–15—
bilateral_sigma_colorFLOAT7510–200—
bilateral_sigma_spaceFLOAT7510–200—
use_claheBOOLEANtrue—
clip_limitFLOAT2.00.5–10—
tile_grid_sizeINT82–16—
canny_low_thresholdINT1000–255—
canny_high_thresholdINT2000–255—
canny_apertureINT33–7—
use_edge_linkingBOOLEANtrue—
gap_thresholdINT31–10—
angle_thresholdINT305–90—
use_morphologyBOOLEANtrue—
morph_kernel_sizeINT31–7—
morph_iterationsINT11–3—
use_component_filterBOOLEANtrue—
min_component_sizeINT205–500—
use_adaptive_regionsBOOLEANtrue—
use_enhanced_filteringBOOLEANtrue—
connectivity_thresholdINT21–5—
use_edge_consistencyBOOLEANtrue—
target_edge_thicknessINT11–3—

Outputs (1)

NameTypeDescription
IMAGEIMAGE—