Matlab评价图像质量,峰值信噪比,模糊系数的计算

博客已转移至个人网站(http://www.p-chao.com)


计算实例

close all
clear
clc
figure('Number','off');
f = imread('lena.bmp');
subplot(231);imshow(f);title('lena彩色原图');
g = rgb2gray(f);
subplot(234);imshow(g),title('lena灰度原图');
n = imnoise(g,'salt & pepper',0.01);
%n = imnoise(g,'gaussian',0,0.01);
%n = imnoise(g,'poisson');
subplot(232);imshow(n),title('噪声图像');
m1 = medfilt2(n,[5 5]);
subplot(235);imshow(m1),title('5*5中值滤波');
m2 = medfilt2(n,[5 1]);
subplot(233);imshow(m2);title('5*1中值滤波');
m3 = medfilt2(n,[1 5]);
subplot(236);imshow(m3);title('组合滤波器');
[imPSNR(n,g),imPSNR(m1,g),imPSNR(m3,g),imPSNR(g,g);
 imKBlur(n,g),imKBlur(m1,g),imKBlur(m3,g),imKBlur(g,g)]

PSNR峰值信噪比


function [ PSNR ] = imPSNR( J , I )
%imPSNR Summary of this function goes here
%   I is a image with high quality
%   J is a image with noise
%   the function will return the PSNR of the noise image
width = size(I,2);
heigh = size(I,1);
if( width ~= size(J,2) || heigh ~= size(J,1) )
    disp('Please check the input image have the same size');
    return
end
K = (I-J).*(I-J);
PSNR = sum(sum(K,1));
PSNR = PSNR / (width * heigh);
PSNR=10*log10(255*255/PSNR);
end

KBlur模糊系数

function [ KBlur ] = imKBlur( J , I )
w = [-1 1;
     1 -1];
J = imfilter(J,w);
I = imfilter(I,w);
Sin = sum(sum(I,1));
Sout = sum(sum(J,1));
KBlur = Sout/Sin;
end


  • 10
    点赞
  • 73
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值