DIGITAL IMAGE PROCESSING-SMOOTHING: LOW PASS FILTER

Mean Filter:

It is easy to implement median filtering. It is used as a smoothing method for images, reducing the amount of variation in intensity between one pixel and the next, resulting in image noise reduction. The idea of mean filtering is simply to substitute each pixel value in an image, including itself with the mean (‘average value of its neighbors. This has the effect of eliminating the values of pixels that are not representative of their environment. Mean filtering is generally thought of as a convolution filter. It is based around a kernel, like other convolutions, which represents the shape and size of the neighborhood to be sampled when the mean is calculated. A square kernel of 3 x33 x 3 is often used, as shown below:

img = imread('hawk.png');
mf = ones(3,3)/9;
>> mf = ones(3,3)/9
mf =

0.1111 0.1111 0.1111
0.1111 0.1111 0.1111
0.1111 0.1111 0.1111
Y = filter2(h,X)
Y = filter2(h,X,shape)
img = imread('cameraman.tif');
imgd = im2double(img); % imgd in [0,1]
f = ones(3,3)/9;
img1 = filter2(f, imgd);
subplot(121);imshow(img);
subplot(122);imshow(img1);
img = imread('cameraman.tif');
imgd = im2double(img); % imgd in [0,1]
imgd = imnoise(imgd,'salt & pepper',0.02);
f = ones(3,3)/9;
img1 = filter2(f, imgd);
subplot(121);imshow(imgd);
subplot(122);imshow(img1);
I = imread('cameraman.tif');
J = imnoise(I,'salt & pepper',0.02);
K = medfilt2(J);
subplot(121);imshow(J);
subplot(122);imshow(K);
I = imread('hawk.png');
J = imnoise(I,'salt & pepper',0.2);

% filter each channel separately
r = medfilt2(J(:, :, 1), [3 3]);
g = medfilt2(J(:, :, 2), [3 3]);
b = medfilt2(J(:, :, 3), [3 3]);

% reconstruct the image from r,g,b channels
K = cat(3, r, g, b);

figure
subplot(121);imshow(J);
subplot(122);imshow(K);

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vineethvasu

Vineethvasu

2 Followers

I seek new challenges and try to think out-of-the-box while looking for creative solutions to a given problem.