A set of nodes for ComfyUI that can composite layer and mask to achieve Photoshop like functionality.
The LayerUtility: Check Mask V2
node is designed for use within the ComfyUI framework to assess the validity of a mask image. This node scrutinizes a mask based on specified criteria, determining if it meets the conditions to be considered a "valid" mask. It offers two methods for evaluating the mask: a simple validity check or a percentage-based evaluation of the white areas in the mask.
This node checks whether a mask (an image used to define areas of interest by marking them in white) is valid based on the provided parameters. If the mask's white area coverage is below a defined percentage, it is deemed invalid.
Mask: The primary input for this node. The mask is an image used to define areas of interest.
Method: The method used to evaluate the mask. It can be either:
White Point: An integer value ranging from 1 to 254. This value sets the threshold for what is considered a "white point" in the mask. Pixels with a brightness above this threshold are considered white and are included in the area percentage check.
Area Percent: A float value representing the percentage threshold. If the calculated white area percentage in the mask is below this threshold, the mask is considered invalid. The percentage can range from 0 to 100.
True
if the mask is valid according to the specified method and parameters, and False
otherwise.Within a ComfyUI workflow, the LayerUtility: Check Mask V2
node can be utilized to verify and filter masks before they are used in further processing or analysis steps. For instance, in workflows dealing with layer blending, art composition, or object detection, ensuring that only valid masks are passed along can help maintain the integrity and quality of the output.
Filtering Inputs: Before applying masks to layers or images, use this node to ensure only sufficiently detailed masks are processed.
Adaptive Workflow Design: The choice of method (simple
vs. detect_percent
) enables flexibility. Users select the most appropriate validation strategy based on their specific use case and data characteristics.
Resizing for Performance: The node automatically resizes masks that exceed 262,144 pixels in area to a standard width of 512 pixels, maintaining aspect ratio for performance considerations without sacrificing too much detail.
Custom Thresholds: With adjustable white_point
and area_percent
, users can finely tune the mask validity criteria to match the requirements of diverse projects, accommodating both highly detailed and more general mask assessments.
Logging Functionality: While not directly visible in output, the node includes logging capabilities to trace decisions when a mask is processed, aiding in debugging and workflow optimization.
This node provides a flexible and robust mechanism to validate mask images in ComfyUI environments, optimizing workflows that rely heavily on mask-based image manipulations.