ComfyUI Node

IW-SSIM

The information-theoretic SSIM nobody wants to compute

By Laurent2916·Created about a year ago·Updated about a year ago· 0
IW-SSIM
  • image_a
  • image_b
  • kernel_size
  • blk_size
  • iw_ssim
data_range1.00
kernel_sigma1.50
k10.01
k20.03
parenttrue
sigma_nsq0.40
reduction

SSIM treats every pixel region as equally important. IW-SSIM (Information-Weighted SSIM) is the 2011 refinement that says: no - regions with more visual information should count for more. It's from the same Wang lab, it's the strongest of the pure SSIM family, and it's also the slowest and most finicky. You reach for it when you need the gold standard traditional metric for a paper, a benchmark, or a really serious A/B test - not when you want a quick sanity check.

It's one of the seventeen nodes in comfyui-piq, Laurent Fainsin's wrapper around the piq library. Same shape as every node in the pack: image_a and image_b in, a single FLOAT out, all under the "piq" category.

How it works. Beyond the usual SSIM machinery, IW-SSIM computes an information-content weight for each local block. Blocks with richer structure carry more of the signal (texture, edges, fine detail) and get weighted up; flat sky and walls get weighted down. It runs this on multiple scales - that's what the parent flag does, whether to include information from parent (coarser) scales, which you want on - using a noise-variance model (sigma_nsq, default 0.4) to estimate how much information survives the "channel." The result is a score in [0, 1], higher better, where the fine details that actually determine perceived quality punch above their pixel count.

Inputs a beginner actually sets:

  • image_a / image_b - candidate vs. reference; image_b is ground truth.
  • data_range - 1.0, because ComfyUI tensors are 0–1 floats.
  • Everything else - kernel_size, kernel_sigma, k1, k2, blk_size, sigma_nsq, parent, reduction - leave at defaults. These are paper-tuned values. blk_size is the block size the information weighting runs over; sigma_nsq is the assumed noise variance in the information model. Tune them only if you know exactly why you're tuning them.

The iw_ssim output is a FLOAT in [0, 1].

Installing. ComfyUI Manager, search "comfyui-piq", Install. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/Laurent2916/comfyui-piq.git
pip install -r custom_nodes/comfyui-piq/requirements.txt

Single dependency (piq>=0.8.0), Python 3.12+. The repo is archived but the math is frozen.

The honest take. IW-SSIM's advantage over plain SSIM is real but modest for day-to-day use, and it's noticeably slower - the information weighting adds a real cost at high resolutions. If you're comparing a handful of upscale candidates and want to be rigorous, sure, run it next to MS-SSIM and take the consensus. If you're iterating a workflow and need a number in under a second, SSIM or GMSD will get you 90% of the signal for 5% of the compute. It's a specialist node, and there's nothing wrong with that.

Categorypiq

Inputs (11)

NameTypeDefaultDescription
image_aIMAGEInput image
image_bIMAGEReference image
data_rangeFLOAT1.00Maximum value range of images
kernel_sizeINTEGER11Size of the Gaussian kernel
kernel_sigmaFLOAT1.50Standard deviation of the Gaussian kernel
k1FLOAT0.01First stability constant
k2FLOAT0.03Second stability constant
parentBOOLEANtrueUse parent weights
blk_sizeINTEGER3Block size for information weighting
sigma_nsqFLOAT0.40Noise variance
reductionCOMBOReduction method

Outputs (1)

NameTypeDescription
iw_ssimFLOATInformation-Weighted Structural Similarity Index