0% found this document useful (0 votes)
53 views

Lecture 04 Introduction To Image Filtering

This document discusses various image filtering techniques in the frequency domain, including low pass, high pass, band pass, and edge detection filters. It explains how to perform discrete Fourier transforms on an image, multiply it with a filtering mask in the frequency domain, and apply an inverse discrete Fourier transform to obtain the output image. Specific filter types like ideal low pass, Gaussian low pass, ideal high pass, and Gaussian high pass are defined. Edge detection techniques using Laplace and Prewitt/Sobel filters are also outlined. Examples are provided to demonstrate ideal low pass filtering.

Uploaded by

Mainul Islam
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

Lecture 04 Introduction To Image Filtering

This document discusses various image filtering techniques in the frequency domain, including low pass, high pass, band pass, and edge detection filters. It explains how to perform discrete Fourier transforms on an image, multiply it with a filtering mask in the frequency domain, and apply an inverse discrete Fourier transform to obtain the output image. Specific filter types like ideal low pass, Gaussian low pass, ideal high pass, and Gaussian high pass are defined. Edge detection techniques using Laplace and Prewitt/Sobel filters are also outlined. Examples are provided to demonstrate ideal low pass filtering.

Uploaded by

Mainul Islam
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Pattern Recognition

Prof. Dr. Rafiqul Islam


Department of CSE
Filtering Process in Frequency Domain

• Perform discrete Fourier transform of the input


image
• Multiply the Fourier domain image with the
Fourier domain filtering mask
• Apply inverse discrete Fourier transform to get
the output image.

06/23/2021 Prof. Dr. Rafiqul Islam 2


Low Pass Filtering
• A
  2-D lowpass filter that passes without
attenuation all frequencies within a circle of
radius from the origin and cuts off all
frequencies outside this circle is called
lowpass filters

• s the distance from the center of the frequency


rectangle.

06/23/2021 Prof. Dr. Rafiqul Islam 3


Gaussian Low Pass Filtering
• Gaussian
  low pass filtering overcomes the
problem of ideal low pass filtering of the form

• s the distance from the center of the frequency


rectangle.

06/23/2021 Prof. Dr. Rafiqul Islam 4


Low Pass Filtering
• Example function im = IdealLowPass(im0,Dc)
% fc is the circular cutoff frequency which is
normalized to [0 1], that is,
50
% the highest radian frequency \pi of digital
signals is mapped to 1.
[r,c] = size(im0);
100

150 hr = (r-1)/2;
200
hc = (c-1)/2;
[x, y] = meshgrid(-hc:hc, -hr:hr);
250

50 100 150 200 250

D = sqrt((x/hc).^2 + (y/hr).^2);
D = sqrt(x.^2 + y.^2);
50
lp = double(D <= Dc);
100

IM = fftshift(fft2(double(im0)));
150
IP = zeros(size(IM));
200
IP = IM .* lp;
im = abs(ifft2(ifftshift(IP)));
250

06/23/2021 50 100 150 200 250 Prof. Dr. Rafiqul Islam 5


High Pass Filtering
• An
  image can be smoothed by attenuating the
high frequency component of the Fourier
transform.
• A high pass filter is obtained from a given low
pass filter using the equation

• is the transfer function of the low pass filter.

06/23/2021 Prof. Dr. Rafiqul Islam 6


High Pass Filtering
•  A 2-D ideal high pass filter is defined as

06/23/2021 Prof. Dr. Rafiqul Islam 7


Gaussian High Pass Filtering
• The
  transfer function of the Gaussian high
pass filter with cuttoff frequency locus at a
distance from the center of the frequency
rectangle is

06/23/2021 Prof. Dr. Rafiqul Islam 8


Band Pass Filtering
• In
  ideal bandpass filters, frequencies within
the given range are passed through without
attenuation and frequencies outside of the
given range are completely removed.
• This behavior makes ideal bandpass filters
very sharp.

