请问一下 这个MATLAB峰值信噪比程序哪错了

[复制链接]
查看11 | 回复2 | 2010-6-6 14:43:35 | 显示全部楼层 |阅读模式
1.
clear all;
d=0;
e=0;
file_name='lena.bmp';
%读取原图像
cover_object=double(imread(file_name));
Mc=size(cover_object,1);
%原图像行数
Nc=size(cover_object,2);
%原图像列数
file_name='attacked_image1.bmp';
watermarked_image=double(imread(file_name));
%计算信噪比
for i=1:Mc

for j=1:Nc

a(i,j)=cover_object(i,j)^2;

b(i,j)=cover_object(i,j)-watermarked_image(i,j);

d=d+a(i,j);

e=e+b(i,j)^2;

end
end
psrn=10*log10(d/e)
2.
%Name:Chris Shoemaker
%Course: EER-280 - Digital Watermarking
%Project:Calculates the PSNR (Peak Signal to Noise Ratio)
%
of images A and A', both of size MxN
function [A] = psnr(image,image_prime,M,N)

% convert to doubles

image=double(image);

image_prime=double(image_prime);

% avoid divide by zero nastiness

if ((sum(sum((image-image_prime).^2))) == 0)


error('Input vectors must not be identical')

else

psnr_num=M*N*max(max(image_prime.^2));
% calculate numerator

psnr_den=sum(sum((image-image_prime).^2));
% calculate denominator

A=psnr_num/psnr_den;
% calculate PSNR

end
return
3.%Name:Chris Shoemaker
%Course: EER-280 - Digital Watermarking
%Project:Calculates the PSNR (Peak Signal to Noise Ratio)
%
of images A and A', both of size MxN
function [A] = psnr(image,image_prime,M,N)

% convert to doubles

image=double(image);

image_prime=double(image_prime);

% avoid divide by zero nastiness

if ((sum(sum((image-image_prime).^2))) == 0)


error('Input vectors must not be identical')

else

psnr_num=M*N*max(max(image_prime.^2));
% calculate numerator

psnr_den=sum(sum((image-image_prime).^2));
% calculate denominator

A=psnr_num/psnr_den;
% calculate PSNR

end
return
4.
clear all;
d=0;
e=0;
file_name='lena.bmp';
%读取原图像
cover_object=double(imread(file_name));
Mc=size(cover_object,1);
%原图像行数
Nc=size(cover_object,2);
%原图像列数
file_name='attacked_image1.bmp';
watermarked_image=double(imread(file_name));
%计算信噪比
for i=1:Mc

for j=1:Nc

a(i,j)=cover_object(i,j)^2;

b(i,j)=cover_object(i,j)-watermarked_image(i,j);

d=d+a(i,j);

e=e+b(i,j)^2;

end
end
psrn=10*log10(d/e)
这几个峰值信噪比公式对不比如我的原图像123.jpg和生成图像1234jpg放在那里合适,请赐教
回 2楼

|
错误:函数定义是不允许在提示符下或在脚本中。
??? function [A] = psnr('lena04.jpg','lena05.jpg',M,N)

|
Error: Function definitions are not permitted at the prompt or in scripts.
老是这句话 function这个也不对哦

回复

使用道具 举报

千问 | 2010-6-6 14:43:35 | 显示全部楼层
对数字图像的水印技术而言,峰值信噪比说明不了太大的问题,还是要看检出率和人眼主观感知评价的。
回复

使用道具 举报

千问 | 2010-6-6 14:43:35 | 显示全部楼层
2和3不是一样的么??2和3是对的。。image嵌入水印后的image_prime原图
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行