ComfyUI-KJNodes
Run ComfyUI Easily with InstaSD
Skip the complex setup. InstaSD helps creative professionals build workflows and deploy them to the world:
- One-click deployment
- Any model, any node
- Powerful GPUs for rapid iteration
Available Nodes
RemapMaskRange
Remap Mask Range Node Documentation
Overview
The Remap Mask Range node in the ComfyUI KJNodes repository is designed to adjust the range of values in an input mask. This adjustment allows users to redefine the minimum and maximum values that the mask can have, effectively scaling the mask's intensity levels within the specified bounds.
Functionality
What This Node Does
The Remap Mask Range node remaps the intensity values of an input mask to a new specified range. This can be useful for normalizing mask values, enhancing contrast, or preparing masks for subsequent operations that require specific value ranges.
Inputs
The node accepts the following inputs:
- Mask: The input mask whose values need to be remapped. The mask is typically a tensor or array representing intensity values.
- Min: The new minimum value for the mask. This defines the lowest value the mask should have after remapping.
- Max: The new maximum value for the mask. This defines the highest value the mask should have after remapping.
Outputs
The node produces:
- Mask: The output mask with its values remapped to the specified minimum and maximum range.
How It Might Be Used in ComfyUI Workflows
In ComfyUI workflows, the Remap Mask Range node can be used in various scenarios:
-
Normalization: When masks are generated or manipulated, their values might not conform to desired ranges. This node can normalize these masks, ensuring they fit within expected limits, which can be crucial for pipeline consistency.
-
Contrast Adjustment: By remapping the mask's range, users can enhance or reduce contrast, making it easier to distinguish mask features or integrate masks into other processing stages.
-
Preprocessing: Before masks are fed into models or other processing nodes, they might need to be in a specific range for compatibility. This node ensures masks meet these prerequisites.
Special Features or Considerations
-
Clamping: The node ensures that the resulting mask values are clamped between 0.0 and 1.0 after remapping. This is essential for maintaining the integrity of masks if they are used in scenarios where pixel values should remain within this range.
-
Dynamic Range Adjustment: The node calculates the maximum value of the input mask to dynamically scale the mask to the new set range. This adaptive scaling ensures that the highest pixel value of the mask is always scaled to the new maximum specified by the user.
-
Avoiding Division by Zero: There is a built-in mechanism to avoid division by zero in cases where the maximum value in the input mask is zero, which can occur due to masking or processing errors in previous steps.
The Remap Mask Range node thus provides essential functionality for managing mask values within ComfyUI workflows, offering both flexibility and robustness in handling mask intensity ranges.