数字图像处理,若干图像质量评价指标的实现

版权声明:本文为EbowTang原创文章,后续可能继续更新本文。如果转载,请务必复制本文末尾的信息! https://blog.csdn.net/EbowTang/article/details/43643037

首先几个最基本的指标:

a)灰度图的均值

即一幅图像所有像素的均值,它表明了该图像是否偏暗或者偏亮,比较小的话就偏暗,较大则亮。

b)灰度图的标准差




首先从图像质量大的分类方法来看,可分为主管评价和客观评价!

其次,客观评价又根据其对参考图像的依赖程度, 可分成三类。
(1)全参考:需要和参考图像上的像素点做一一对应的比较;
(2)半参考:只需要和参考图像上的部分统计特征做比较;
(3)无参考:不需要具体的参考图像。其中全参考算法是研究时间最长、发展最成熟的部分



1,Peak Signal to Noise Ratio(PSNR) 峰值信噪比

全参考评价方式,需要参考图像和待评价图像,是一种相似度评价指标,参考图像是清晰图像的话psnr越大越好。

其中MSE表明了两幅图像的总体差异,越大表明差异也越明显。


function pnsr_result = myPsnr(img_ref,img_den)    
%myPsnr Summary of this function goes here  
%   img_ref is a high quality image 
%   img_den is a noise/denoise image  
%   the function will return the PSNR of the noise/denoise image  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%author:ebowtang
%author blog:http://blog.csdn.net/ebowtang/article/details/43643037
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
width = size(img_ref,2);  
heigh = size(img_ref,1);  
if( width ~= size(img_den,2) || heigh ~= size(img_den,1) )  
    disp('Please check the input image have the same size');  
    return  
end  
[a,b]=size(img_ref);    
XX2=double(img_ref) - double(img_den);    
mse_value2 = sum(sum( XX2.^2 ))/(a*b);    
pnsr_result = 10*log10( 255*255 / mse_value2 ); %get pnsr  

对其进行测试:编写正确!!!





2,Signal to Noise Ratio(SNR) 信噪比

首先值得一提的是,SNR的定义方式有很多种,见参考文献[1-3]。

其中最常见的是a)这种定义方式,这种定义方式实际意义和psnr一样,都是一种相似度评价指标:


a)最常见的定义方式(度量图像相似度)

如果把f(x,y)看做原始图g(x,y)和噪声图像e(x,y)的和,输出图的均方信噪比就是


matlab实现如下:

function result_snr = mySnr(img_ref,img_den)
%mySnr Summary of this function goes here  
%   img_ref is a high quality image 
%   img_den is a noise/denoise image  
%   the function will return the result_snr of the noise/denoise image  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%author:ebowtang
%author blog:http://blog.csdn.net/ebowtang
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
width = size(img_ref,2);  
heigh = size(img_ref,1);  
if( width ~= size(img_den,2) || heigh ~= size(img_den,1) )  
    disp('Please check the input image have the same size');  
    return  
end 
d2=sum(sum( img_ref.^2 ));
M=double(img_ref) - double(img_den);    
d1 = sum(sum( M.^2 )); 
result_snr = 10*log10((d2/d1));

b)其他表达式(度量噪声强度)

通常我们以平均值代表影像图像信号的强度,而将选定背景区域的标准差当成噪声的大小,因为标准差所代表的物理意义为噪声相对该区域平均值的波动情形,这直觉上就像是噪声載在图像信号上一樣,SNR越大,代表图像品质越好。常见的度量噪声强度的SNR的表达式为:

其中I表示图像,max(I)就是求取图像的最大像素,分子则是选定的背景噪声区域的方差(没有根号就是标准差)


其中一种实现为:

function result_snr = mySnr1(img_den,noise_region)
%mySnr1 Summary of this function goes here  
%   img_den is a noise/denoise image  
%   noise_region is the selected regions of interest and of background noise region
%   the function will return the result_snr of the noise/denoise image  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%author:ebowtang
%author blog:http://blog.csdn.net/ebowtang
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
img_den=double(img_den);
noise_region=double(noise_region);
d2=max(max(img_den));%用图像像素的最大值代表信号强度
%d2=mean2(img_den);%用图像像素的平均值代表信号强度
d1=std2(noise_region);d1=d1+0.000001;%估计图像的噪声标准差(可以通过选定图像背景区域得到)
result_snr = 20*log10(d2/d1);%这样的表达形式的计算结果单位是‘db’



3,Contrast Noise Ratio(CNR) 对比度噪声

对比度噪声比,是衡量图像对比度的一个指标。运用他的时候,首先要在待处理图像上选取感兴趣区域(ROI)。见参考蚊香【4】一般情况下,这里全部引用文献4的说法.

CNR= 图像在感兴趣的区域内外的强度差 除以 图像在感兴趣的区域之内外的标准差和,并取绝对值。即內外信号强度初一内外噪声和。可以很直观的想象,CNR的值越大代表內外区域越能被分辨出來,表示影像的对比度越好。




根据完论文的描述,于是我们可以得到代码如下

