Image Batch Filter(ImageBatchFilter)
This node takes an image batch as input and allows the user to define a color value representing 'empty' (such as pure black) and a tolerance threshold.
Image Batch Filter
The Image Batch Filter node receives an image batch as input and allows the user to define a color value representing "empty" (such as pure black) and a tolerance threshold.
Image Batch Filter is a filtering node for image batch processing. Its core function is to automatically identify and remove "empty" images from the batch. It determines whether an image is empty by comparing it to a specified color, thereby helping users clean up invalid image data and improve the efficiency of subsequent processing workflows.
Node Function
This node receives an image batch as input and allows the user to define a color value representing "empty" (such as pure black) and a tolerance threshold. Internally, it calculates the average difference between each image in the batch and the specified color. If the difference is below the threshold, the image is considered empty. Users can choose to directly remove these empty images or fill their positions with another replacement image to maintain the original batch size.
Node Parameter Description - Image Batch Filter
Connection Inputs (Inputs)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
images | IMAGE | Yes | - | - | images (output parameter): The filtered or replaced image batch. |
replacement_image | IMAGE | No | - | - | replacement_image (input parameter): An optional parameter, an image used to replace those judged as empty. If not provided, empty images are directly removed. |
Control Parameters (Parameters)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
empty_color | STRING | Yes | 0, 0, 0 | - | empty_color (input parameter): Defines the color considered as "empty", formatted as an "R, G, B" string, e.g., "0, 0, 0" represents pure black. |
empty_threshold | FLOAT | Yes | 0.01 | 0.0 - 1.0 (Step: 0.01) | empty_threshold (input parameter): The tolerance threshold for judging whether an image is empty, ranging from 0.0 to 1.0 with a step of 0.01. A smaller value indicates stricter judgment. |
Output
| Parameter Name | Data Type | Description |
|---|---|---|
| images | IMAGE | images (output parameter): The filtered or replaced image batch. |
| removed_indices | STRING | removed_indices (output parameter): Outputs the indices of the removed or replaced images in the original batch as a string. |
Usage Scenarios
In image generation workflows, if upstream nodes (such as batch generation or image loading) may produce a large number of solid-color or invalid placeholder images, this node can be used for automatic filtering. For example, when combining multiple LoRA models for batch style testing, use this node to filter out failed solid-color generations, passing only valid images to subsequent upscaling or composition nodes to ensure a smooth workflow.
Notes
This node requires that the replacement image (if provided) has the same number of channels as the input images; otherwise, automatic scaling will be performed, which may affect image quality. Additionally, the judgment of empty color is based on pixel averages, which may not be precise enough for "near-empty" images containing subtle noise or textures. Adjust the threshold according to the actual situation.
Image Batch Filter Node Source Code Link
The Image Batch Filter node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.