⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wpsnr.m

📁 Function that calculate the PSNR and WSNR of two imagines
💻 M
字号:
function f = WPSNR(A,B,varargin)

% This function computes WPSNR (weighted peak signal-to-noise ratio) between
% two images. The answer is in decibels (dB).
%
% Using contrast sensitivity function (CSF) to weight spatial frequency
% of error image.
%
% Using: 	WPSNR(A,B)
%
% Written by Ruizhen Liu, http://www.assuredigit.com
A=mat2gray(A);
B=mat2gray(B);

	if A == B
   	error('Images are identical: PSNR has infinite value')
	end

	max2_A = max(max(A));
	max2_B = max(max(B));
	min2_A = min(min(A));
	min2_B = min(min(B));

	if max2_A > 1 | max2_B > 1 | min2_A < 0 | min2_B < 0
   	error('input matrices must have values in the interval [0,1]')
	end

	e = A - B;
	if nargin<3
		fc = csf;	% filter coefficients of CSF
	else
		fc = varargin{1};
	end
	ew = filter2(fc, e);		% filtering error with CSF
	
	decibels = 20*log10(1/(sqrt(mean(mean(ew.^2)))));
%	disp(sprintf('WPSNR = +%5.2f dB',decibels))
	f=decibels;


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -