Matlab Code To find the MSE value

%Let me explain with the same example.
%To the input image Iimg applied the 'Salt & Pepper noise' with the noise ratio of 20% and named as 'Nimg'.
%Now for the 'Nimg' i applied median filter and named as Mimg.
%Now i need to find the 'Mean Square Error' MSE comparison between Mimg and Nimg.


clear all
close all
clc;
Iimg=imread('moon.tif');
[r c]=size(  Iimg );
d=ndims( Iimg );
if d == 3
     Iimg =rgb2gray( Iimg );
end
Iimg=double( Iimg );
Iimg= Iimg /225;
Nimg=imnoise( Iimg ,'salt & pepper',0.2);
Mimg=medfilt2( Nimg ,[5 5]);
clc;
Diff= Nimg - Mimg ;
MSE= sum(sum(Diff.* Diff)) / (r * c);
fprintf('\n\nThe Mse value is:  %d',MSE1);
subplot(1,2,1);imshow( Nimg );title('Noised image');
subplot(1,2,2);imshow( Mimg );title('Denoised image');


RESULT:

The Mse value is:  2.521604e-002

i.e, MSE ~ 0.0252

Contact:
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com
Share:

Total Pageviews

CONTACT US

Prof. Roshan P. Helonde
Mobile: +917276355704
WhatsApp: +917276355704
Email: roshanphelonde@rediffmail.com

Enter Project Title

Popular Projects

All Archive

Contact Form

Name

Email *

Message *