文章目录

  • 一、结构相似性
  • 二、定义
  • 三、应用
  • 四、SSIM源码

一、结构相似性

SSIM 是一种基于感知的模型,它将图像退化视为结构信息的感知变化,同时还结合了重要的感知现象,如亮度掩蔽和对比度掩蔽。
与 MSE 或 PSNR 等其他技术的不同之处在于,这些方法估计绝对误差。
结构信息是指像素具有很强的相互依赖性,尤其是当它们在空间上接近时。 这些依赖项携带有关视觉场景中对象结构的重要信息。


二、定义

SSIM值是通过不同的图像窗口计算的

u_x:x的平均值;
u_y:y的平均值;
o_x^2:x的方差;
o_y^2:y的方差;
o_xy:x和y的协方差;
c1=(k1L)^2;
c2=(k2
L)^2;
L:像素值的动态范围;
默认值:k1=0.01、k2=0.03。


三、应用

图像压缩:SSIM
图像修复:Stat-SSIM
模式识别:CW-SSIM


四、SSIM源码

function [mssim, ssim_map] = ssim(img1, img2, K, window, L)% ========================================================================
% SSIM Index with automatic downsampling, Version 1.0
% Copyright(c) 2009 Zhou Wang
% All Rights Reserved.
%
% ----------------------------------------------------------------------
% Permission to use, copy, or modify this software and its documentation
% for educational and research purposes only and without fee is hereby
% granted, provided that this copyright notice and the original authors'
% names appear on all copies and supporting documentation. This program
% shall not be used, rewritten, or adapted as the basis of a commercial
% software or hardware product without first obtaining permission of the
% authors. The authors make no representations about the suitability of
% this software for any purpose. It is provided "as is" without express
% or implied warranty.
%----------------------------------------------------------------------
%
% This is an implementation of the algorithm for calculating the
% Structural SIMilarity (SSIM) index between two images
%
% Please refer to the following paper and the website with suggested usage
%
% Z. Wang, A. C. Bovik, H. R. Sheikh, and E. P. Simoncelli, "Image
% quality assessment: From error visibility to structural similarity,"
% IEEE Transactios on Image Processing, vol. 13, no. 4, pp. 600-612,
% Apr. 2004.
%
% http://www.ece.uwaterloo.ca/~z70wang/research/ssim/
%
% Note: This program is different from ssim_index.m, where no automatic
% downsampling is performed. (downsampling was done in the above paper
% and was described as suggested usage in the above website.)
%
% Kindly report any suggestions or corrections to zhouwang@ieee.org
%
%----------------------------------------------------------------------
%
%Input : (1) img1: the first image being compared
%        (2) img2: the second image being compared
%        (3) K: constants in the SSIM index formula (see the above
%            reference). defualt value: K = [0.01 0.03]
%        (4) window: local window for statistics (see the above
%            reference). default widnow is Gaussian given by
%            window = fspecial('gaussian', 11, 1.5);
%        (5) L: dynamic range of the images. default: L = 255
%
%Output: (1) mssim: the mean SSIM index value between 2 images.
%            If one of the images being compared is regarded as
%            perfect quality, then mssim can be considered as the
%            quality measure of the other image.
%            If img1 = img2, then mssim = 1.
%        (2) ssim_map: the SSIM index map of the test image. The map
%            has a smaller size than the input images. The actual size
%            depends on the window size and the downsampling factor.
%
%Basic Usage:
%   Given 2 test images img1 and img2, whose dynamic range is 0-255
%
%   [mssim, ssim_map] = ssim(img1, img2);
%
%Advanced Usage:
%   User defined parameters. For example
%
%   K = [0.05 0.05];
%   window = ones(8);
%   L = 100;
%   [mssim, ssim_map] = ssim(img1, img2, K, window, L);
%
%Visualize the results:
%
%   mssim                        %Gives the mssim value
%   imshow(max(0, ssim_map).^4)  %Shows the SSIM index map
%========================================================================if (nargin < 2 || nargin > 5)mssim = -Inf;ssim_map = -Inf;return;
endif (size(img1) ~= size(img2))mssim = -Inf;ssim_map = -Inf;return;
end[M N] = size(img1);if (nargin == 2)if ((M < 11) || (N < 11))mssim = -Inf;ssim_map = -Inf;returnendwindow = fspecial('gaussian', 11, 1.5);  %K(1) = 0.01;                  % default settingsK(2) = 0.03;                 %L = 255;                                     %
endif (nargin == 3)if ((M < 11) || (N < 11))mssim = -Inf;ssim_map = -Inf;returnendwindow = fspecial('gaussian', 11, 1.5);L = 255;if (length(K) == 2)if (K(1) < 0 || K(2) < 0)mssim = -Inf;ssim_map = -Inf;return;endelsemssim = -Inf;ssim_map = -Inf;return;end
endif (nargin == 4)[H W] = size(window);if ((H*W) < 4 || (H > M) || (W > N))mssim = -Inf;ssim_map = -Inf;returnendL = 255;if (length(K) == 2)if (K(1) < 0 || K(2) < 0)mssim = -Inf;ssim_map = -Inf;return;endelsemssim = -Inf;ssim_map = -Inf;return;end
endif (nargin == 5)[H W] = size(window);if ((H*W) < 4 || (H > M) || (W > N))mssim = -Inf;ssim_map = -Inf;returnendif (length(K) == 2)if (K(1) < 0 || K(2) < 0)mssim = -Inf;ssim_map = -Inf;return;endelsemssim = -Inf;ssim_map = -Inf;return;end
endimg1 = double(img1);
img2 = double(img2);% automatic downsampling
f = max(1,round(min(M,N)/256));
%downsampling by f
%use a simple low-pass filter
if(f>1)lpf = ones(f,f);lpf = lpf/sum(lpf(:));img1 = imfilter(img1,lpf,'symmetric','same');img2 = imfilter(img2,lpf,'symmetric','same');img1 = img1(1:f:end,1:f:end);img2 = img2(1:f:end,1:f:end);
endC1 = (K(1)*L)^2;
C2 = (K(2)*L)^2;
window = window/sum(sum(window));mu1   = filter2(window, img1, 'valid');
mu2   = filter2(window, img2, 'valid');
mu1_sq = mu1.*mu1;
mu2_sq = mu2.*mu2;
mu1_mu2 = mu1.*mu2;
sigma1_sq = filter2(window, img1.*img1, 'valid') - mu1_sq;
sigma2_sq = filter2(window, img2.*img2, 'valid') - mu2_sq;
sigma12 = filter2(window, img1.*img2, 'valid') - mu1_mu2;if (C1 > 0 && C2 > 0)ssim_map = ((2*mu1_mu2 + C1).*(2*sigma12 + C2))./((mu1_sq + mu2_sq + C1).*(sigma1_sq + sigma2_sq + C2));
elsenumerator1 = 2*mu1_mu2 + C1;numerator2 = 2*sigma12 + C2;denominator1 = mu1_sq + mu2_sq + C1;denominator2 = sigma1_sq + sigma2_sq + C2;ssim_map = ones(size(mu1));index = (denominator1.*denominator2 > 0);ssim_map(index) = (numerator1(index).*numerator2(index))./(denominator1(index).*denominator2(index));index = (denominator1 ~= 0) & (denominator2 == 0);ssim_map(index) = numerator1(index)./denominator1(index);
endmssim = mean2(ssim_map);return

