Visit ComfyUI Online for ready-to-use ComfyUI environment
Node for precise image cropping based on masks, ideal for AI artists and image processing tasks.
The Bounded Image Crop with Mask node is designed to crop images based on a provided mask, allowing for precise extraction of regions of interest within an image. This node is particularly useful for AI artists who need to isolate specific parts of an image for further processing or analysis. By using a mask to define the area to be cropped, this node ensures that only the relevant portions of the image are retained, while unwanted areas are discarded. Additionally, the node allows for customizable padding around the cropped region, providing flexibility in how much surrounding context is included. This functionality is essential for tasks such as object detection, segmentation, and image enhancement, where focusing on specific regions can significantly improve the quality and accuracy of the results.
The image parameter represents the input image that you want to crop. This image should be in a tensor format, and it can be either a single image or a batch of images. The node will process each image individually based on the provided mask.
The mask parameter is a binary mask that defines the region of interest within the image. The mask should have the same spatial dimensions as the input image, with non-zero values indicating the area to be retained. If the number of masks does not match the number of images, the first mask will be used for all images.
The padding_left parameter specifies the amount of padding to be added to the left side of the cropped region. This value is an integer and can be adjusted to include more or less of the surrounding context. The default value is 0, and it can be increased as needed.
The padding_right parameter specifies the amount of padding to be added to the right side of the cropped region. Similar to padding_left, this value is an integer and can be adjusted to control the amount of surrounding context included. The default value is 0.
The padding_top parameter specifies the amount of padding to be added to the top of the cropped region. This value is an integer and can be adjusted to include more or less of the surrounding context. The default value is 0.
The padding_bottom parameter specifies the amount of padding to be added to the bottom of the cropped region. Similar to padding_top, this value is an integer and can be adjusted to control the amount of surrounding context included. The default value is 0.
The cropped_images parameter is the output tensor containing the cropped regions of the input images. Each cropped image corresponds to the region defined by the mask and includes any specified padding. This output is useful for further processing or analysis of the isolated regions.
The all_bounds parameter is a list of bounding boxes for each cropped region. Each bounding box is represented as a list of four integers: [rmin, rmax, cmin, cmax], indicating the row and column indices of the cropped region. This information is valuable for understanding the spatial location of the cropped regions within the original images.
© Copyright 2024 RunComfy. All Rights Reserved.