Visit ComfyUI Online for ready-to-use ComfyUI environment
Generate contrast mask from image for precise AI image manipulation with depth mask support and background replacement ease.
The image2contrastMask_node
is designed to create a contrast mask from a given image, making it a single-step process to generate a mask that can be used for various purposes such as background replacement. This node is particularly useful when working with images that have a good depth mask applied, such as those generated by MiDaS, or images with a high contrast background. By converting the image to grayscale, applying optional Gaussian blur, and filtering based on specified threshold values, this node produces a contrast mask that highlights areas of interest while suppressing less relevant regions. This functionality is essential for AI artists looking to manipulate images with precision and ease.
The image
parameter is the input image that you want to process. This image should be in a format compatible with the node, typically a tensor representing the image data. The image is converted to grayscale and processed to generate the contrast mask.
The low_threshold
parameter sets the lower bound for pixel intensity. Pixels with intensity values below this threshold will be set to 0 (black) in the resulting mask. This helps in suppressing the less relevant regions of the image. The value should be between 0 and 255, with a default value that can be adjusted based on the specific needs of the image.
The high_threshold
parameter sets the upper bound for pixel intensity. Pixels with intensity values above this threshold will be set to 255 (white) in the resulting mask. This helps in highlighting the areas of interest in the image. The value should be between 0 and 255, with a default value that can be adjusted based on the specific needs of the image.
The blur_radius
parameter determines the radius of the Gaussian blur applied to the image before thresholding. A higher blur radius can help in smoothing out noise and creating a more uniform mask. The value should be greater than 1 to apply the blur, with a default value that can be adjusted based on the specific needs of the image.
The image
output is the processed grayscale image after applying the thresholds and optional blur. This image is a tensor that represents the intensity values of the original image, adjusted based on the specified thresholds.
The mask
output is the contrast mask generated from the input image. This mask is a tensor where the pixel values are either 0 or 1, representing the suppressed and highlighted regions of the image, respectively. This mask can be used for further image manipulation tasks such as background replacement.
low_threshold
and high_threshold
values to fine-tune the areas of the image that you want to highlight or suppress. Experiment with different values to achieve the desired effect.blur_radius
parameter to smooth out noise in the image. A higher blur radius can help in creating a more uniform mask, especially for images with a lot of fine details or noise.low_threshold
or high_threshold
values are outside the acceptable range of 0 to 255. - Solution: Adjust the threshold values to be within the range of 0 to 255.blur_radius
value is less than or equal to 1, which may not apply the desired blur effect.blur_radius
to a value greater than 1 to apply the Gaussian blur effectively.© Copyright 2024 RunComfy. All Rights Reserved.