image enhancement in the frequency domain...fi = fft2(i); fi2 = log(abs(fi)); imshow( fi2, [-1 5] ,...

34
Image Enhancement in the Frequency Domain Image Enhancement in the Frequency Domain

Upload: others

Post on 29-Mar-2021

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Image Enhancement in the Frequency DomainImage Enhancement in the Frequency Domain

Page 2: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Topics� Frequency Domain Enhancements

� Fourier Transform

� Convolution

High Pass Filtering in Frequency Domain� High Pass Filtering in Frequency Domain

� Low Pass Filtering in Frequency Domain

Page 3: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Frequency Domain� A frequency-domain graph shows how much of the

signal lies within each given frequency band over a range of frequencies.

� A frequency-domain representation can also include � A frequency-domain representation can also include information on the phase shift that must be applied to each sinusoid in order to be able to recombine the frequency components to recover the original time signal.

� A given function or signal can be converted between the time and frequency domains with a pair of mathematical operators called a transform

Page 4: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Frequency Domain

Page 5: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Fourier Transform� Fourier transform is given by

� Inverse Fourier transform is

Page 6: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Two Dimensional Fourier Transform� Forward Fourier Transform is:

� Inverse Fourier Transform is:

Page 7: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Discrete Fourier Transform� 1D forward transform

� 1D inverse transform

Page 8: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Fourier Transform Properties� From Euler’s Equation we have:

Hence by replacing we get� Hence by replacing we get

Page 9: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Magnitude, Phase, and Power

Spectrum of Fourier Transform� Magnitude of Fourier transform is found by:

Phase is given by:� Phase is given by:

� Power Spectrum is:

Page 10: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Sample Functions and their

Fourier Transforms

Page 11: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Sample Fourier Analysis

Page 12: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Convolution� In 2D continuous space, convolution is defined by:

� In 2D discrete space convolution is given by:

Page 13: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Convolution

Page 14: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Filtering in Frequency DomainBasic Steps of Filtering in Frequency Domain Are:

� Compute F(u,v), the DFT of the input image

� Multiply F(u,v) by a filter function H(u,v)

� Compute inverse DFT of the result

� Obtain real part of the inverse DFT

Page 15: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Filtering in Frequency Domain

Page 16: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Spatial Masks in Time Domain

Page 17: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Convolving Mask with Image in

Time Domain� Convolving mask with image is carried out by sliding

the mask over the image, multiplying mask values with the pixel values falling beneath them and obtaining the sum.the sum.

� The convolution is converted to multiplication in frequency domain

Page 18: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Sample Frequency Domain Filters� Notch Filter: Changes the average value of an image to

zero

Page 19: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Low Pass Filters

Page 20: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Ideal Low Pass Filter

Page 21: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Some Low Pass Filters� Gaussian low pass filter (GLPF)

D(u,v) is the distance from the origin of the Fourier D(u,v) is the distance from the origin of the Fourier transform.

Page 22: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Result of Filtering with GLPF

Page 23: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Low Pass Filter Example

Page 24: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

High Pass Filter

Page 25: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

High Pass Filters� Simplest high pass filter is the complement of low pass

filter

� Ideal high pass filter is given by:� Ideal high pass filter is given by:

Page 26: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

High Pass Filters� Gaussian high pass filter is given by:

D0 is the distance from the center to cut-off frequency

D(u,v) is the distance from any point (u,v) to the center given by

Page 27: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Example Results with D0 = 15, 30

and 80

Page 28: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Ideal and Gaussian High Pass Filters

Page 29: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

MATLAB Implementations� Use fft(.) function for 1D Fourier transform and fft2(.)

for 2D transform.

� Use ifft and ifft2 for inverse Fourier transforms

� Example:� Example:

� I = imread(‘test.jpg’);

� FI = fft2(I);

� FI2 = log(abs(FI));

� imshow( FI2, [-1 5] , 'InitialMagnification','fit')

Page 30: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Fast Convolution� Read the image

� Create the mask (or read it)

� Find the Fourier transforms of the Image and the mirror of the mask (rotate by 180 degrees)mirror of the mask (rotate by 180 degrees)

� Multiply the transformed image and the transformed mask

� Find the inverse Fourier transform of the result

Page 31: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Fast Convolution� I = imread(‘test.bmp’);

� Mask = [1 1 1

0 0 0

-1 -1 -1];-1 -1 -1];

� FI = fft2(I);

� FMask = fft2(Mask, size(I,1), size(I,2));

� RF = FI .* FMask;

� R = ifft2( RF );

Page 32: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Example: Detecting a Letter� To find a sample pattern in an image convolution can

be used

� Assume Image is given at variable I and the pattern at PP

� C = real(ifft2( fft2( I ) .* fft2( rot90(P,2)));

� MaxC = max(C);

� imshow( C > MaxC – 5 )

Page 33: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Questions?Questions?

Page 34: Image Enhancement in the Frequency Domain...FI = fft2(I); FI2 = log(abs(FI)); imshow( FI2, [-1 5] , 'InitialMagnification','fit') Fast Convolution Read the image Create the mask (or

Assignment� Will be posted on http://ceng503.cankaya.edu.tr