I am confused with the Peak signal-to-noise ratio (PSNR) between original image and encrypted image. As i know, the higher PSNR value means the better image quality. I tried to test and calculate the PSNR value. I used LSB technique on the text steganography.
- I tried embed 100 character into an image. It results with 69.9696 dB.
- I tried embed 5 character into an image. It results with 68 dB.
Now, what I think in my mind is:
Should more character embed into image, produce less PSNR value, or less character embed into image, produce high PSNR value?
More character embed, means more manipulation on the pixel. So, PSNR value become lesser?
Anyone can tell me or correct me with my mistake?
------Attached Coding------
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));
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.
That's why I get confused.
---HERE is my PSNR code---
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);
I just call the function of PSNR and print the PSNR value of original image and stego image.
The many character I embed, I get 51.1687256 dB. The one character I embed, I get 51.1578686 dB.
Can tell me why?