ComfyUI Node: Canny Edge

Class Name

CannyEdgePreprocessor

Category
ControlNet Preprocessors/Line Extractors
Author
Fannovel16 (Account age: 3127 days)
Extension
ComfyUI's ControlNet Auxiliary Preproces...
Latest Updated
6/18/2024
Github Stars
1.6K

How to Install ComfyUI's ControlNet Auxiliary Preprocessors

Install this extension via the ComfyUI Manager by searching for  ComfyUI's ControlNet Auxiliary Preprocessors
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI's ControlNet Auxiliary Preprocessors in the search bar
After installation, click the  Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • High-speed GPU machines
  • 200+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 50+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Canny Edge Description

Detect edges in images using Canny edge detection algorithm for AI artists to extract prominent lines with customizable sensitivity.

Canny Edge:

The CannyEdgePreprocessor is a powerful tool designed to detect edges within an image using the Canny edge detection algorithm. This node is particularly useful for AI artists who want to extract prominent lines and edges from their images, which can be used for various artistic effects or as a preprocessing step for further image analysis. The Canny edge detection method is renowned for its ability to detect a wide range of edges in an image while minimizing noise, making it an essential tool for creating clean and precise edge maps. By adjusting the thresholds, you can control the sensitivity of the edge detection, allowing for a high degree of customization based on your specific needs.

Canny Edge Input Parameters:

low_threshold

The low_threshold parameter sets the lower boundary for edge detection. Edges with gradient values below this threshold will be discarded, meaning they will not be considered as edges. This parameter helps in filtering out weak edges that are likely caused by noise. The value ranges from 0 to 255, with a default value of 100. Adjusting this value can help in fine-tuning the sensitivity of the edge detection process.

high_threshold

The high_threshold parameter sets the upper boundary for edge detection. Edges with gradient values above this threshold are considered as strong edges and are definitely included in the edge map. This parameter works in conjunction with the low_threshold to create a hysteresis effect, where edges that fall between the two thresholds are included only if they are connected to strong edges. The value ranges from 0 to 255, with a default value of 200. Modifying this value allows you to control the strictness of the edge detection.

Canny Edge Output Parameters:

IMAGE

The output of the CannyEdgePreprocessor is an IMAGE that contains the detected edges. This image is a binary map where the edges are highlighted, and the rest of the image is set to black. This output can be used directly for artistic purposes or as an input for further image processing tasks. The edge map provides a clear and precise representation of the prominent lines and contours in the original image.

Canny Edge Usage Tips:

  • To achieve a more detailed edge map, lower the low_threshold value to include more edges, but be cautious as this might also include more noise.
  • For cleaner and more prominent edges, increase the high_threshold value to ensure only the strongest edges are detected.
  • Experiment with different threshold values to find the optimal balance between edge detection and noise reduction for your specific image.

Canny Edge Common Errors and Solutions:

ValueError: low_threshold must be less than high_threshold

  • Explanation: This error occurs when the low_threshold value is set higher than or equal to the high_threshold value.
  • Solution: Ensure that the low_threshold value is always less than the high_threshold value to maintain the proper functioning of the edge detection algorithm.

TypeError: image must be a valid image format

  • Explanation: This error indicates that the input provided is not a valid image format that the node can process.
  • Solution: Verify that the input is a valid image file and is correctly formatted before passing it to the node.

RuntimeError: Failed to execute Canny edge detection

  • Explanation: This error suggests that there was an issue during the execution of the Canny edge detection algorithm, possibly due to incompatible input parameters or corrupted image data.
  • Solution: Double-check the input parameters and ensure the image data is not corrupted. If the problem persists, try using different threshold values or a different image.

Canny Edge Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI's ControlNet Auxiliary Preprocessors
RunComfy

© Copyright 2024 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals.