how can i calculate MSE and PSNR of RGB color image

i embeded a watermark in RGB color image now i want to calculate PSNR and MSE of original and watermarked images . how can i find PSNR and MSE of original and watermarked images

2 Comments

How to compute three PSNR Values , one for each channel?
how to compute mean and variance for each channel?

Sign in to comment.

 Accepted Answer

clc;
[filename1,pathname]=uigetfile('*.*','Select the original image');
image1=imread(num2str(filename1));
[filename2,pathname]=uigetfile('*.*','Select the watermarked image');
image2=imread(num2str(filename2));
figure(1);
imshow(image1); title('Original image');
figure(2);
imshow(image2); title('Watermarked image');
[row,col] = size(image1)
size_host = row*col;
o_double = double(image1);
w_double = double(image2);
s=0;
for j = 1:size_host; % the size of the original image
s = s+(w_double(j) - o_double(j))^2 ;
end
mes=s/size_host;
psnr =10*log10((255)^2/mes);
display 'Value of',psnr

12 Comments

While using above mentioned program..i am getting this error command.. Error: File: Untitled.m Line:4 column: 11 Unexpected MATLAB operator.
What does this mean??
Looks okay to me. You might try my attached demo instead and see if that works.
why I only got the result of PSNR is one value? why does it not give 3 value? the format of both images is RGB, right? and how to show the value of MSE?
I don't know what code you ran. Make sure you're running it only one color channel at a time and do it for each color channel if you want 3 PSNR's out.
I want to ask, actually if both images is RGB, then the MSE value consist of 3, MSE for Red, Green, and Blue. And how about the PSNR of the RGB image? The correct way, Is the PSNR produce three value of color channel or just one value used the average of MSE? Please explain.
They're both 3 values - one for each color channel. You can average them together, if you want, to produce one number. Whatever meets your needs.
Is it possible if the result of PSNR is negative? Because I obtained the value of PSNR is negative. If the MSE result is high then the PSNR result is low? am I right? Please explain. thankyou
@ Image Analyst...I observed that the attached PNSR code is for Gray scale images, it this code applicable to Color images ?? also
@Image Analyst... how to compute mean and variance for each channel?
mean(YourSignal,2) %mean over columns
var(YourSignal, [], 2) %variance over columns
If "channel" means color pane in this case, then
mean(YourSignal, [1 2])
var(YourSignal, [], [1 2])

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!