function result_cnr = myCnr(noise_region,roi1,roi2,roi3,roi4)
%myCnr Summary of this function goes here  
%   img_den is a noise/denoise image  
%   noise_region is the selected regions of interest and of background noise region
%   roi1,roi2,roi3,roi4 are four interest Regions
%   the function will return the result_cnr of the image  
%   tip: this function need five selected regions from the image you want to evaluate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%author:ebowtang
%author blog:http://blog.csdn.net/ebowtang
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
noise_region=double(noise_region);
roi1=double(roi1);
roi2=double(roi2);
roi3=double(roi3);
roi4=double(roi4);

ub=mean2(noise_region);
u1=mean2(roi1);
u2=mean2(roi2);
u3=mean2(roi3);
u4=mean2(roi4);

varb=std2(noise_region);varb=varb*varb;
var1=std2(roi1);var1=var1*var1;
var2=std2(roi2);var2=var2*var2;
var3=std2(roi1);var3=var3*var3;
var4=std2(roi1);var4=var4*var4;

cnr1=10*log((u1-ub)/sqrt(var1+varb));
cnr2=10*log((u2-ub)/sqrt(var2+varb));
cnr3=10*log((u3-ub)/sqrt(var3+varb));
cnr4=10*log((u4-ub)/sqrt(var4+varb));

result_cnr=(cnr1+cnr2+cnr3+cnr4)/4;



4,equivalent numbers of looks(ENL)等效视数

等效视数(ENL),这是一种衡量均匀区域的光滑性的指标(ENL is commonly used to measure the speckle suppression of different SAR/OCT image filters. When the ENL value is bigger, it indicates the image is smoothed well.)。一般我们可以选取几个感兴趣区域求取等效视数然后求平均,或者直接求取图像的等效视数。所以公式可以写成如下:


公式中的分母表示感兴趣区域的均值,分母则是方差

function result_enl = myEnl(img_roi)
%myEnl Summary of this function goes here  
%   img_roi is the selected regions from the your image(or the image )
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%author:ebowtang
%author blog:http://blog.csdn.net/ebowtang
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
img_roi=double(img_roi);
u1=mean2(img_roi);u1=u1*u1;
std1=std2(img_roi);var1=std1*std1;
result_enl=u1/var1;


5,edge preservation index(EPI)边缘保持系数

ENL is commonly used to measure the speckle suppression of different SAR image filters. When the ENL value is bigger, it indicates the image is smoothed well.EPI measures the ability to maintain details of the image。

其表达式可以为,参考论文【5】:




参考代码为:

function result_epi=myEpi(img_before,img_after)
% 计算一副图像的边缘保护指数EPI(Edge Protect Index),EPI越接近1,说明算法的边缘保持能力越强。
% img_before表示原始图像(这里考虑标准图像,其他的话也可以考虑一下去噪前的图像,C实现的时候,考虑到平台需求,用的是去噪前的图像)
% img_after表示去噪后的图像
% 根据《基于多小波域Besov球映射的SAR图像去噪算法》
% 其他出处:《基于改进的小波软阈值法的SAR图像去噪》
img_before=double(img_before);
img_after=double(img_after);
[height,width]=size(img_before);
sum1=0;
sum2=0;
%去噪前
for i=1:height   %水平
    for j=1:width-1
        sum1=sum1+abs(img_before(i,j)-img_before(i,j+1));
    end
end
for i=1:height-1  %垂直
    for j=1:width
        sum1=sum1+abs(img_before(i,j)-img_before(i+1,j));
    end
end
%去噪后
for i=1:height  %水平
    for j=1:width-1
        sum2=sum2+abs(img_after(i,j)-img_after(i,j+1));
    end
end
for i=1:height-1  %垂直
    for j=1:width
        sum2=sum2+abs(img_after(i,j)-img_after(i+1,j));
    end
end
sum1=double(sum1);
sum2=double(sum2);
result_epi=sum2/sum1;




参考资源:

【1】comparaison of snr image quality metrics for remote sensing systems[J]. Optical Engineering, 2001, 40(4):574-585 

【2】点目标图像信噪比计算方法,王学伟, 王春歆, 张玉叶(海军航空工程学院控制工程系,山东烟台264001)

【3】一种遥感图像信噪比评估和度量准则,傅鹏,孙权森,纪则轩,陈强,南京理工大学计算机科学与工程学院,江苏南京210094

【4】眼底OCT图像降噪及边缘检测算法研究,刘涛;清华大学, 信息与通信工程, 2010, 硕士

【5】基于改进的小波软阈值法的SAR 图像去噪,张微, 孙蓉桦, 章孝灿,(浙江大学空间信息技术研究所, 浙江杭州310027


注:本博文为EbowTang原创,后续可能继续更新本文。如果转载,请务必复制本条信息!

原文地址:http://blog.csdn.net/ebowtang/article/details/43643037

原作者博客:http://blog.csdn.net/ebowtang

猜你喜欢

转载自blog.csdn.net/EbowTang/article/details/43643037
今日推荐