Resize Mask(ResizeMask)
This node technically processes the input mask tensor through the `common_upscale` function, supporting batch processing.
Resize Mask
The Resize Mask node technically processes the input mask tensor through the common_upscale function and supports batch processing.
The Resize Mask node is a tool for adjusting mask dimensions. Its core function is to receive one or more masks (MASK) and scale them to specified width and height. This node provides various scaling methods and options to meet different image processing needs.
Node Functionality
This node technically processes the input mask tensor through the common_upscale function and supports batch processing. It offers multiple upsampling methods, including "nearest-exact", "bilinear", "area", "bicubic", and "lanczos", to accommodate different quality requirements. When the "Keep Proportions" option is enabled, the node automatically calculates the scaling ratio to ensure the original aspect ratio of the mask is not distorted.
Node Parameter Description - Resize Mask
Connection Inputs (Inputs)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
mask | MASK | Yes | - | - | mask (Output Parameter): Outputs the resized mask. |
upscale_method | COMBO | Yes | - | "nearest-exact", "bilinear", "area", "bicubic", "lanczos" | upscale_method (Input Parameter): The method used for upscaling. Options are "nearest-exact", "bilinear", "area", "bicubic", and "lanczos". |
Control Parameters (Parameters)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
crop | COMBO | Yes | disabled | "disabled", "center" | crop (Input Parameter): Selects the cropping mode. Options are "disabled" (no cropping) or "center" (center crop), which only takes effect if the scaled dimensions exceed the target dimensions. |
width | INT | Yes | 512 | 0 - MAX_RESOLUTION (Step: 1) | width (Input Parameter): The target width for the resized mask. |
height | INT | Yes | 512 | 0 - MAX_RESOLUTION (Step: 1) | height (Input Parameter): The target height for the resized mask. |
keep_proportions | BOOLEAN | Yes | False | - | keep_proportions (Input Parameter): Whether to maintain the original aspect ratio of the mask. When enabled, scaling is performed proportionally based on the minimum scaling ratio of width and height. |
Output
| Parameter Name | Data Type | Description |
|---|---|---|
| mask | MASK | mask (Output Parameter): Outputs the resized mask. |
| width | INT | width (Output Parameter): Outputs the actual width value of the processed mask. |
| height | INT | height (Output Parameter): Outputs the actual height value of the processed mask. |
Usage Scenarios
In a typical image inpainting or compositing workflow, this node can be used when the size of the original image's mask does not match the target canvas. For example, before extracting a person from one image and placing them onto a new background, this node can be used to adjust the person's mask to the same resolution as the new background, ensuring edge alignment and compositing accuracy.
Notes
Please note that when width or height is set to 0 and "Keep Proportions" is enabled, the node will use the mask's original dimension as the target value for that axis. Additionally, when the "lanczos" upsampling method is selected, the internal processing mechanism differs slightly from other methods, but the final output result is consistent.
Resize Mask Node Source Code Link
The Resize Mask node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.