ComfyUI > Nodes > Bmad Nodes > AdaptiveThresholding

ComfyUI Node: AdaptiveThresholding

Class Name

AdaptiveThresholding

Category
Bmad/CV/Thresholding
Author
bmad4ever (Account age: 3591days)
Extension
Bmad Nodes
Latest Updated
2024-08-02
Github Stars
0.05K

How to Install Bmad Nodes

Install this extension via the ComfyUI Manager by searching for Bmad Nodes
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter Bmad Nodes 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

AdaptiveThresholding Description

Perform adaptive thresholding on images to convert grayscale images into binary images, enhancing contrast and highlighting important features for image processing tasks.

AdaptiveThresholding:

AdaptiveThresholding is a powerful node designed to perform adaptive thresholding on images, which is a technique used to convert grayscale images into binary images. This method is particularly useful when dealing with images that have varying lighting conditions, as it dynamically determines the threshold for different regions of the image. By doing so, it enhances the contrast and highlights important features, making it easier to process and analyze the image further. AdaptiveThresholding is beneficial for tasks such as edge detection, object recognition, and image segmentation, providing a robust solution for handling complex visual data.

AdaptiveThresholding Input Parameters:

src

This parameter represents the source image that you want to apply adaptive thresholding to. The image should be in a format that can be processed by the node, typically a grayscale image.

max_value

This integer parameter sets the maximum value to be assigned to the pixels that pass the thresholding test. It ranges from 0 to 255, with a default value of 255. Adjusting this value can affect the brightness of the resulting binary image.

adaptive_method

This parameter determines the adaptive thresholding algorithm to be used. The available options are "ADAPTIVE_THRESH_MEAN_C" and "ADAPTIVE_THRESH_GAUSSIAN_C", with the default being "ADAPTIVE_THRESH_GAUSSIAN_C". "ADAPTIVE_THRESH_MEAN_C" calculates the mean of the neighborhood area, while "ADAPTIVE_THRESH_GAUSSIAN_C" uses a weighted sum of the neighborhood values.

threshold_type

This parameter specifies the type of thresholding to be applied. It uses predefined threshold types such as binary or inverse binary. The default value is the first option in the list of threshold types.

block_size

This integer parameter defines the size of the neighborhood area used to calculate the threshold for each pixel. It must be an odd number greater than 1, with a default value of 4. Increasing the block size can help in smoothing out noise but may reduce the detail in the thresholded image.

c

This integer parameter is a constant subtracted from the mean or weighted mean calculated. It helps in fine-tuning the thresholding process. The default value is 2, and it can be adjusted to any integer value, including negative values, to achieve the desired thresholding effect.

AdaptiveThresholding Output Parameters:

IMAGE

The output is a binary image where the pixels are either set to the maximum value or zero based on the adaptive thresholding criteria. This binary image can be used for further image processing tasks such as contour detection, segmentation, or feature extraction.

AdaptiveThresholding Usage Tips:

  • For images with uneven lighting, use "ADAPTIVE_THRESH_GAUSSIAN_C" to achieve better results as it considers the weighted sum of the neighborhood values.
  • Adjust the block_size parameter to control the level of detail in the thresholded image. A larger block size can help reduce noise but may also smooth out important features.
  • Use the c parameter to fine-tune the thresholding. If the resulting image is too bright or too dark, try adjusting this value to achieve a better balance.

AdaptiveThresholding Common Errors and Solutions:

"Block size must be an odd number greater than 1"

  • Explanation: The block_size parameter must be an odd number greater than 1 to properly define the neighborhood area for threshold calculation.
  • Solution: Ensure that the block_size value is set to an odd number greater than 1, such as 3, 5, or 7.

"Invalid adaptive method"

  • Explanation: The adaptive_method parameter must be one of the predefined options: "ADAPTIVE_THRESH_MEAN_C" or "ADAPTIVE_THRESH_GAUSSIAN_C".
  • Solution: Verify that the adaptive_method value is correctly set to either "ADAPTIVE_THRESH_MEAN_C" or "ADAPTIVE_THRESH_GAUSSIAN_C".

"Invalid threshold type"

  • Explanation: The threshold_type parameter must be set to a valid threshold type from the predefined list.
  • Solution: Check that the threshold_type value is correctly chosen from the available options and matches the expected format.

AdaptiveThresholding Related Nodes

Go back to the extension to check out more related nodes.
Bmad Nodes
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.