Visit ComfyUI Online for ready-to-use ComfyUI environment
Extract precise bounding box from binary image masks for AI artists to isolate regions efficiently.
The Bbox From Mask (mtb) node is designed to extract a bounding box from a given mask, which is a binary image indicating the region of interest. This node is particularly useful for AI artists who need to isolate specific areas within an image for further processing or analysis. By identifying the smallest rectangle that can enclose all the non-zero pixels in the mask, the node provides a precise bounding box that can be used to crop the image or perform other operations. This functionality is essential for tasks such as object detection, segmentation, and image editing, where focusing on a particular region is crucial. The node also offers an option to invert the mask, allowing for flexibility in handling different types of masks.
The mask
parameter is a binary image (MASK) that indicates the region of interest. The mask should have non-zero values in the areas you want to include in the bounding box. This parameter is required for the node to function.
The invert
parameter is a boolean (BOOLEAN) that determines whether to invert the mask before extracting the bounding box. If set to True
, the mask will be inverted, meaning the non-zero values will become zero and vice versa. The default value is False
. This option is useful when you need to work with the inverse of the provided mask.
The image
parameter is an optional input (IMAGE) that, if provided, will be cropped according to the extracted bounding box. This allows you to directly obtain the cropped image along with the bounding box. If the image is not provided, only the bounding box will be returned.
The bbox
parameter is the bounding box (BBOX) extracted from the mask. It is represented as a tuple of four integers: (x, y, width, height). This bounding box defines the smallest rectangle that can enclose all the non-zero pixels in the mask, providing a precise region of interest.
The image
parameter is an optional output (IMAGE) that contains the cropped image based on the extracted bounding box. If the input image was provided, this output will give you the image cropped to the bounding box dimensions. If no image was provided, this output will be None
.
invert
parameter if your mask represents the background instead of the foreground.<new_bbox>
© Copyright 2024 RunComfy. All Rights Reserved.