ComfyUI Node
CV Quality Compare Batch (cv2.quality)
Scores EVERY frame of an image batch against one reference (cv2.quality class API). This is the node for a parameter sweep: render N candidates into a batch, get N scores out, and pick the winner with the 'best_index' output. The reference's internal state is computed ONCE and reused for all N frames, which the one-shot 'CV Image Quality (compare)' cannot do. Read the direction: SSIM/PSNR higher is better, MSE/GMSD lower is better - 'higher_is_better' says which, and 'best_index' already accounts for it. All frames must match the reference's size.
CV Quality Compare Batch (cv2.quality)
- reference
- images
- best_score
- best_index
- higher_is_better
- scores
- quality_maps
◄metricSSIM (structural similarity)►
◄max_pixel_value255►
Categoryimage/CV/quality
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| reference | NPARRAY,IMAGE,MASK | The ground-truth / original image (frame 0 if a batch). Its quality state is computed once. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size. | |
| images | NPARRAY,IMAGE,MASK | Batch of processed candidates to score. Every frame must have the reference's size and channel count. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size. | |
| metric | COMBO | SSIM (structural similarity) | SSIM tracks perceived structural change (0-1, 1 = identical). PSNR is a log-scale error in dB (>40 is typically indistinguishable). MSE is the raw squared error. GMSD compares gradient structure and correlates well with perceived sharpness loss. |
| max_pixel_valueopt | FLOAT | 2551–65535 | PSNR only: the maximum per-channel pixel value used as the numerator (255 for 8-bit images). Ignored by the other metrics. |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| best_score | FLOAT | Score of the best frame, averaged over the colour channels. |
| best_index | INT | Index of the best frame in the batch - argmax for SSIM/PSNR, argmin for MSE/GMSD. Feed it to a list picker to select the winning candidate. |
| higher_is_better | BOOLEAN | True for SSIM/PSNR, False for MSE/GMSD. Wire it into a comparison so a workflow can rank without hardcoding the metric's direction. |
| scores | NPARRAY | float32 array of shape (N,) - one score per frame, in batch order. Chart it with 'CV Chart Series'. |
| quality_maps | NPARRAY | Per-pixel quality/error maps, float32 (N,H,W,C) - preview with 'Preview CV Array' (normalize/heatmap) to see WHERE frames differ. GMSD's map is HALF the input's resolution (the metric works on a downsampled gradient map). |