LayerStyle

2167
By chflame
Updated 15 days ago
View on GitHub →See Common Issues →

A set of nodes for ComfyUI that can composite layer and mask to achieve Photoshop like functionality.

Available Nodes

LayerMask: MaskByColor

LayerMask: Mask by Color Node Documentation

Overview

The "LayerMask: Mask by Color" node in ComfyUI is designed to create masks from an image based on a specified color. This node is particularly useful for tasks where you need to isolate elements in an image that match or are similar to a specific color, enabling various image processing operations such as layer styling, compositing, and manipulation.

Inputs

The "LayerMask: Mask by Color" node accepts the following inputs:

  • Image: The target image from which the mask will be generated. This input is of the type IMAGE.

  • Color: The color used for generating the mask, provided as an RGB color. Defaults to white (#FFFFFF).

  • Color in HEX: An optional string input that allows specifying the color in HEX format. If provided, it overrides the Color input. Must be a valid HEX code (e.g., #FFFFFF).

  • Threshold: An integer value determining the sensitivity of the color matching process. The range is from 0 to 100, with 0 being the most strict and 100 the most lenient. The default is set to 50.

  • Fix Gap: An integer that specifies the width of gaps to be filled in the mask. The range is from 0 to 32, with a default of 2.

  • Fix Threshold: A float value between 0.01 and 0.99 that defines the threshold for gap filling in the mask. The default is 0.75.

  • Invert Mask: A boolean value indicating whether the mask should be inverted. Defaults to False, meaning the mask will not be inverted.

  • Mask (Optional): An optional mask input of type MASK, which can be used to further refine the output. If this input is provided, the operation takes it into account during processing.

Outputs

The node produces the following output:

  • Mask: A binary mask that highlights areas in the image matching the specified color. This mask can be used in subsequent image processing operations in a ComfyUI workflow.

Usage in ComfyUI Workflows

The LayerMask: Mask by Color node can be used in a variety of ComfyUI workflows where color-based segmentation is required. It is particularly useful in:

  • Image Compositing: Isolating specific elements based on color allows for applying different styles or effects to those elements without affecting the rest of the image.

  • Graphic Design: Designers can quickly extract elements of a specific color for integration into different compositions or projects.

  • Preprocessing Steps: Facilitating subsequent operations in a pipeline by initially segmenting and isolating parts of an image, leading to targeted processing.

Special Features and Considerations

  • Color Input Flexibility: The node allows for color specification both through RGB and HEX formats, accommodating different user preferences and needs.

  • Threshold Control: The threshold input offers precise control over the strictness of the color-matching operation, providing flexibility in different scenarios.

  • Mask Inversion: The option to invert the produced mask extends the node's versatility, making it adaptable for various use cases.

  • Gap Fixing: Automatic gap filling ensures cleaner masks, which is particularly beneficial for applications requiring precise masking.

When incorporating the "LayerMask: Mask by Color" node in a workflow, consider experimenting with the threshold and fix parameters to achieve desired results, especially in images with complex or similar color palettes.