psnrjava代码 psm代码
求M文件,直接求图像的峰值信噪比(无论灰度和彩色)
close all
创新互联成立与2013年,是专业互联网技术服务公司,拥有项目成都网站制作、网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元习水做网站,已为上家服务,为习水各地企业和个人服务,联系电话:028-86922220
clear all
I=imread('lena.bmp');
J=imnoise(I,'gaussian',0.01,0.005);
A=imread('lena.bmp');
[M,N]=size(A);
B = imread('J.bmp');
a=double(A);
b=double(B);
sum=0;
for i=1:M;
for j=1:N;
sum=sum+(a(i,j)-b(i,j))^2;
end;
end;
mseValue=sum/(M*N);
psnrValue=10*log10(255^2/mseValue);
disp(['输入数据的MSE为:',num2str(mseValue)]);
disp(['输入数据的PSNR为:',num2str(psnrValue)]);
输入数据的MSE为:7915.4387
输入数据的PSNR为:9.1461
以上是MATLAB程序 及其输出结果 M文件可为
function PSNR = PSNR(A,B)
[M,N]=size(A);
x=double(A);
y=double(B);
sum=0;
for i=1:M;
for j=1:N;
sum=sum+(x(i,j)-y(i,j))^2;
end;
end;
mseValue=sum/(M*N);
psnrValue=10*log10(255^2/mseValue);
disp(['输入数据的MSE为:',num2str(mseValue)]);
disp(['输入数据的PSNR为:',num2str(psnrValue)]);
数字音频水印——峰值信噪比PSNR与信噪比SNR的问题。求告之!求代码!
峰值信噪比PSNR
(1)PSNR (Peak signal-to-noise ratio)
常用于图像压缩等领域中,压缩前与压缩后,图像劣化程度的客观评价。
评价结果以dB(对比分贝)为单位来表示。2个图像间,PSNR值越大,趋于无劣化,劣化程度较大时,PSNR值趋于0dB。
不知道你是灰度图像水印还是彩色图像水印,还是音频转成的二维矩阵,我就简单的用灰度水印图像介绍一下;
PSNR的公式是:
、
如上图MSE是原始和编码后图像的之间的均方误差,n表示每个像素的比特数,公式的具体解释和证明去自己找资料吧。
看你代码的形式,应该是matlab
其中n表示的比特数为8比特
function [PSNR, MSE] = psnr(X, Y)
% 计算峰值信噪比PSNR、均方根误差MSE
% 如果输入Y为空,则视为X与其本身来计算PSNR、MSE
if nargin2
D = X;
else
if any(size(X)~=size(Y))
error('The input size is not equal to each other!');
end
D = X-Y;
end
MSE = sum(D(:).*D(:))/prod(size(X));
PSNR = 10*log10(255^2/MSE);
以下个人观点:我做实验的时候不太喜欢用PSNR,实验结果显示,PSNR 的分数无法和人眼看到的视觉品质完全一致,有可能 PSNR 较高者看起来反而比PSNR 较低者差,语音水印的品质也很成问题,不建议用PSNR,除非你的算法和PSNR很合得来,可以作为参考参数。
下班了,待续...
求基于BP神经网络的图像复原代码,着急用,帮帮我
function Solar_SAE
tic;
n = 300;
m=20;
train_x = [];
test_x = [];
for i = 1:n
%filename = strcat(['D:\Program Files\MATLAB\R2012a\work\DeepLearn\Solar_SAE\64_64_3train\' num2str(i,'%03d') '.bmp']);
%filename = strcat(['E:\matlab\work\c0\TrainImage' num2str(i,'%03d') '.bmp']);
filename = strcat(['E:\image restoration\3-(' num2str(i) ')-4.jpg']);
b = imread(filename);
%c = rgb2gray(b);
c=b;
[ImageRow ImageCol] = size(c);
c = reshape(c,[1,ImageRow*ImageCol]);
train_x = [train_x;c];
end
for i = 1:m
%filename = strcat(['D:\Program Files\MATLAB\R2012a\work\DeepLearn\Solar_SAE\64_64_3test\' num2str(i,'%03d') '.bmp']);
%filename = strcat(['E:\matlab\work\c0\TestImage' num2str(i+100,'%03d') '-1.bmp']);
filename = strcat(['E:\image restoration\3-(' num2str(i+100) ').jpg']);
b = imread(filename);
%c = rgb2gray(b);
c=b;
[ImageRow ImageCol] = size(c);
c = reshape(c,[1,ImageRow*ImageCol]);
test_x = [test_x;c];
end
train_x = double(train_x)/255;
test_x = double(test_x)/255;
%train_y = double(train_y);
%test_y = double(test_y);
% Setup and train a stacked denoising autoencoder (SDAE)
rng(0);
%sae = saesetup([4096 500 200 50]);
%sae.ae{1}.activation_function = 'sigm';
%sae.ae{1}.learningRate = 0.5;
%sae.ae{1}.inputZeroMaskedFraction = 0.0;
%sae.ae{2}.activation_function = 'sigm';
%sae.ae{2}.learningRate = 0.5
%%sae.ae{2}.inputZeroMaskedFraction = 0.0;
%sae.ae{3}.activation_function = 'sigm';
%sae.ae{3}.learningRate = 0.5;
%sae.ae{3}.inputZeroMaskedFraction = 0.0;
%sae.ae{4}.activation_function = 'sigm';
%sae.ae{4}.learningRate = 0.5;
%sae.ae{4}.inputZeroMaskedFraction = 0.0;
%opts.numepochs = 10;
%opts.batchsize = 50;
%sae = saetrain(sae, train_x, opts);
%visualize(sae.ae{1}.W{1}(:,2:end)');
% Use the SDAE to initialize a FFNN
nn = nnsetup([4096 1500 500 200 50 200 500 1500 4096]);
nn.activation_function = 'sigm';
nn.learningRate = 0.03;
nn.output = 'linear'; % output unit 'sigm' (=logistic), 'softmax' and 'linear'
%add pretrained weights
%nn.W{1} = sae.ae{1}.W{1};
%nn.W{2} = sae.ae{2}.W{1};
%nn.W{3} = sae.ae{3}.W{1};
%nn.W{4} = sae.ae{3}.W{2};
%nn.W{5} = sae.ae{2}.W{2};
%nn.W{6} = sae.ae{1}.W{2};
%nn.W{7} = sae.ae{2}.W{2};
%nn.W{8} = sae.ae{1}.W{2};
% Train the FFNN
opts.numepochs = 30;
opts.batchsize = 150;
tx = test_x(14,:);
nn1 = nnff(nn,tx,tx);
ty1 = reshape(nn1.a{9},64,64);
nn = nntrain(nn, train_x, train_x, opts);
toc;
tic;
nn2 = nnff(nn,tx,tx);
toc;
tic;
ty2 = reshape(nn2.a{9},64,64);
tx = reshape(tx,64,64);
tz = tx - ty2;
tz = im2bw(tz,0.1);
%imshow(tx);
%figure,imshow(ty2);
%figure,imshow(tz);
ty = cat(2,tx,ty2,tz);
montage(ty);
filename3 = strcat(['E:\image restoration\3.jpg']);
e=imread(filename3);
f= rgb2gray(e);
f=imresize(f,[64,64]);
%imshow(ty2);
f=double (f)/255;
[PSNR, MSE] = psnr(ty2,f)
imwrite(ty2,'E:\image restoration\bptest.jpg','jpg');
toc;
%visualize(ty);
%[er, bad] = nntest(nn, tx, tx);
%assert(er 0.1, 'Too big error');
当前名称:psnrjava代码 psm代码
文章URL:http://scyanting.com/article/dojpooi.html