ComfyUI  >  Nodes  >  ComfyUI - Mask Bounding Box >  Mask Bounding Box

ComfyUI Node: Mask Bounding Box

Class Name

Mask Bounding Box

Category
image/processing
Author
mikkel (Account age: 6034 days)
Extension
ComfyUI - Mask Bounding Box
Latest Updated
5/22/2024
Github Stars
0.0K

How to Install ComfyUI - Mask Bounding Box

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

Mask Bounding Box Description

Identifies and extracts mask bounding box for precise image editing and manipulation.

Mask Bounding Box:

The Mask Bounding Box node is designed to identify and extract the bounding box of a mask within an image. This node is particularly useful for AI artists who need to isolate specific regions of an image based on a mask, allowing for more precise editing and manipulation. By computing the bounding box, the node helps in determining the smallest rectangle that can encompass all the non-zero pixels of the mask, which is essential for tasks like cropping, resizing, or focusing on particular areas of an image. The node ensures that the bounding box meets minimum width and height requirements, making it versatile for various applications.

Mask Bounding Box Input Parameters:

mask_bounding_box

This parameter represents the mask from which the bounding box will be computed. The mask is typically a binary or grayscale image where the regions of interest are highlighted with non-zero values. The node will analyze this mask to determine the bounding box.

min_width

This parameter sets the minimum width of the bounding box. If the computed bounding box is narrower than this value, the node will adjust the width to meet this minimum requirement. This ensures that the bounding box is not too small for practical use. The default value is not specified in the context, but it should be set according to the specific needs of your project.

min_height

This parameter sets the minimum height of the bounding box. Similar to min_width, if the computed bounding box is shorter than this value, the node will adjust the height to meet this minimum requirement. This ensures that the bounding box is sufficiently tall for practical use. The default value is not specified in the context, but it should be set according to the specific needs of your project.

image_mapped

This parameter represents the image that corresponds to the mask. The node uses this image to extract the region defined by the bounding box, allowing you to work with both the mask and the corresponding image area.

threshold

This parameter defines the threshold value for determining which pixels in the mask are considered part of the region of interest. Pixels with values above this threshold are included in the bounding box computation. The default value is not specified in the context, but it should be set according to the specific needs of your project.

Mask Bounding Box Output Parameters:

min_x

This output parameter represents the minimum x-coordinate of the bounding box. It indicates the leftmost boundary of the bounding box within the mask.

max_x

This output parameter represents the maximum x-coordinate of the bounding box. It indicates the rightmost boundary of the bounding box within the mask.

min_y

This output parameter represents the minimum y-coordinate of the bounding box. It indicates the topmost boundary of the bounding box within the mask.

max_y

This output parameter represents the maximum y-coordinate of the bounding box. It indicates the bottommost boundary of the bounding box within the mask.

width

This output parameter represents the width of the bounding box. It is calculated as the difference between max_x and min_x.

height

This output parameter represents the height of the bounding box. It is calculated as the difference between max_y and min_y.

raw_bb

This output parameter is the raw bounded mask extracted from the original mask based on the computed bounding box. It allows you to work with the specific region of the mask that is of interest.

raw_img

This output parameter is the raw image region corresponding to the bounding box. It allows you to work with the specific region of the image that is of interest.

Mask Bounding Box Usage Tips:

  • Ensure that the threshold parameter is set appropriately to accurately capture the regions of interest in the mask. A higher threshold may exclude important areas, while a lower threshold may include unwanted regions.
  • Adjust the min_width and min_height parameters to ensure that the bounding box is of a practical size for your specific application. This is particularly useful when working with small or detailed regions in the mask.
  • Use the raw_bb and raw_img outputs to focus your image processing tasks on the specific regions of interest, improving efficiency and precision.

Mask Bounding Box Common Errors and Solutions:

No non-zero positions found in the mask

  • Explanation: This error occurs when the mask does not contain any pixels with values above the specified threshold.
  • Solution: Ensure that the mask and threshold values are set correctly. Verify that the mask contains regions of interest with pixel values above the threshold.

Bounding box dimensions are smaller than the minimum width or height

  • Explanation: This error occurs when the computed bounding box is smaller than the specified minimum width or height.
  • Solution: Adjust the min_width and min_height parameters to appropriate values that match the expected size of the regions of interest in the mask.

Mask Bounding Box Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI - Mask Bounding Box
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.