Replace Images In Batch(ReplaceImagesInBatch)
This node takes two image batches (original images and replacement images) as input and performs replacement operations based on user-defined starting indices.
Replace Images In Batch
The Replace Images In Batch node receives two image batches (original images and replacement images) as input and performs a replacement operation based on a user-defined starting index.
The Replace Images In Batch node is used to replace specified portions within a sequence of images in bulk. It allows users to start from a defined position and replace corresponding parts of the original image batch with a new set of images, while also synchronously processing associated mask data.
Node Functionality
This node receives two image batches (original images and replacement images) as input and performs a replacement operation based on a user-defined starting index. Internally, if the dimensions of the replacement images do not match the original images, the node automatically scales them to the original image dimensions using the Lanczos algorithm to ensure batch consistency. The node also supports performing the same replacement operation on corresponding mask batches.
Node Parameter Description - Replace Images In Batch
Connection Inputs (Inputs)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
original_images | IMAGE | No | - | - | : The original image batch, the sequence of images to be partially replaced. |
replacement_images | IMAGE | No | - | - | : The new image batch used for replacement. |
original_masks | MASK | No | - | - | : The mask sequence corresponding to the original image batch. |
replacement_masks | MASK | No | - | - | : The new mask sequence corresponding to the replacement image batch. |
Control Parameters (Parameters)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
start_index | INT | Yes | 1 | 0 - 4096 (Step: 1) | : Specifies the starting index position for the replacement, range 0 to 4096, step 1. |
Output
| Parameter Name | Data Type | Description |
|---|---|---|
| IMAGE | IMAGE | : The final image batch output after the replacement operation. |
| MASK | MASK | : The final mask batch output after the replacement operation. |
Usage Scenarios
In workflows for image inpainting or video frame editing, this node can be used when you need to make local modifications to a middle portion of an image sequence (such as video frames). For example, replacing frames 10 to 20 of an original video with another set of generated or edited images, thereby updating local content without affecting other parts of the sequence.
Notes
When using this node, note that the number of replacement images must match the number of available positions from the starting index to the end of the original batch; otherwise, an index out-of-bounds error will occur. Additionally, the input image and mask batches should maintain dimensional correspondence.
Replace Images In Batch Node Source Code Link
The Replace Images In Batch node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.