Visit ComfyUI Online for ready-to-use ComfyUI environment
Extract specific image regions using masks for precise editing, with options for shape, size, and alpha channel control.
The D2 Cut By Mask node is designed to extract specific regions from an image using a mask. This node is particularly useful for isolating parts of an image based on a defined mask, allowing for precise image manipulation and editing. It offers flexibility in how the image is cut, whether following the exact shape of the mask, creating a rectangular cutout, or generating a square thumbnail centered on the mask area. This functionality is beneficial for tasks that require focused image processing, such as creating thumbnails, isolating objects, or preparing images for further compositing. By providing options to adjust the output size and include an alpha channel, the node ensures that the extracted image meets specific requirements, making it a versatile tool in image processing workflows.
This parameter represents the source images from which regions will be extracted. The images should be in a compatible format, typically a batch of images with dimensions [batch, height, width, channels]. The quality and resolution of the input images directly affect the output, as the node will cut based on the provided mask and image dimensions.
The mask parameter defines the area of the image to be extracted. It can be a binary mask where non-zero values indicate the region of interest. The mask should match the dimensions of the input images to ensure compatibility. The mask's shape determines the cutout area, and it can be adjusted to fit the image dimensions using utility functions.
This parameter specifies the shape of the cutout. Options include "mask" for cutting according to the mask's shape, "rectangle" for creating a rectangular cutout based on the mask's bounding box, and "square_thumb" for generating a square thumbnail centered on the mask area. The choice of cut_type affects the final appearance of the extracted region.
This parameter determines the size of the output image. Options include "mask_size" for an output that matches the mask's dimensions, and "image_size" for an output that retains the input image's size with transparency around the cutout. The output_size setting influences how the extracted region is presented and can be tailored to specific needs.
Padding allows for the expansion of the mask area by a specified number of pixels. The default value is 0, meaning no expansion. Increasing the padding can help include additional context around the mask area, which can be useful for certain image processing tasks.
This parameter sets the minimum width for the mask size. The default value is 0, and it can be adjusted up to 10000 pixels. Ensuring a minimum width can be important for maintaining consistency in the output, especially when dealing with varying mask sizes.
Similar to min_width, this parameter sets the minimum height for the mask size. The default value is 0, with a maximum of 10000 pixels. It ensures that the extracted region meets a certain height requirement, which can be crucial for uniformity in image processing.
This boolean parameter determines whether the output image includes an alpha channel. The default is true, meaning the output will have transparency information. Including an alpha channel is essential for compositing tasks where the extracted region needs to be overlaid on other images.
The image output is the region extracted from the input image based on the mask and cut_type. It reflects the specified output_size and may include an alpha channel if output_alpha is true. This output is crucial for further image processing or compositing tasks.
The mask output is the mask used for the extraction, which can be the original mask or adjusted based on the output_size setting. It provides a reference for the extracted region and can be used for additional processing or analysis.
The rect output provides the coordinates and dimensions of the extracted region in the format (x, y, width, height). This information is valuable for understanding the position and size of the cutout within the original image, aiding in precise image manipulation.
RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Playground, enabling artists to harness the latest AI tools to create incredible art.