ComfyUI > Nodes > Masquerade Nodes > Cut By Mask

ComfyUI Node: Cut By Mask

Class Name

Cut By Mask

Category
Masquerade Nodes
Author
BadCafeCode (Account age: 485days)
Extension
Masquerade Nodes
Latest Updated
2024-06-19
Github Stars
0.34K

How to Install Masquerade Nodes

Install this extension via the ComfyUI Manager by searching for Masquerade Nodes
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter Masquerade Nodes in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • High-speed GPU machines
  • 200+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 50+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Cut By Mask Description

Extract specific image regions based on masks, resize output, batch processing, complex editing.

Cut By Mask:

The Cut By Mask node is designed to extract specific regions from an image based on a provided mask. This node is particularly useful for isolating parts of an image that match a certain criteria defined by the mask. By cutting the image to the bounding box of the mask, you can focus on the areas of interest and discard the rest. Additionally, the node offers the flexibility to resize the extracted region to specified dimensions, ensuring that the output fits your desired size. This can be especially beneficial when working with images that need to be processed in a batch or when preparing images for further manipulation. The optional mask mapping feature allows for cutting multiple pieces from a single image, making it a powerful tool for batch processing and complex image editing tasks.

Cut By Mask Input Parameters:

image

This parameter represents the input image from which regions will be extracted. The image should be in a format that the node can process, typically a tensor or an array representing pixel values.

mask

The mask parameter is an image that defines the regions to be extracted from the input image. The mask should have the same dimensions as the input image, with non-zero values indicating the areas of interest.

force_resize_width

This integer parameter specifies the width to which the extracted region should be resized. If set to 0, the width will not be resized. The default value is 0, with a minimum value of 0 and a maximum value defined by VERY_BIG_SIZE.

force_resize_height

This integer parameter specifies the height to which the extracted region should be resized. If set to 0, the height will not be resized. The default value is 0, with a minimum value of 0 and a maximum value defined by VERY_BIG_SIZE.

mask_mapping_optional

This optional parameter allows for the inclusion of a mask mapping, which can be provided from a Separate Mask Components node. This enables the cutting of multiple pieces from a single image in a batch, facilitating more complex image processing workflows.

Cut By Mask Output Parameters:

image

The output is an image that contains the region(s) extracted from the input image based on the provided mask. If resizing parameters are specified, the output image will be resized accordingly. This output is useful for isolating and focusing on specific parts of the original image for further processing or analysis.

Cut By Mask Usage Tips:

  • To ensure accurate extraction, make sure the mask image aligns perfectly with the input image in terms of dimensions and orientation.
  • Utilize the force_resize_width and force_resize_height parameters to standardize the size of the extracted regions, especially when preparing images for a uniform output format.
  • When working with multiple regions in a single image, use the mask_mapping_optional parameter in conjunction with the Separate Mask Components node to efficiently process and extract all desired regions in one go.

Cut By Mask Common Errors and Solutions:

"Mask and image dimensions do not match"

  • Explanation: This error occurs when the dimensions of the mask do not match the dimensions of the input image.
  • Solution: Ensure that the mask image has the same width and height as the input image before using the node.

"Invalid resize dimensions"

  • Explanation: This error is triggered when the force_resize_width or force_resize_height parameters are set to values outside the acceptable range.
  • Solution: Verify that the resize dimensions are within the specified range (0 to VERY_BIG_SIZE) and adjust them accordingly.

"Mask mapping not provided"

  • Explanation: This error occurs when the mask_mapping_optional parameter is expected but not provided.
  • Solution: If you intend to cut multiple regions from a single image, ensure that you provide a valid mask mapping from the Separate Mask Components node. If not needed, you can ignore this parameter.

Cut By Mask Related Nodes

Go back to the extension to check out more related nodes.
Masquerade Nodes
RunComfy

© Copyright 2024 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals.