我对原始图像和加密图像之间的峰值信噪比 (PSNR) 感到困惑。据我所知,PSNR 值越高意味着图像质量越好。我试图测试和计算 PSNR 值。我在文本隐写术上使用了 LSB 技术。
- 我尝试将 100 个字符嵌入到图像中。结果为 69.9696 dB。
- 我尝试将 5 个字符嵌入到图像中。结果为 68 dB。
现在,我的想法是:
应该更多的字符嵌入到图像中,产生更少的 PSNR 值,还是更少的字符嵌入到图像中,产生高的 PSNR 值?
更多的字符嵌入,意味着对像素的更多操作。那么,PSNR 值会变小吗?
任何人都可以告诉我或纠正我的错误吗?
------附加编码------
Str = 'after this, I tried calculate the PSNR value with original image and stego image. 100 character which is read from file is embedded into image, higher PSNR value. 5 character, less PSNR value.';%many character
%Str = 'a'; %one character
Str=uint8(Str); %converting to 8 bit numbers for proper calculation
fprintf('%d ', Str);
fprintf('\n');
stringLength = length(Str);
x=imread('lena.bmp'); %reading the image file
x=uint8(x); %conversion to 8 bit
[x_row,x_col]=size(x);
numPixelsInImage = numel(x);
bitsPerLetter = 7; % For ASCII, this is 7.
numPixelsNeededForString = stringLength * bitsPerLetter;
binaryAsciiString = dec2bin(Str)'
whos binaryAsciiString
binaryAsciiString = binaryAsciiString(:)'
stegoImage = x;
stegoImage(1:numPixelsInImage) = bitset(stegoImage(1:numPixelsInImage), 1, 0);
oneIndexes = find(binaryAsciiString == '1');
stegoImage(oneIndexes) = bitset(stegoImage(oneIndexes), 1, 1);
imwrite(uint8(stegoImage),'stego123.bmp')
fprintf('\nPSNR: %9.7f dB\n\n', psnr(x,stegoImage));
在此之后,我尝试用原始图像和隐秘图像计算 PSNR 值。从文件中读取的 100 个字符嵌入到图像中,PSNR 值更高。5 个字符,少 PSNR 值。
这就是为什么我感到困惑。
---这是我的 PSNR 代码---
function [PSNR,mse]=psnr(X,Y)
% function [PSNR,mse]=psnr(X,Y)
% Peak signal to noise ratio of the difference between images and the
%mean square error
% If the second input Y is missing then the PSNR and MSE of X itself
% becomes the output (as if Y=0).
if nargin<2, 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 值。
我嵌入的许多字符,我得到 51.1687256 dB。我嵌入的一个字符,我得到 51.1578686 dB。
能告诉我为什么吗?