图像评价指标用来客观评价图像处理中算法的优劣性,一般在对比实验中突出自己提出的算法的亮点。一般来说,每个细分的领域都有相应的指标,如边缘检测,有PFOM(Pratt’s Figure Of Merit)[1][2](第一个引用是它的来源,第二个引用是使用它的例子);图像增强,有EEME(Evaluating image Enhancement Measure by Entropy)[3][4]。
还有一个比较大的领域–图像复原,包括图像去噪、去模糊、去雾等的评价指标基本上是通用的,都可以用复原后图像与参考图像对比来进行评价,即有参考图像评价指标。相应地提出一系列的指标:(R)MSE, (M)SSIM, PSNR(CSNR)等等,这些指标比较常见。原则上来说,采用越通用的指标,如去噪大家都采用PSNR和SSIM,这样得到的结果也越令人信服。#每种指标都有具体针对的情况,根据评价的目的和情况来设计评价算法。
接下来介绍几种评价指标:
图像的清晰度可以这样得到:对于模糊的图像,其整个图像的灰度较为均匀,相邻像素之间的差值会很小,相乘之后的结果会很小;图像越清晰,那么,边缘跟其周围像素灰度的差值也越大,相乘之后的值也会更大,这样就可以定义一个指标:灰度方差乘积(SMD2),它可以快速准确地来判断一副图像清晰的程度。
double getSMD2(const Mat& test)//SMD2=sum(|test(x,y)-test(x+1,y)|*|test(x,y)-test(x,y+1)|)
{
double temp = 0;
const uchar* ix;
const uchar* ix1;
for (int i = 0; i < test.rows-1; ++i)
{
ix = test.ptr<uchar>(i);
ix1 = test.ptr<uchar>(i + 1);
for (int j = 0; j < test.cols-1; ++j)
{
temp += abs(ix[j] - ix1[j])*abs(ix[j] - ix[j + 1]);
}
}
return temp / (test.rows * test.cols);
}
人类的视觉感知有3个显著的特性,即视觉非线性特性(Weber定律)、视觉敏感度带通和视觉多通道及掩盖效应。利用小波变换与HVS多通道特性相匹配的特点,建立一种和人的视觉评价保持良好一致的方法,其评价结果与主观评价平均评价分数的相关系数达0.95,而对应的客观评价方法与主观评价平均评价分数的相关系数为0.81。利用对比度敏感度函数的带通特性以简化HVS模型,将不同空间频带失真用Minkowski求和进行非线性合并,最后仿照峰值信噪比的定义,得到结果。具体的步骤是:
(1)将待测图像和标准图像选用D9/7小波进行分解,分解为4级;
(2)将4级小波分为5个频带,对不同空间频带乘于对应的CSF系数;
(3)待测图像和标准图像相减得到5个频带的误差E,然后按照下面公式进行求和:
double **fwt97(double** matrix, int width, int height)
{
//9 / 7 Coefficients:
double a1 = -1.586134342;
double a2 = -0.05298011854;
double a3 = 0.8829110762;
double a4 = 0.4435068522;
//Scale coeff:
double k1 = 0.81289306611596146; // 1 / 1.230174104914
double k2 = 0.61508705245700002; // 1.230174104914 / 2
for (int col = 0; col < width; ++col)
{
//Predict 1. y1
for (int row = 1; row < height - 1; row += 2)//奇数列
{
matrix[row][col] += a1 * (matrix[row - 1][col] + matrix[row + 1][col]);
}
matrix[height - 1][col] += 2 * a1 * matrix[height - 2][col];
//Update 1. y0
for (int row = 2; row < height; row += 2)//偶数列
{
matrix[row][col] += a2 * (matrix[row - 1][col] + matrix[row + 1][col]);//这里注意不要越界
}
matrix[0][col] += 2 * a2 * matrix[1][col];
//Predict 2.
for (int row = 1; row < height - 1; row += 2)//奇数列
{
matrix[row][col] += a3 * (matrix[row - 1][col] + matrix[row + 1][col]);
}
matrix[height - 1][col] += 2 * a3 * matrix[height - 2][col];
//Updata 2.
for (int row = 2; row < height; row += 2)//偶数列
{
matrix[row][col] += a4 * (matrix[row - 1][col] + matrix[row + 1][col]);//
}
matrix[0][col] += 2 * a4 * matrix[1][col];
}
double **temp;
createMatrix(temp, Size(width, height));
for (int row = 0; row < height; ++row)
{
for (int col = 0; col < width; ++col)
{
if (row % 2 == 0)
temp[col][row / 2] = k1 * matrix[row][col];
else
temp[col][row / 2 + height / 2] = k2 * matrix[row][col];
}
}
for (int row = 0; row < height; ++row)
{
for (int col = 0; col < width; ++col)
{
matrix[row][col] = temp[row][col];
}
}
releaseMatrix(temp, Size(width, height));
return matrix;
}
Mat fwt97_2d(Mat image, int nlevels)
{
int iWidth = image.rows, iHeight = image.cols;
double **matrix;
createMatrix(matrix, image.size());
//convert mat to 2d matrix
const uchar *ix;
for (int row = 0; row < iHeight; ++row)
{
ix = image.ptr(row);
for (int col = 0; col < iWidth; ++col)
{
matrix[row][col] = double(uchar(ix[col]));
}
}
int width = iWidth, height = iHeight;
//do the wavelet decompose
for (int i = 0; i < nlevels; ++i)
{
matrix = fwt97(matrix, width, height);
matrix = fwt97(matrix, width, height);
width /= 2;
height /= 2;
}
#ifdef SHOW_WAVELET
Mat im1(image.size(), CV_8UC1);
for (int row = 0; row < iHeight; ++row)
{
for (int col = 0; col < iWidth; ++col)
{
if (matrix[row][col] < 0)
im1.at(row, col) = 0;
else if (matrix[row][col] > 255)
im1.at(row, col) = 255;
else
im1.at(row, col) = uchar(matrix[row][col]);
}
}
imshow("97wavelet", im1);
#endif
//multiple the CSF coefficient with different frequence band
double csf[4] = { 2.16, 2.87, 3.16, 2.56 };
for (int i = 0; i < nlevels; ++i)
{
int tHeight = 0, tWidth = 0;
for (int row = tHeight; row < height; ++row)
{
for (int col = tWidth ; col < width; ++col)
{
matrix[row][col] = csf[i] * matrix[row][col];
}
}
tWidth = width;
tHeight = height;
width *= 2;
height *= 2;
}
Mat im(image.size(), CV_64FC1);
for (int row = 0; row < iHeight; ++row)
{
double * dm = im.ptr(row);
for (int col = 0; col < iWidth; ++col)
{
dm[col] = matrix[row][col];
}
}
releaseMatrix(matrix, image.size());
return im;
}
double getHVSNR(const Mat &test, const Mat &reference, int nlevels)//the image size must be 2^n*2^n
{
Mat _test(test.size(), CV_64FC1), _ref(reference.size(), CV_64FC1);
_test = fwt97_2d(test, nlevels);
_ref = fwt97_2d(reference, nlevels);
//Minkovski nonlinear summation
Mat diff(test.size(), CV_64FC1), powImg(test.size(), CV_64FC1);
absdiff(_test, _ref, diff);
pow(diff, 4, powImg);
double temp = 0;
temp = mean(diff).val[0];
temp = pow(temp, 1. / 4);
return 10 * log10(255*255 / (temp+0.000001)); //add a small number avoiding the divider to be zero
}
PFOM是由三种因子的组合来定义的:真实边缘的漏检测,伪边缘的误检测及边缘的定位误差,三种因子按下式组合起来就是Pratt品质因素:
function [F, fac, msc] = pratt(Ea,Ed)
% Function EDPM : Edge detector performance measure function.
% Calculates for a given edge image the false alarm
% count, miss count and figure of merit (F) values.
%
%
% Input(s)... Ea : Actual edge image
% Ed : Detected edge image.
%
% Output(s).. fac: False alarm count
% msc: miss count
% F : Figure of merit
Ea=double(Ea);
Ed=double(Ed);
[N,M]=size(Ea);
if [N,M]~=size(Ed)
error('Actual and detected edge image sizes must be same');
end;
a=0.1; % edge shift penalty constant;
fac=length(find((Ea-Ed)==-1)); % False Alarm Count
msc=length(find((Ea-Ed)==1)); % Miss Count
Na=sum(sum(Ea));Nd=sum(sum(Ed));
c=1/max(Na,Nd);
[ia,ja]=find(Ea==1);
for l=1:Na
Aes(l)=Ed(ia(l),ja(l));
end;
mi=ia(find(Aes==0));
mj=ja(find(Aes==0));
F=c*sum(Aes);
for k=1:length(mi)
n1=0;n2=0;m1=0;m2=0;
while sum(sum(Ed(mi(k)-n1:mi(k)+n2,mj(k)-m1:mj(k)+m2)))<1
if mi(k)-n1>1 n1=n1+1;end;
if mi(k)+n21;end;
if mj(k)-m1>1 m1=m1+1;end;
if mj(k)+m21;end;
end;
di=max([n1 n2 m1 m2]);
F=F+c/(1+a*di^2);
end;
F = F*100;
EEME借用了 Michelson对比度公式[7]:
[1] Pratt W K. Digital Image Processing[M]. Wiley-Interscience, 1978.
[2] Sheng Y, Dementrio L, EasleyR, Hamid K. A Shearlet Approach to Edge Analysis and Detection[J], IEEE Transactions on Image Processing. 2009, 18(5):929-941.
[3] S.S. Agaian, B. Silver, K.A. Panetta, Transform coefficient histogram-based image enhancement algorithms using contrast entropy, IEEE Trans. Image Process. 16 (3) (2007) 741–758.
[4] A. Ghani, N. Isa. Enhancement of low quality underwater image through integrated global and local contrast correction. Elsevier Applied Soft Computing. 37(2015) 332-344.
[5] 李郁峰, 陈念年, 张佳成. 一种快速高灵敏度聚焦评价函数. 计算机应用研究, 2010, 4.
[6] 丁绪星, 朱日宏, 李建欣. 一种基于人眼视觉特性的图像质量评价. 中国图象图形学报, 2004, 2.
[7] Michelson A. Studies in optics[M]. University of Chicago Press, 1927.