Color To Mask (UTK):
The ColorToMask_UTK node is designed to convert specific colors within an image into a mask, based on a defined RGB color and a threshold for color similarity. This node is particularly useful for isolating areas of an image that match a specific color, allowing you to create masks that highlight or exclude these areas. By calculating the Euclidean distance between each pixel's color and the target RGB color, the node determines which pixels fall within the specified threshold distance. These pixels are included in the mask, appearing as white, while those outside the threshold are excluded and appear as black. This functionality is beneficial for tasks such as chroma keying or color-based segmentation in image processing workflows.
Color To Mask (UTK) Input Parameters:
images
This parameter accepts the input images that you want to convert into masks. The images are analyzed to identify pixels that match the specified color criteria.
red
This integer parameter specifies the red component of the target color you wish to match in the image. It ranges from 0 to 255, with a default value of 0. Adjusting this value changes the red intensity of the target color.
green
This integer parameter specifies the green component of the target color. It also ranges from 0 to 255, with a default value of 0. Modifying this value alters the green intensity of the target color.
blue
This integer parameter specifies the blue component of the target color. Like the other color components, it ranges from 0 to 255, with a default value of 0. Changing this value affects the blue intensity of the target color.
threshold
This integer parameter defines the maximum color distance for a pixel to be included in the mask. It ranges from 0 to 255, with a default value of 10. A lower threshold results in a stricter color match, while a higher threshold allows for more variation in color similarity.
invert
This boolean parameter determines whether to invert the mask. By default, it is set to False. When enabled, the mask will exclude pixels that match the target color, effectively inverting the mask's inclusion criteria.
Color To Mask (UTK) Output Parameters:
mask
The output parameter is a mask that highlights the areas of the input image that match the specified color criteria. Pixels within the threshold distance of the target color are included in the mask and appear as white, while those outside the threshold are excluded and appear as black. This mask can be used for further image processing tasks, such as isolating specific regions or applying effects selectively.
Color To Mask (UTK) Usage Tips:
- To achieve precise color matching, start with a lower threshold value and gradually increase it until the desired areas are included in the mask.
- Use the invert option to exclude specific colors from the mask, which can be useful for removing unwanted backgrounds or elements from an image.
- Experiment with different RGB values to isolate various colors in an image, especially when working with complex scenes or multiple objects.
Color To Mask (UTK) Common Errors and Solutions:
Mask is None
- Explanation: This error occurs when the input image is not properly loaded or processed, resulting in a null mask.
- Solution: Ensure that the input image is correctly formatted and accessible. Check for any issues with the image file or path.
Failed to convert mask to PIL
- Explanation: This error indicates a failure in converting the mask to a PIL image format, possibly due to incompatible image data.
- Solution: Verify that the input image is in a supported format and that the image processing libraries are correctly installed and configured.
Mask size exceeds limit
- Explanation: This error occurs when the mask's dimensions exceed the maximum allowed size, which can lead to performance issues.
- Solution: Consider resizing the input image or adjusting the processing parameters to reduce the mask size.
