请问一下 这个MATLAB峰值信噪比程序哪错了 20
1.clearall;d=0;e=0;file_name='lena.bmp';%读取原图像cover_object=double(imread(file_name));...
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 这个也不对哦 展开
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 这个也不对哦 展开
2个回答
Sievers分析仪
2024-12-30 广告
2024-12-30 广告
是的。传统上,对于符合要求的内毒素检测,最终用户必须从标准内毒素库存瓶中构建至少一式两份三点标准曲线;必须有重复的阴性控制;每个样品和PPC必须一式两份。有了Sievers Eclipse内毒素检测仪,这些步骤可以通过使用预嵌入的内毒素标准...
点击进入详情页
本回答由Sievers分析仪提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询