Nodes/comfyui_cv/CV Quality Compare Batch (cv2.quality)
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.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
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)

NameTypeDefaultDescription
referenceNPARRAY,IMAGE,MASKThe 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.
imagesNPARRAY,IMAGE,MASKBatch 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.
metricCOMBOSSIM (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_valueoptFLOAT2551–65535PSNR only: the maximum per-channel pixel value used as the numerator (255 for 8-bit images). Ignored by the other metrics.

Outputs (5)

NameTypeDescription
best_scoreFLOATScore of the best frame, averaged over the colour channels.
best_indexINTIndex 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_betterBOOLEANTrue for SSIM/PSNR, False for MSE/GMSD. Wire it into a comparison so a workflow can rank without hardcoding the metric's direction.
scoresNPARRAYfloat32 array of shape (N,) - one score per frame, in batch order. Chart it with 'CV Chart Series'.
quality_mapsNPARRAYPer-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).