For two image signals x and y within a local window, SSIM combines three comparisons: luminance l(x,y) based on the means μx, μy; contrast c(x,y) based on the standard deviations σx, σy; and structure s(x,y) based on the covariance σxy. In compact form: SSIM(x,y) = (2μxμy + C1)(2σxy + C2) / ((μx² + μy² + C1)(σx² + σy² + C2)), where the stabilizing constants C1 = (K1·L)² and C2 = (K2·L)² depend on the dynamic range L (255 for an 8-bit image) and small constants K1 = 0.01 and K2 = 0.03. The window slides across the whole image and the final score is the mean of the local SSIM values (MSSIM).
Traditional error-based metrics (MSE, PSNR) correlate poorly with human-perceived image quality — two images with identical MSE can differ drastically in visual quality. SSIM addresses this by measuring structural similarity instead of absolute pixel-intensity difference.
Component measuring luminance agreement; l(x,y) = (2μxμy + C1) / (μx² + μy² + C1).
Component measuring contrast agreement; c(x,y) = (2σxσy + C2) / (σx² + σy² + C2).
Component measuring structural correlation; s(x,y) = (σxy + C3) / (σxσy + C3), where typically C3 = C2/2.
Window slid pixel by pixel where μ, σ and σxy are computed; aggregating local SSIM yields MSSIM.
Passing the wrong L (e.g. 255 for data normalized to [0,1]) yields wrong C1/C2 constants and invalid scores.
Computing SSIM globally instead of in a sliding window changes results and deviates from the paper definition.
Averaging SSIM over RGB channels without luminance conversion produces results not comparable across implementations.
SSIM does not capture all distortion types (e.g. geometric shifts); a high score does not always mean good perceptual quality.
Wang, Simoncelli and Bovik introduce a multiscale version of SSIM at the Asilomar conference.
Paper defining SSIM in IEEE Transactions on Image Processing.
Wang and Li propose information-content weighting of SSIM, improving correlation with human judgments.
Zhao et al. demonstrate using (MS-)SSIM as a loss function for training image-restoration networks.
Time complexity: O(N). Space complexity: O(N).
Range of pixel values; drives constants C1, C2. Must match the data (e.g. 255 for 8-bit, 1.0 for normalized).
Size of the local window; standard 11×11.
Standard deviation of the Gaussian window weighting.
Small constants preventing division by zero; C1=(K1·L)², C2=(K2·L)².
Weights of luminance, contrast and structure components; default α=β=γ=1.
Computation performed densely over all pixels; no conditional routing.
Per-window statistics and SSIM values are independent, enabling full parallelism (e.g. on GPU).
Simple convolution/statistics operation, efficient on both CPU and GPU.
As a differentiable loss in network training it benefits from GPU acceleration.