Matlab Code for Image Smoothing
A=imread('lenna.png');
imshow(A)
%converting A into single channel Image
B=rgb2gray(A);
imshow (B)
% Now Generating Averaging Filter image
h_average=fspecial('average',3);
C_average=imfilter(B,h_average);
%Generating Gaussian filter Image
h_gaussian=fspecial('gaussian',3,0.5);
gaussian=imfilter(B,h_gaussian);
%Generating median filter Image
C_median=medfilt2(B);
% Plotting the images
Subplot(2,2,1)
imshow(B),title('origional image');
Subplot(2,2,2)
imshow(C_average)
title('average filter image');
% Subplot(2,2,3)
% imshow(gaussian)
% title('gaussian filter image');
Subplot(2,3,4)
imshow(C_median)
title('median filter image');
imshow(A)
%converting A into single channel Image
B=rgb2gray(A);
imshow (B)
% Now Generating Averaging Filter image
h_average=fspecial('average',3);
C_average=imfilter(B,h_average);
%Generating Gaussian filter Image
h_gaussian=fspecial('gaussian',3,0.5);
gaussian=imfilter(B,h_gaussian);
%Generating median filter Image
C_median=medfilt2(B);
% Plotting the images
Subplot(2,2,1)
imshow(B),title('origional image');
Subplot(2,2,2)
imshow(C_average)
title('average filter image');
% Subplot(2,2,3)
% imshow(gaussian)
% title('gaussian filter image');
Subplot(2,3,4)
imshow(C_median)
title('median filter image');
Comments
Post a Comment