06/23/2021 Prof. Dr. Rafiqul Islam 9


Edge Detection
• Edge detection includes a variety of mathematical
methods that aim at identifying points in a 
digital image at which the image brightness changes
sharply or, more formally, has discontinuities.
• The points at which image brightness changes sharply
are typically organized into a set of curved line
segments termed edges. 

06/23/2021 Prof. Dr. Rafiqul Islam 10


Edge Detection
• Generally edges are of three types:
– Horizontal edges
– Vertical Edges
– Diagonal Edges
• Here are some of the masks for edge detection.
– Prewitt Operator
– Sobel Operator
– Laplacian Operator.
– Canny Operator

06/23/2021 Prof. Dr. Rafiqul Islam 11


Edge Detection: Laplace Filtering

• The
  simplest isotropic derivative operator is
the Laplacian, which, for a function (image)
of two variables, is defined as

06/23/2021 Prof. Dr. Rafiqul Islam 12


Edge Detection: Laplace Filtering

•  The derivation of in -direction

• The derivation of in -direction

06/23/2021 Prof. Dr. Rafiqul Islam 13


Edge Detection: Laplace Filtering

• The
  discrete Laplacian of two variables in
direction is

06/23/2021 Prof. Dr. Rafiqul Islam 14


Edge Detection: Laplace Filtering

• The Laplacian mask from the equation can be


derived as
0 1 0 1 1 1

1 -4 1 1 -8 1

0 1 0 1 1 1

0 -1 0 -1 -1 -1

-1 4 -1 -1 8 -1

0 -1 0 -1 -1 -1

06/23/2021 Prof. Dr. Rafiqul Islam 15


Edge Detection: Laplace Filtering
• im = imread('cameraman.tif');
• Example
• [m, n] = size (im);
50

100 • a_ft = fft2(im);
150

• h = [0 -1 0;-1 4 -1; 0 -1 0];


200

• h(m,n) = 0;
250

50 100 150 200 250

• hf = fft2(h);
50

• b_ft = a_ft.*hf;
• b_filt = ifft2((b_ft));
100

150

200 • imagesc(abs(b_filt))
250

06/23/2021 50 100 150 200 250


Prof. Dr. Rafiqul Islam 16
Edge Detection: Prewitt Filtering
•• The
  PREWITT function returns an approximation to the
Prewitt edge enhancement operator for images.

• where (x, y) are the coordinates of each pixel fxy in the Image.

06/23/2021 Prof. Dr. Rafiqul Islam 17


Edge Detection: Prewitt Filtering
This is equivalent to a convolution using the following masks:
• X-direction mask • Y-direction mask

-1 0 1 1 1 1

-1 0 1 0 0 0

-1 0 1 -1 -1 -1

06/23/2021 Prof. Dr. Rafiqul Islam 18


Edge Detection: Sobel Filtering
•• The
  SOBEL function returns an approximation to the Sobel
edge enhancement operator for images,

• where (x, y) are the coordinates of each pixel fxy in the Image.

06/23/2021 Prof. Dr. Rafiqul Islam 19


Edge Detection: Sobel Filtering
This is equivalent to a convolution using the following masks:
• X-direction mask • Y-direction mask

-1 0 1 1 2 1

-2 0 2 0 0 0

-1 0 1 -1 -2 -1

06/23/2021 Prof. Dr. Rafiqul Islam 20


Questionaries'
• Consider a 8-bit 5 by 5 noisy image with
integer value. Now generate an ideal low pass
filter of size 3 by 3.
• Compute Discrete Fourier value of the image.
• Apply the low pass filter to reduce the noise in
frequency domain.
• Apply inverse Discrete fourier transform to
show the spatial domain image.

06/23/2021 Prof. Dr. Rafiqul Islam 21


References
• Digital Image Processing – R Gonzalez, R
Woods

06/23/2021 Prof. Dr. Rafiqul Islam 22

You might also like