close all;
clear all;
i=input('Enter the image name','s');
f=input('Enter the filter size');
I=imread(i);
imshow(I),title('Orginal image');
I=im2double(I);
[m,n]=size(I);
I=padarray(I,[f-1 f-1]);
[p,q]=size(I);
s=floor(f/2);
H=zeros(p,q);
for i=s+1:1:p-s
for j=s+1:1:q-s
H(i,j)=I(i+1,j)+I(i-1,j)+I(i,j+1)+I(i,j-1)-4*I(i,j);
end;
end;
% C=imcrop(J,[f,f,m-1,n-1]);
C=imcrop(H,[f,f,m-1,n-1]);
figure,imshow(C),title('Laplacian image');
[k l]=size(C);
t=(p-l)/2;
C1=padarray(C,[t t]);
Filtered_img =I+C1;
figure,imshow(Filtered_img),title('filtered image');
%to find the the error in orginal and filtered image
sq=(Filtered_img-I).^2;
s=sum(sum(sq));
%RMSE is root mean square error
RMSE = sqrt( (s)/(m*n) )
%PSNR is peak signal to noise ratio
PSNR=20*log10(double(max(max(I)))/RMSE)
评论0