参考文献
Image_quality_assessment_from_error_visibility_to_structural_similarity

质量评估指标:SSIM(Structural similarity 结构相似性)相关推荐

  1. SSIM(structural similarity index),结构相似性

    ssim算法原理 - 我们都不是神的孩子 - CSDN博客 http://blog.csdn.net/ecnu18918079120/article/details/60149864 一.结构相似性( ...

  2. 怎么去除图像亮度对图像质量评价的影响_图像质量评估指标 SSIM / PSNR / MSE

    Visibility of Errors 计算图像degrade后的质量,最 direct 的思路即比较degrade后的图像与真实图像(distortion-free)之间的差剖面,即可视误差,通过 ...

  3. 图像增强评价指标学习之——结构相似性SSIM

    SSIM(structural similarity index),结构相似性,是一种衡量两幅图像相似度的指标.该指标首先由德州大学奥斯丁分校的图像和视频工程实验室(Laboratory for Im ...

  4. 图像质量评价方法PSNR+SSIM 评估指标SROCC,PLCC——简记

    笔记类博文 2019-04-01 当时的具体.参考链接 指标 英文全称 中文 SNR signal to noise ratio 信噪比 PSNR peak signal to noise ratio ...

  5. 无参考质量评估在视频增强的进展与应用

    无参考质量评估在许多无法取得参考信息的实际系统中应用广泛且十分重要,本文整理自腾讯音视频实验室的高孟平在LiveVideoStackCon 2019上海大会中的分享,详细介绍了腾讯音视频实验室团队如何 ...

  6. ssim算法计算图片_图像质量评估算法 SSIM(结构相似性)

    SSIM的全称为structural similarity index,即为结构相似性,是一种衡量两幅图像相似度的指标.该指标首先由德州大学奥斯丁分校的图像和视频工程实验室(Laboratory fo ...

  7. 图像质量评价方法PSNR+SSIM评估指标SROCC,PLCC

    图像质量评价方法PSNR+SSIM&&评估指标SROCC,PLCC ssim的计算里面有高斯模糊,为了快速计算,先对每个小块进行计算,然后计算所有块的平均值.可以参考源代码实现,而且代 ...

  8. 图像质量评估指标:MSE,PSNR,SSIM

    文章目录 MSE与PSNR的计算方法 MSE与PSNR的问题 SSIM的理念与计算方法 理念 概念准备 公式理解 基本元素 三原则 亮度.对比度.结构的相似度指标设计 最终公式 程序计算方法 计算公式 ...

  9. 【图像处理】——图像质量评价指标信噪比(PSNR)和结构相似性(SSIM)(含原理和Python代码)

    目录 一.信噪比(PSNR) 1.信噪比的原理与计算公式 2.Python常规代码实现PSNR计算 3.TensorFlow实现PSNR计算 4.skimage实现PSNR计算 5.三种方法计算的结果 ...

  10. 图像质量评估指标:PSNR / SSIM 原理及Python代码

    1. PSNR   PSNR(峰值信噪比,Peak Signal-to-Noise Ratio),用于衡量两张图像之间差异,例如压缩图像与原始图像,评估压缩图像质量:复原图像与ground truth ...

最新文章

  1. 【转载】变量的存储类别
  2. C专家编程--读书笔记十 再论指针
  3. python中字典的value可以为任意对象_Python学习之字典的删改查操作
  4. python树代码_浅析AST抽象语法树及Python代码实现
  5. CI框架 -- URL
  6. Docke--利用 commit 理解构建镜像
  7. 程序员面试金典——9.5字符串排列
  8. 团队第一阶段站立会议05
  9. (转)Flex compc ant 编译
  10. Atitit 编程范式 体系树 目录 1. 编程范型、编程范式或程序设计法(英语:Programming paradigm) 1 2. 编程范式 2 3. 声明式编程体系树 3 3.1. 声明式(对
  11. 股票历史数据-A股所有股票历史数据下载
  12. bzoj2286 消耗战 虚树树形dp
  13. python绘制坐标系_借助Python Turtle,了解计算机绘图的坐标系
  14. 机器学习——多元线性回归模型
  15. Android 屏幕旋转流程分析
  16. from flask._compat import text_type ModuleNotFoundError: No module named ‘flask._compa‘
  17. leetcode 1567 替换所有问号
  18. JAVA---冒泡排序
  19. 基址寻址与变址寻址的个人理解
  20. conflict 冲突

热门文章

  1. [原创]浅析汇编之堆栈平衡
  2. echarts 生成 迁徙图_echarts3 迁徙图 迁入迁出
  3. Linux 加固(centos7)
  4. MatLab数字图像处理实战(赵小川)-sift原理
  5. tracert命令详解
  6. zebra 斑马打印机 打印图片
  7. 易语言服务器中转,让自己的电脑变成服务器,易语言远程文件传输器
  8. 凤凰os 停在android,电脑的安卓系统,凤凰OS:有亮点但还很粗糙的系统
  9. matlab-液压阀仿真
  10. 微信商城小程序怎么弄?怎么做微信商城小程序?