FrequencyDomainImageProcessing Set 02

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 79

Frequency Domain Image

Processing

Dr. Muhammad Hanif


Fourier Transform
 Any signal can be expressed as sum of sines and cosines
multiplied by a weighing function.
 The transformed signal can be reconstructed completely via
an inverse process with no loss of information
 Applications of Fourier transforms in Image processing: –
• Image enhancement,
• Image restoration,
• Image encoding / decoding,
• Image description
Frequencies in Image
• What do frequencies mean in an image ?
• – High frequencies correspond to pixel values that change rapidly
across the image (e.g. text, texture, edegz, etc.)
• – low frequency components correspond to slow changing pixel
values (large scale features) in the image (e.g. a single, homogenous
object that dominates the image)
• We will use Fourier transformations to obtain frequency
representations of an image
Main Steps
• 1. Multiply the input image by to centre the transform.

• 2. Compute F(u, v), the DFT of the image.
• 3. Multiply F(u, v) by a filter function H(u,v).

• 4. Compute the inverse DFT of the result.

• 5. Obtain the real part of the result.


• 6. Multiply the result by
Main Steps
Basics
• To filter an image in the frequency domain:
• – Compute F(u,v) the DFT of the image
– Multiply F(u,v) by a filter function H(u,v)
– Compute the inverse DFT of the result
Freq. Domain: Main Properties
Convolution in DFT
Frequency Domain Filtering
• H(u,v) is called a filter is because it suppresses certain frequencies in
the transform while leaving others unchanged.
• We can therefore directly design a transfer function H (u, v) and
implement the enhancement in the frequency domain as follows:

• Letting F(u,v) and H(u,v) denote the Fourier transforms of f(x,y) and
h(x,y), the following result holds:
Frequency Domain Filtering
Frequency Domain Filters
• Smoothing Filters:
• Low pass filters
• ideal (very sharp)
• Butterworth (tunable)
• Gaussian (very smooth)
• Sharping Filters:
• High pass filters
• ideal (very sharp)
• Butterworth (tunable)
• Gaussian (very smooth)
Notch Filter
• We wish to force the average value of an image to zero:
• F(0; 0) is the average value of the image
• If size of the image is M × N then the centered value of the Fourier
transform is the average value (M/2 , N/2 )
• Remove the average value of an image

Notch Filter
• Notch filter - remove the average value of an image
Basic Frequency Domain filters
Smoothing in Freq. Domain
Ideal Low Pass filter
Ideal Low Pass filter
Ideal Low Pass filter
Example: Low
Pass filter
Ideal Low Pass filter
• In ideal low pass filters have some issues:
• Blurring : Low frequencies are removed
• Ringing : Cutoff is too sharp
Blurring - Ideal Low pass Filter

99.7% 99.37% 98.65%


Butterworth Low Pass filter
Gaussian Low Pass

No Ringing
Low Pass Filter
Sharping in Freq. Domain
Ideal High Pass
Butterworth High Pass
Gaussian High Pass
Laplacian in Frequency domain
• DFT of Laplacian in 1 D:

• General form in 2D:

• So Laplacian filter in Frequency domain is :


Laplacian in Frequency domain

• Example:
High Boost filtering (EXTRA)
• Idea: HP filters cut the zero frequency component, namely the mean
value. The resulting image is zero mean and looks very dark
• High boost filtering “sums” the original image to the result of HPF in
order to get an image with sharper (emphasized) edges but with
same range of grey values as the original one
High Boost filtering (EXTRA)
• In Fourier domain
High Boost filtering (EXTRA)
• Example
High Boost filtering (EXTRA)
• High boost and histogram equalization
Notch Filter
• Force the average value of an image to zero
• F(0; 0) is the average value of the image
• If size of the image is M × N then the centered value of the Fourier
transform is the average value (M/2 , N/2 )
• Remove the average value of an image

Notch Filter
• Notch filter - remove the average value of an image
Notch Filters
• Notch filter as band reject filter
• Block or remove specific frequencies in an image
• Notch filters and periodic Noise
Notch Filter
Notch Filter
Notch Band Reject filters
• In addition to basic Notch filter we have ideal, Butterworth and
Gaussian Band reject Notch filters
Notch Band Reject Filter
• Ideal Notch Band Reject:

• Where D(u,v) is the distance from the origin, calculated as

• Do is the center of the band to be rejected (block) and W is the width of the
reject band.
Notch Band Reject Filter
• Butterworth Band Reject:
Notch Band Reject Filter
• Gaussian Band Reject:
Notch Band Reject Filter
Notice strong
frequency
components in the
ring

