LayerMask: MaskBoxDetect Node Documentation
Overview
The LayerMask: MaskBoxDetect
node is a powerful utility in the ComfyUI framework for detecting specific box-like regions within a mask. This node can identify various types of rectangular regions on a mask image, which can be used for further image processing tasks. It provides the capability to detect minimal bounding rectangles, maximal inscribed rectangles, or areas determined by the extent of the mask.
Inputs
The LayerMask: MaskBoxDetect
node accepts the following inputs:
1. Mask
- Type: Image (MASK)
- Description: The mask image in which the node will search for box-like regions. The mask should highlight areas of interest that need to be enclosed in a rectangular selection.
2. Detect
- Type: Option
- Options:
- Min Bounding Rect
- Max Inscribed Rect
- Mask Area
- Description: Defines the mode of detection:
- Min Bounding Rect: Detects the smallest rectangle that can completely enclose the mask.
- Max Inscribed Rect: Finds the largest rectangle that can fit inside the mask.
- Mask Area: Utilizes the mask to determine the region of interest based on the mask’s area.
3. X Adjust
- Type: Integer
- Range: -9999 to 9999
- Default: 0
- Description: Adjusts the detected region on the x-axis. Positive values move the box to the right, while negative values move it to the left.
4. Y Adjust
- Type: Integer
- Range: -9999 to 9999
- Default: 0
- Description: Adjusts the detected region on the y-axis. Positive values move the box downward, while negative values move it upward.
5. Scale Adjust
- Type: Float
- Range: 0.01 to 100
- Default: 1.0
- Description: Scales the size of the detected region. Values less than 1.0 shrink the rectangle, while values greater than 1.0 enlarge it.
Outputs
The LayerMask: MaskBoxDetect
node produces the following outputs:
1. Box Preview
- Type: Image
- Description: A preview image that shows the detected box. The box is highlighted on the original mask image with indicators for adjustments and scaling.
2. X Percent
- Type: Float
- Description: The x-coordinate of the box's center as a percentage of the image width.
3. Y Percent
- Type: Float
- Description: The y-coordinate of the box's center as a percentage of the image height.
4. Width
- Type: Integer
- Description: The width of the detected box, adjusted based on the scale factor.
5. Height
- Type: Integer
- Description: The height of the detected box, adjusted based on the scale factor.
6. X
- Type: Integer
- Description: The x-coordinate of the top-left corner of the detected box.
7. Y
- Type: Integer
- Description: The y-coordinate of the top-left corner of the detected box.
Usage in ComfyUI Workflows
In ComfyUI workflows, the LayerMask: MaskBoxDetect
node can be strategically used for advanced image editing tasks. For instance, it can help isolate areas of interest on a mask that require further modification or analysis. This node facilitates tasks such as cropping, resizing, or applying effects specifically within detected regions of an image. It is particularly useful in complex workflows where automatic detection of specific areas can streamline processes and enhance accuracy.
Special Features and Considerations
- Gaussian Blur: The node applies a Gaussian blur to the mask internally to smoothen the feature detection process. This enhances the accuracy of box detection by reducing noise.
- Adjustments and Scaling: The node allows users to make precise adjustments to the position and size of the detected region, providing flexibility for varied applications.
- Multiple Detection Modes: With options to detect minimal bounding boxes, maximal inscribed boxes, or based on mask areas, users have versatile options to fine-tune the selection according to their needs.
- Efficient Logging: The node logs operations internally which can assist in debugging and monitoring the detection process.
This node, LayerMask: MaskBoxDetect
, thus offers a robust solution for detecting and manipulating rectangular regions within mask images, enabling more refined control over image editing tasks within the ComfyUI environment.