KJNodes/maskinggenerated

Batch Uncrop(BatchUncrop)

This node takes the original image, the cropped image, and the corresponding bounding box (BBOX) data as inputs.

Batch Uncrop

original_images
cropped_images
bboxes
IMAGE
border_blending
0.25
crop_rescale
1.00
border_top
border_bottom
border_left
border_right
KJNodes

The Batch Uncrop node receives the original image, the cropped image, and the corresponding bounding box (BBOX) data as input.

The Batch Uncrop node is a tool for image composition. Its core function is to precisely place cropped images back into specified locations within the original background image. It uses bounding box coordinates for positioning and supports smooth blending at the seam edges to achieve a seamless visual integration effect.

Node Function

This node receives the original image, the cropped image, and the corresponding bounding box (BBOX) data as input. Its internal mechanism is to recomposite the cropped image back into the corresponding area of the original image based on the coordinates defined by the bounding box. It supports scaling adjustments for the repositioned image and handles seam edges with an adjustable blend strength to reduce harsh transitions. All input images must be in batch format, and their quantities must match each other.

Node Parameter Description - Batch Uncrop

Connection Inputs (Inputs)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
original_imagesIMAGEYes--original_images (Input Parameter): The batch of original, complete background images. The cropped images will be fused back into these.
cropped_imagesIMAGEYes--cropped_images (Input Parameter): The batch of cropped images that need to be repositioned back into the original background. The quantity must match the original images.
bboxesBBOXYes--bboxes (Input Parameter): The batch of bounding box coordinates defining the position of the cropped images within the original images, used for precise positioning.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
border_blendingFLOATYes0.250.0 - 1.0 (Step: 0.01)border_blending (Input Parameter): Controls the blending strength at the seam edges. Range 0.0 to 1.0. Higher values result in smoother blending.
crop_rescaleFLOATYes1.00.0 - 10.0 (Step: 0.01)crop_rescale (Input Parameter): The scaling factor applied to the cropped image before fusion. Range 0.0 to 10.0.
border_topBOOLEANYesTrue-border_top (Input Parameter): Boolean value controlling whether to apply blending to the top edge of the repositioned image.
border_bottomBOOLEANYesTrue-border_bottom (Input Parameter): Boolean value controlling whether to apply blending to the bottom edge of the repositioned image.
border_leftBOOLEANYesTrue-border_left (Input Parameter): Boolean value controlling whether to apply blending to the left edge of the repositioned image.
border_rightBOOLEANYesTrue-border_right (Input Parameter): Boolean value controlling whether to apply blending to the right edge of the repositioned image.

Output

Parameter NameData TypeDescription
IMAGEIMAGEIMAGE (Output Parameter): Outputs the final batch of composited images.

Usage Scenario

A typical usage scenario is in a portrait restoration workflow: First, use a detection node to frame the facial area, crop and enlarge it for detail restoration (e.g., removing blemishes, enhancing resolution). Then, use the Batch Uncrop node to seamlessly fuse the restored facial image back into the corresponding position of the original photo, resulting in an overall image with locally enhanced details.

Notes

When using this node, ensure that the quantities of the input original_images and cropped_images batches are strictly consistent. If more bounding boxes (bboxes) are provided than there are images, the node will automatically discard the excess bounding boxes.

The Batch Uncrop node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…