Butterworth
Band-reject
filter
Notch Band Reject Filter
Band Reject filter
• Example
Local Rejector
• Example:
Homomorphic Filtering
• The image can be characterized by two components,
• (1) the amount of source illumination incident and
• (2) amount of illumination reflected by the object.
• These are called the illumination and reflectance components of the
image.
• Image is assumed to consist of two multiplicative components:
• Illumination and reflectance
Homomorphic Filtering
• Homomorphic filtering is a technique for removing multiplicative
noise that has certain characteristics.
• (x,y)=I(x,y) n(x,y)
• Homomorphic filtering is most commonly used for correcting non-
uniform illumination in images.
• The illumination-reflectance model of image formation says that the
intensity at any pixel, which is the amount of light reflected by a point
on the object, is the product of the illumination of the scene and the
reflectance of the object(s) in the scene, i.e.
I(x,y)=L(x,y) R(x,y)
Homomorphic Filtering
• Reflectance R arises from the properties of the scene objects
themselves, but illumination L results from the lighting conditions at
the time of image capture.
• To compensate for the non-uniform illumination, the key is to remove
the illumination component L and keep only the reflectance
component R.
• If we consider illumination as the noise signal (which we want to
remove), this model is similar to the multiplicative noise model
shown earlier.
Homomorphic filtering
• The aim: to normalize the intensity across the entire image and to increase
contrast
• Reflectance Model:
• Illumination i(x,y)
• Surface Reflectance r(x,y)
• Brightness f(x,y) = i(x,y) • r(x,y)
• Assumptions:
• Illumination changes "slowly" across scene :Illumination low frequencies.
• Surface reflections change "sharply" across scene reflectance high
frequencies.
• The image can be decomposed (factorized) in each pixel into a product of
two components – illumination i and reflectance r: f(x, y) = i(x, y) r(x, y).
Homomorphic filtering
• This difference is the key to separating out the illumination
component from the reflectance component.
Homomorphic filtering
• The key idea: the logarithm function can be used to separate the
illumination and the reflectance components.
Homomorphic filtering
Homomorphic filtering
• We use a high-pass filter H(u,v) in the log domain to remove the low-
frequency illumination component while preserving the high-
frequency reflectance component.
• The basic steps in homomorphic filtering are shown in the diagram
below:

Homomorphic filtering
• Example: The outcome is the suppression in the illumination changes
in the scene and the improvement of the reflectance component.
Homomorphic filtering
Homomorphic filtering
MATLAB– Homomorphic Filter
• I = imread('AT3_1m4_01.tif');
• imshow(I)
• I = im2double(I);
• I = log(1 + I);
• M = 2*size(I,1) + 1;
• N = 2*size(I,2) + 1;
• sigma = 10;
• % Hihgpass Filter
• [X, Y] = meshgrid(1:N,1:M);
• centerX = ceil(N/2);
• centerY = ceil(M/2);
• gaussianNumerator = (X - centerX).^2 + (Y - centerY).^2;
• H = exp(-gaussianNumerator./(2*sigma.^2));
• H = 1 - H;
MATLAB– Homomorphic Filter
• imshow(H,'InitialMagnification',25);
• H = fftshift(H);
• If = fft2(I, M, N);
• Iout = real(ifft2(H.*If));
• Iout = Iout(1:size(I,1),1:size(I,2));
• Ihmf = exp(Iout) - 1;
• imshowpair(I, Ihmf, 'montage')
MATLAB– Homomorphic Filter
MATLAB
• the value of the transform at the origin of the frequency domain,
at F(0,0), is called the DC component F(0,0) is equal to MN times the
average value of f(x,y)
• in MATLAB, F(0,0) is actually F(1,1) because array indices in MATLAB
start at 1 rather than 0
• we visually analyse a Fourier transform by computing a Fourier
spectrum (the magnitude of F(u,v)) and display it as an image. the
Fourier spectrum is symmetric about the origin
• the fast Fourier transform (FFT) is a fast algorithm for computing the
discrete Fourier transform.
MATLAB
• MATLAB has three functions to compute the DFT:
• fft -for one dimension (useful for audio)
• fft2 -for two dimensions (useful for images)
• fftn -for n dimensions
• MATLAB has three related functions that compute the inverse DFT:
• ifft
• ifft2
• ifftn
MATLAB Example
MATLAB
MATLAB
• Example:
MATLAB
• Basic steps in DFT filtering:
1. Obtain the padding parameters using function paddedsize: (
PQ=paddedsize(size(f)); )
2. Obtain the Fourier transform of the image with padding: ( F=fft2(f,
PQ(1), PQ(2)); )
3. Generate a filter function, H, the same size as the image
4. Multiply the transformed image by the filter: ( G=H.*F; )
5. Obtain the real part of the inverse FFT of G: ( g=real(ifft2(G)); )
6. Crop the top, left rectangle to the original size: (g=g(1:size(f, 1), 1:size(f,
2));)
MATLAB- LowPass Filter
footBall=imread('football.jpg');
%Convert to grayscale
footBall=rgb2gray(footBall);
imshow(footBall)
%Determine good padding for Fourier transform
PQ = paddedsize(size(footBall));
%Create a Gaussian Lowpass filter 5% the width of the Fourier transform
D0 = 0.05*PQ(1); H = lpfilter('gaussian', PQ(1), PQ(2), D0);
% Calculate the discrete Fourier transform of the image
F=fft2(double(footBall),size(H,1),size(H,2));
% Apply the highpass filter to the Fourier spectrum of the image
LPFS_football = H.*F;
% convert the result to the spacial domain.
LPF_football=real(ifft2(LPFS_football));
% Crop the image to undo padding
LPF_football=LPF_football(1:size(footBall,1), 1:size(footBall,2));
%Display the blurred image figure, imshow(LPF_football, [])
% Display the Fourier Spectrum % Move the origin of the transform to the center of the
frequency rectangle.
Fc=fftshift(F); Fcf=fftshift(LPFS_football);
% use abs to compute the magnitude and use log to brighten display
S1=log(1+abs(Fc)); S2=log(1+abs(Fcf));
figure, imshow(S1,[])
figure, imshow(S2,[])
MATLAB- LowPass Filter
MATLAB
• Notch Filter

You might also like