声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2534|回复: 0

[图像处理] 采用HVS的图像相似度准则计算WPSNR

[复制链接]
发表于 2005-10-15 15:13 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
下面的MATLAB程序计算两幅图像的加权峰值信噪比。相比常用的PSNR而言,考虑到HVS(human visual sytem)的影响。<br><br>function f = WPSNR(A,B,varargin)<br><br>% This function computes WPSNR (weighted peak signal-to-noise ratio) between<br>% two images. The answer is in decibels (dB).<br>%<br>% Using contrast sensitivity function (CSF) to weight spatial frequency<br>% of error image.<br>%<br>% Using:  WPSNR(A,B)<br>%<br>% Written by Ruizhen Liu, http://www.assuredigit.com<br><br> if A == B<br>    error('Images are identical: PSNR has infinite value')<br> end<br><br> max2_A = max(max(A));<br> max2_B = max(max(B));<br> min2_A = min(min(A));<br> min2_B = min(min(B));<br><br> if max2_A &gt; 1 | max2_B &gt; 1 | min2_A &lt; 0 | min2_B &lt; 0<br>    error('input matrices must have values in the interval [0,1]')<br> end<br><br> e = A - B;<br> if nargin&lt;3<br>  fc = csf; % filter coefficients of CSF<br> else<br>  fc = varargin{1};<br> end<br> ew = filter2(fc, e);  % filtering error with CSF<br> <br> decibels = 20*log10(1/(sqrt(mean(mean(ew.^2)))));<br>% disp(sprintf('WPSNR = +%5.2f dB',decibels))<br> f=decibels;<br><br>%=============<br>function fc = csf()<br>%=============<br>% Program to compute CSF<br>% Compute contrast sensitivity function of HVS<br>%<br>% Output: fc --- filter coefficients of CSF<br>%<br>% Reference:<br>% Makoto Miyahara<br>% "Objective Picture Quality Scale (PQS) for Image Coding"<br>% IEEE Trans. on Comm., Vol 46, No.9, 1998.<br>%<br>% Written by Ruizhen Liu, http://www.assuredigit.com<br><br> % compute frequency response matrix<br> Fmat = csfmat;<br><br> % Plot frequency response<br> %mesh(Fmat); pause<br><br> % compute 2-D filter coefficient using FSAMP2<br> fc = fsamp2(Fmat);   <br> %mesh(fc)<br><br><br>%========================<br>function Sa = csffun(u,v)<br>%========================<br>% Contrast Sensitivity Function in spatial frequency<br>% This file compute the spatial frequency weighting of errors<br>%<br>% Reference:<br>% Makoto Miyahara<br>% "Objective Picture Quality Scale (PQS) for Image Coding"<br>% IEEE Trans. on Comm., Vol 46, No.9, 1998.<br>%<br>% Input :   u --- horizontal spatial frequencies<br>%  v --- vertical spatial frequencies<br>%  <br>% Output: frequency response<br>%<br>% Written by Ruizhen Liu, http://www.assuredigit.com<br><br> % Compute Sa -- spatial frequency response<br> %syms S w sigma f u v<br> sigma = 2;<br> f = sqrt(u.*u+v.*v);<br> w = 2*pi*f/60;<br> Sw = 1.5*exp(-sigma^2*w^2/2)-exp(-2*sigma^2*w^2/2);<br><br> % Modification in High frequency<br> sita = atan(v./(u+eps));<br> bita = 8;<br> f0 = 11.13;<br> w0 = 2*pi*f0/60;<br> Ow = ( 1 + exp(bita*(w-w0)) * (cos(2*sita))^4) / (1+exp(bita*(w-w0)));<br><br> % Compute final response<br> Sa = Sw * Ow;<br><br><br>%===================<br>function Fmat = csfmat()<br>%===================<br>% Compute CSF frequency response matrix<br>% Calling function csf.m<br>% frequency range<br>% the rang of frequency seems to be:<br>%   w = pi = (2*pi*f)/60<br>%  f = 60*w / (2*pi), about 21.2<br>%<br> min_f = -20;<br> max_f = 20;<br> step_f = 1;<br> u = min_f:step_f:max_f; <br> v = min_f:step_f:max_f;<br> n = length(u);<br> Z = zeros(n);<br> for i=1:n<br>   for j=1:n<br>     Z(i,j)=csffun(u(i),v(j)); % calling function csffun<br>   end<br> end<br> Fmat = Z;<br>
[此贴子已经被作者于2005-10-15 15:13:53编辑过]

回复
分享到:

使用道具 举报

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-14 10:29 , Processed in 0.059185 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表