ComfyUI > Nodes > MTB Nodes > Bbox From Mask (mtb)

ComfyUI Node: Bbox From Mask (mtb)

Class Name

Bbox From Mask (mtb)

Category
mtb/crop
Author
melMass (Account age: 3754days)
Extension
MTB Nodes
Latest Updated
2024-07-02
Github Stars
0.35K

How to Install MTB Nodes

Install this extension via the ComfyUI Manager by searching for MTB Nodes
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter MTB 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

Bbox From Mask (mtb) Description

Extract precise bounding box from binary image masks for AI artists to isolate regions efficiently.

Bbox From Mask (mtb):

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.

Bbox From Mask (mtb) Input Parameters:

mask

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.

invert

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.

image

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.

Bbox From Mask (mtb) Output Parameters:

bbox

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.

image (optional)

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.

Bbox From Mask (mtb) Usage Tips:

  • Ensure that the mask accurately represents the region of interest with non-zero values to get a precise bounding box.
  • Use the invert parameter if your mask represents the background instead of the foreground.
  • Provide an image if you want to obtain a cropped version of the image along with the bounding box.

Bbox From Mask (mtb) Common Errors and Solutions:

Batch count mismatch for mask and image

  • Explanation: This error occurs when the number of masks does not match the number of images. The mask batch size should either be 1 (for a single mask applied to all images) or equal to the number of images.
  • Solution: Ensure that the mask batch size is either 1 or matches the number of images provided.

Mask is empty

  • Explanation: This error occurs when the mask does not contain any non-zero values, making it impossible to extract a bounding box.
  • Solution: Check the mask to ensure it contains non-zero values in the region of interest. Adjust the mask if necessary.

BBox too big, constrained to <new_bbox>

  • Explanation: This warning indicates that the extracted bounding box exceeds the target size and has been constrained to fit within the target dimensions.
  • Solution: Verify the target size and adjust the mask or target dimensions to ensure the bounding box fits within the desired area.

Bbox From Mask (mtb) Related Nodes

Go back to the extension to check out more related nodes.
MTB 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.