Visit ComfyUI Online for ready-to-use ComfyUI environment
Generate rectangular masks within images for isolating specific regions with adjustable position, size, and origin point.
The Create Rect Mask node is designed to generate a rectangular mask within an image, which can be particularly useful for isolating specific regions for further processing or analysis. This node allows you to define the position and size of the rectangle either in pixels or as a percentage of the image dimensions. Additionally, it offers flexibility in setting the origin point of the rectangle, making it adaptable to various use cases. If an image is provided through the copy_image_size
parameter, the node will automatically adjust the mask size to match the dimensions of the given image, ensuring seamless integration with your existing workflow. This functionality is essential for tasks that require precise control over masked areas, such as image editing, object detection, and region-based filtering.
This parameter determines the unit of measurement for the rectangle's dimensions and position. It can be set to either "percent" or "pixels". When set to "percent", the values for x
, y
, width
, and height
are interpreted as percentages of the image's width and height. When set to "pixels", these values are taken as absolute pixel measurements. This flexibility allows you to choose the most convenient unit for your specific task.
This parameter specifies the reference point for the rectangle's position. It can be set to one of the following options: "topleft", "bottomleft", "topright", or "bottomright". The chosen origin affects how the x
and y
coordinates are interpreted, providing you with control over the rectangle's alignment within the image.
This parameter sets the horizontal position of the rectangle's origin. Its value can range from 0 to a very large size, with a default of 0. The interpretation of this value depends on the mode
parameter, either as a percentage or in pixels.
This parameter sets the vertical position of the rectangle's origin. Its value can range from 0 to a very large size, with a default of 0. Similar to x
, the interpretation of this value depends on the mode
parameter.
This parameter defines the width of the rectangle. Its value can range from 0 to a very large size, with a default of 50. The unit of this value is determined by the mode
parameter, allowing you to specify the width in either pixels or as a percentage of the image width.
This parameter defines the height of the rectangle. Its value can range from 0 to a very large size, with a default of 50. The unit of this value is determined by the mode
parameter, allowing you to specify the height in either pixels or as a percentage of the image height.
This parameter sets the width of the image in pixels. It is used when the copy_image_size
parameter is not provided. The value can range from 64 to a very large size, with a default of 512. This parameter ensures that the mask is created with the correct dimensions.
This parameter sets the height of the image in pixels. It is used when the copy_image_size
parameter is not provided. The value can range from 64 to a very large size, with a default of 512. This parameter ensures that the mask is created with the correct dimensions.
This optional parameter allows you to provide an image whose dimensions will be used for the mask, overriding the image_width
and image_height
parameters. This ensures that the mask fits perfectly within the provided image, simplifying the process of creating masks for existing images.
The output of this node is an image containing the rectangular mask. The mask is represented as a binary image where the masked area is set to 1 and the rest of the image is set to 0. This output can be used in subsequent nodes for various image processing tasks, such as filtering, segmentation, or object detection.
x
, y
, width
, and height
.copy_image_size
parameter to automatically adjust the mask size to match the dimensions of an existing image, ensuring seamless integration with your workflow.mode
parameter must be set to either "percent" or "pixels".mode
parameter is correctly set to one of the allowed values.origin
parameter must be set to one of the following: "topleft", "bottomleft", "topright", or "bottomright".origin
parameter is correctly set to one of the allowed values.x
, y
, width
, and height
must be within the specified range.image_width
and image_height
parameters must be within the specified range.image_width
and image_height
are within the allowed range and adjust them if necessary.copy_image_size
parameter is used, it must be a valid image.copy_image_size
parameter or ensure that it is not used if not needed.© Copyright 2024 RunComfy. All Rights Reserved.