0% found this document useful (0 votes)
5 views9 pages

Spatial Domain Image Filtering Techniques

The document discusses filtering techniques in the spatial domain, including the creation of averaging and sharpening filters. It demonstrates the application of these filters on images, including noise addition and median filtering. The document also covers the use of Sobel filters for edge detection in images.

Uploaded by

ayhamjahgh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views9 pages

Spatial Domain Image Filtering Techniques

The document discusses filtering techniques in the spatial domain, including the creation of averaging and sharpening filters. It demonstrates the application of these filters on images, including noise addition and median filtering. The document also covers the use of Sobel filters for edge detection in images.

Uploaded by

ayhamjahgh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

filtering in spatial domain

s = 5;
h1 = 1/(s*s)*ones(s)

h1 = 11×11
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083
0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083

h2 = [1 2 1;2 4 2;1 2 1]/16

h2 = 3×3
0.0625 0.1250 0.0625
0.1250 0.2500 0.1250
0.0625 0.1250 0.0625

im = imread('[Link]');
figure,imshow(im)

f_im = imfilter(im,h1);
figure,imshow(f_im)

1
figure,imshow(im)

f_im = imfilter(im,h2);
figure,imshow(f_im)

2
add noise to image
n_im =imnoise(im,'salt & pepper',0.05);
figure,imshow(n_im)

m_im = medfilt2(n_im,[3 3]);


figure,imshow(m_im)

3
sharpening filter
h1 = [0 1 0;1 -4 1;0 1 0]

h1 = 3×3
0 1 0
1 -4 1
0 1 0

h2 =-h1

h2 = 3×3
0 -1 0
-1 4 -1
0 -1 0

h3 = [-1 -1 -1;-1 8 -1;-1 -1 -1];


h4 = -h3;
[im] = imread("[Link]");
figure,imshow(im)

4
i_f = imfilter(im,h4);
figure,imshow(i_f)

5
f_img = im-i_f;
figure,imshow(f_img)

6
sopel filter
h1 = [1 2 1;0 0 0;-1 -2 -1]

h1 = 3×3
1 2 1
0 0 0
-1 -2 -1

h2 = h1';
im = imread('[Link]');
h_f = imfilter(im,h1);
figure,imshow(i_f)

7
v_f = imfilter(im,h2);
figure,imshow(i_f)

im = h_f+v_f;
figure,imshow(im)

8
9

You might also like