CivArchive
    ← All articles
    Published February 12, 2026by bemoreone807

    [Custom Node] Phase Congruency Edge

    111 views0 reactions0 comments on CivitAI0 collected
    announcementcomfyui, custom node, edge detection, controlnet, preprocessing,   image processing

    https://github.com/bemoregt/ComfyUI_PhaseCongruencyEdge

     ---                                                                                          

      Phase Congruency Edge — A Smarter Edge Detector for ComfyUI                                

                                                                                                   

      If you've ever used ControlNet with Canny or Depth maps, you know how powerful structural  

      guidance can be. But Canny has a dirty secret: it breaks under different lighting conditions 

      and contrast levels. Crank up the exposure on your image and the edge map completely changes.

      Phase Congruency Edge solves this problem at the mathematical level.

      ---

      What Makes It Different?

      Standard edge detectors like Canny or Sobel work by measuring intensity gradients — how fast

      pixel brightness changes. That means their output is directly tied to lighting, exposure, and

       local contrast.

      Phase Congruency works differently. It looks at the Fourier frequency components of an image

      and asks: at which pixels do all these components arrive in phase at the same time? Those

      points are the true features — edges, corners, ridges — and they stay stable no matter how

      you change the brightness or contrast.

      The result is an edge map that is:

      - Illumination invariant — same result under any lighting

      - Contrast invariant — works on flat, low-contrast images too

      - Perceptually accurate — detects what the human eye sees as a boundary

      - Multi-scale — captures both fine detail and broad structure simultaneously

      ---

      How to Use It in ComfyUI

      Install the node into your custom_nodes folder:

      cd ComfyUI/custom_nodes

      git clone https://github.com/bemoregt/ComfyUI_PhaseCongruencyEdge.git

      Restart ComfyUI and find the node under image/filters Phase Congruency Edge.

      Connect any IMAGE to it and it outputs a clean grayscale edge map — ready to feed into

      ControlNet, use as a mask, or composite directly into your workflow.

      ---

      Key Parameters

      ┌────────────────┬─────────────────────────────────────────────────────────────────────┐

      │   Parameter    │                            What it does                             │

      ├────────────────┼─────────────────────────────────────────────────────────────────────┤

      │ nscale         │ How many frequency scales to analyze (more = richer detail)         │

      ├────────────────┼─────────────────────────────────────────────────────────────────────┤

      │ norient        │ How many directions to scan (more = smoother, more isotropic edges) │

      ├────────────────┼─────────────────────────────────────────────────────────────────────┤

      │ min_wavelength │ Smallest feature size to detect (lower = finer edges)               │

      ├────────────────┼─────────────────────────────────────────────────────────────────────┤

      │ k              │ Noise suppression strength (higher = cleaner but less sensitive)    │

      └────────────────┴─────────────────────────────────────────────────────────────────────┘

      The defaults (nscale=4, norient=6, k=2.0) work well for most images right out of the box.

      ---

      Practical Use Cases

      - ControlNet preprocessing — a more stable alternative to Canny for stylized or unevenly lit

      input images

      - Consistent lineart extraction — works reliably across scanned sketches, photos, and renders

      - Medical / scientific images — extracts meaningful structure where contrast is naturally low

      - Artistic workflows — produces clean, smooth edge lines with a unique character compared to

      gradient-based methods

      - Masking and compositing — use the edge map to drive inpainting regions or blend layers

      ---

      Background

      This algorithm was developed by Peter Kovesi in 1999 and published in the Videre: Journal of

      Computer Vision Research. It has been widely used in computer vision research for decades but

       has rarely been available as a plug-and-play node in generative AI workflows — until now.

      ---

      Links

      - GitHub: https://github.com/bemoregt/ComfyUI_PhaseCongruencyEdge

      - Reference: Kovesi, P. (1999). Image Features from Phase Congruency. Videre, 1(3).

      ---

      Give it a try and let me know what workflows you build with it. Feedback and pull requests

      are welcome!

      ---

    Tags: ComfyUI, custom node, edge detection, ControlNet, preprocessing,

      image processing