ch04-frequency domain processing

Upload: innocent-cool

Post on 08-Aug-2018

228 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/22/2019 Ch04-Frequency Domain Processing

    1/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    1

    Frequency

    DomainProcessing

    Chapter 4

    www.ImageProcessingPlace.com

    www.csie.ntnu.edu.tw/~violet/IP93/Chapter04.ppt

  • 8/22/2019 Ch04-Frequency Domain Processing

    2/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    2

    Complex Numbers

    http://en.wikipedia.org/wiki/Complex_number

  • 8/22/2019 Ch04-Frequency Domain Processing

    3/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    3

    Polar Coordinates

    http://en.wikipedia.org/wiki/Polar_coordinates

  • 8/22/2019 Ch04-Frequency Domain Processing

    4/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    4

    Periodic Function

    per iod p

    x x+px

    A functionfis periodic with period pgreater than zero if

    f(x +p) =f(x)

    forallvalues ofx in the domain off.

    If a functionfis periodic with periodp, then for allx in the domain offand all integers n,

    f(x + np) =f(x)

  • 8/22/2019 Ch04-Frequency Domain Processing

    5/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    5

    If a function f is periodic with period p > 0

    then thefundamental frequency off is 1/p

    p has units of length 1/p has units of cycles/length

    Periodic Function

  • 8/22/2019 Ch04-Frequency Domain Processing

    6/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    6

    p is large (large period) 1/p is small (low frequency)

    p is small (small period) 1/p is large (high frequency)

    p

    p

    Periodic Function

  • 8/22/2019 Ch04-Frequency Domain Processing

    7/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    7

    Fourier Series & Fourier Transform

    Any function thatperiodically repeats itself can

    be expressed as the sum of sines and/or cosines of

    different frequencies, each multiplied by a

    different coefficient (Fourier series).

    Even functions that are not periodic (but whose

    area under the curve is finite) can be expressed as

    the integral of sines and/or cosines multiplied bya weighting function (Fourier transform).

  • 8/22/2019 Ch04-Frequency Domain Processing

    8/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    8

    Fourier Transform & Glass Prism

    The prism is a physical device that separates lightinto various color components, each dependingon its wavelength (or frequency) content.

    The Fourier transform may be viewed as amathematical prism that separates(characterizes) a function into variouscomponents, also based on frequency content.

    This is a powerful concept that lies at the heart oflinear filtering.

  • 8/22/2019 Ch04-Frequency Domain Processing

    9/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    9

    Frequency Domain

    The frequency domain

    refers to the plane of the

    two dimensional discrete

    Fourier transform of animage.

    The purpose of the

    Fourier transform is to

    represent a signal as a

    linear combination of

    sinusoidal signals of

    various frequencies.

  • 8/22/2019 Ch04-Frequency Domain Processing

    10/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    10

    Fourier TransformationAnd Its Inverse

    The one-dimensional Fourier transform and its inverse

    Fourier transform (continuous case)

    Inverse Fourier transform:

    The two-dimensional Fourier transform and its inverse

    Fourier transform (continuous case)

    Inverse Fourier transform:

    dueuFxf uxj 2)()(

    dydxeyxfvuF vyuxj )(2),(),(

    1where)()(2

    jdxexfuF

    uxj

    dvduevuFyxf vyuxj )(2),(),(

  • 8/22/2019 Ch04-Frequency Domain Processing

    11/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    11

    The one-dimensional Fourier transform and its inverse

    Fourier transform (discrete case)

    Inverse Fourier transform:

    1,...,2,1,0for)(

    1

    )(

    1

    0

    /2

    MuexfMuF

    M

    x

    Muxj

    1,...,2,1,0for)()(1

    0

    /2

    MxeuFxfM

    u

    Muxj

    Discrete Fourier Transformation

    One Dimensional

  • 8/22/2019 Ch04-Frequency Domain Processing

    12/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    12

    Since (Eulers formula)

    then discrete Fourier transform can be redefined

    Frequency (time) domain: the domain (values ofu) over

    which the values ofF(u) range; because u determines thefrequency of the components of the transform.

    Frequency (time) component: each of theMterms ofF(u).

    1,...,2,1,0for Mu

    1

    0]/2sin/2)[cos(

    1

    )(

    M

    xMuxjMuxxfMuF

    sincos je j

    Discrete Fourier Transformation

    One Dimensional

  • 8/22/2019 Ch04-Frequency Domain Processing

    13/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    13

    F(u) can be expressed in polar coordinates:

    R(u): the real part ofF(u)

    I(u): the imaginary part ofF(u)

    Power spectrum:

    )()()()( 222

    uIuRuFuP

    spectrum)phaseorangle(phase)(

    )(tan)(

    spectrum)or(magnitude)()()(where

    )()(

    1

    22

    )(

    uR

    uIu

    uIuRuF

    euFuF uj

    Discrete Fourier Transformation (DFT)

    One Dimensional

  • 8/22/2019 Ch04-Frequency Domain Processing

    14/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    14

    f(0) = 2

    f(1) = 3

    f(2) = 4

    f(3) = 4

    The One-Dimensional DFT

    Examples

    1,...,2,1,0for Mu

    1

    0

    ]/2sin/2)[cos(1

    )(M

    x

    MuxjMuxxfM

    uF

    )()()( 22 uIuRuF

    F(0) = 3.25

    F(1) = -0.5 +j 0.25

    F(2) = 0.25

    F(3) = -0.5 -j 0.25

    |F(0) | = 3.25

    |F(1) | = 0.75

    |F(2) | = 0.25

    |F(3) | = 0.75

  • 8/22/2019 Ch04-Frequency Domain Processing

    15/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    15

    The One-Dimensional DFT

    Examples

  • 8/22/2019 Ch04-Frequency Domain Processing

    16/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    16

    The One-Dimensional DFT

    Examples

    M= 1024 points, A = 1, K= 8 points

    Spectrum is centered at u = 0 (discussed in the following slides)

    1,...,2,1,0for Mu

    1

    0

    ]/2sin/2)[cos(1

    )(M

    x

    MuxjMuxxfM

    uF

    )()()( 22 uIuRuF

    1

  • 8/22/2019 Ch04-Frequency Domain Processing

    17/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    17

    The One-Dimensional DFT

    Examples

    Important Features:

    The height of the spectrum doubled as the area

    under the curve in thex-domain doubled. The number of zeros in the spectrum in the same

    interval doubled as the length of the function

    doubled. This reciprocal nature of the Fourier transform

    pair is most useful in interpreting results of image

    processing in the frequency domain.

    l 2 d d 18

  • 8/22/2019 Ch04-Frequency Domain Processing

    18/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    18

    The One-Dimensional Fourier TransformSome Examples

    The transform of a constant function is a DC value only.

    The transform of a delta function is a constant.

    Di i l I P i 2 d d 19

  • 8/22/2019 Ch04-Frequency Domain Processing

    19/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    19

    The One-Dimensional Fourier TransformSome Examples

    The transform of an infinite train of delta functions spaced by

    T is an infinite train of delta functions spaced by 1/T.

    The transform of a cosine function is a positive delta at the

    appropriate positive and negative frequency.

    Di i l I P i 2 d d 20

  • 8/22/2019 Ch04-Frequency Domain Processing

    20/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    20

    The One-Dimensional Fourier TransformSome Examples

    The transform of a sin function is a negative complex delta

    function at the appropriate positive frequency and a negative

    complex delta at the appropriate negative frequency.

    The transform of a square pulse is a sinc function.

    Di it l I P i 2 d d 21

  • 8/22/2019 Ch04-Frequency Domain Processing

    21/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    21

    The Two Dimensional DFT

    The two-dimensional Fourier transform and its inverse

    Fourier transform (discrete case) DFT

    Inverse Fourier transform:

    u, v : the transform or frequency variables

    x, y : the spatial or image variables

    1,...,2,1,0,1,...,2,1,0for

    ),(1

    ),(1

    0

    1

    0

    )//(2

    NvMu

    eyxf

    MN

    vuFM

    x

    N

    y

    NvyMuxj

    1,...,2,1,0,1,...,2,1,0for

    ),(),(

    1

    0

    1

    0

    )//(2

    NyMx

    evuFyxf

    M

    u

    N

    v

    NvyMuxj

    Di it l I P i 2 d d 22

  • 8/22/2019 Ch04-Frequency Domain Processing

    22/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    22

    The Two Dimensional DFT

    Properties

    (shift))2

    ,2

    ()1)(,()1(N

    vM

    uFyxf yx

    Di it l I P i 2 d d 23

  • 8/22/2019 Ch04-Frequency Domain Processing

    23/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    23

    We define the Fourier spectrum, phase angle, and power

    spectrum as follows:

    R(u,v): the real part ofF(u,v)

    I(u,v): the imaginary part ofF(u,v)

    spectrum)(power),(),(),()(

    angle)(phase),(

    ),(tan),(

    spectrum)(),(),(),(

    222

    1

    2

    122

    vuIvuRvuFu,vP

    vuR

    vuIvu

    vuIvuRvuF

    The Two Dimensional DFT

    Di it l I P i 2 d d 24

  • 8/22/2019 Ch04-Frequency Domain Processing

    24/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    24

    Magnitude and Phase

    Of sinusoidal wave

    Digital Image Processing 2nd ed 25

  • 8/22/2019 Ch04-Frequency Domain Processing

    25/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    25

    Complex Numbers

    Digital Image Processing 2nd ed 26

  • 8/22/2019 Ch04-Frequency Domain Processing

    26/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    26

    A Memory Aid for Evaluating j

    Digital Image Processing 2nd ed 27

  • 8/22/2019 Ch04-Frequency Domain Processing

    27/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    27

    DFT Translation Property

    Digital Image Processing 2nd ed 28

  • 8/22/2019 Ch04-Frequency Domain Processing

    28/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    28

    DFT Rotation Property

    Digital Image Processing 2nd ed 29

  • 8/22/2019 Ch04-Frequency Domain Processing

    29/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    29

    DFT Periodicity

    Digital Image Processing 2nd ed 30

  • 8/22/2019 Ch04-Frequency Domain Processing

    30/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    30

    spectrum)theofcomponentor DC(average

    ),(1

    )0,0(1

    0

    1

    0

    M

    x

    N

    y

    yxfMN

    F

    The Two Dimensional DFT

    Properties

    F(u, v) =F(u+M, v) =F(u, v+N) =F(u+M, v+N)

    (infinitely periodic in both u & v directions)

    Same is for inverse DFT:

    f(x,y) =f(x+M,y) =f(x,y+N) =f(x+M,y+N)

    Digital Image Processing 2nd ed 31

  • 8/22/2019 Ch04-Frequency Domain Processing

    31/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    31

    (a)f(x,y) (b)F(u,y) (c)F(u, v)

    The 2D DFTF(u, v) can be obtained by:

    1. taking the 1D DFT of every row of imagef(x,y),F(u,y),

    2. taking the 1D DFT of every column ofF(u,y)

    The Two Dimensional DFT

    Digital Image Processing 2nd ed 32

  • 8/22/2019 Ch04-Frequency Domain Processing

    32/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    32

    shift

    The Two Dimensional DFT

    Digital Image Processing 2nd ed 33

  • 8/22/2019 Ch04-Frequency Domain Processing

    33/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    33

    The Two Dimensional DFT

    Digital Image Processing 2nd ed 34

  • 8/22/2019 Ch04-Frequency Domain Processing

    34/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    34

    The Two Dimensional DFT

    Digital Image Processing, 2nd ed. 35

  • 8/22/2019 Ch04-Frequency Domain Processing

    35/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    35

    Computing & Visualizing

    2-D DFT>> f = imread('rectangle.tif');

    >> F = fft2(f);

    >> Fc = fftshift(F);

    >> imshow(abs(Fc), [])>> S2 = log(1+abs(Fc));

    >> imshow(S2, [])

    Note:[(-1)x+yf(x, y)]

    = fftshift(fft2(f))

    Digital Image Processing, 2nd ed. 36

  • 8/22/2019 Ch04-Frequency Domain Processing

    36/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    36

    The Property of Two-Dimensional DFT

    Rotation

    DFT

    DFT

    Digital Image Processing, 2nd ed. 37

  • 8/22/2019 Ch04-Frequency Domain Processing

    37/77

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    37

    The Property of Two-Dimensional DFT

    Linear Combination

    DFT

    DFT

    DFT

    A

    B

    0.25 * A

    + 0.75 * B

    Digital Image Processing, 2nd ed. 38

  • 8/22/2019 Ch04-Frequency Domain Processing

    38/77

    g g g,www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    38

    The Property of Two-Dimensional DFT

    Expansion

    DFT

    DFT

    A

    Expanding the original image by a factor of n (n=2), filling

    the empty new values with zeros, results in the same DFT.

    B

    Digital Image Processing, 2nd ed.i i b k

    39

  • 8/22/2019 Ch04-Frequency Domain Processing

    39/77

    g g g,www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    39

    Two-Dimensional DFT with Different Functions

    Sine wave Its DFT

    Digital Image Processing, 2nd ed.i i b k

    40

  • 8/22/2019 Ch04-Frequency Domain Processing

    40/77

    g g g,www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    40

    Two-Dimensional DFT with Different Functions

    2D Gaussian

    function

    Impulses

    Its DFT

    Its DFT

    Digital Image Processing, 2nd ed.i i b k

    41

  • 8/22/2019 Ch04-Frequency Domain Processing

    41/77

    g g g,www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    Filtering in the Frequency Domain

    Digital Image Processing, 2nd ed.www imageprocessingbook com

    42

  • 8/22/2019 Ch04-Frequency Domain Processing

    42/77

    g g gwww.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    1. Since frequency is directly related

    to rate of change it can be

    associated with frequencies in the

    Fourier transform.

    2. Slowest varying frequencycomponent (u = v = 0)

    corresponds to the average gray

    level of an image.

    3. As we move further away from

    the origin, the higher frequencies

    begin to correspond to faster and

    faster gray level changes in an

    image, which are the edges of

    objects or noise etc.

    Filtering in the Frequency DomainSome Basic Properties

    Digital Image Processing, 2nd ed.www imageprocessingbook com

    43

  • 8/22/2019 Ch04-Frequency Domain Processing

    43/77

    g g gwww.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    Filtering in the Frequency DomainBasics of Filtering in the Frequency Domain

    Digital Image Processing, 2nd ed.www imageprocessingbook com

    44

  • 8/22/2019 Ch04-Frequency Domain Processing

    44/77

    www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    1) Multiply the input image by (-1)x+y to center the

    transform.

    2) ComputeF(u,v), the DFT of the image from (1).

    3) MultiplyF(u,v) by a filter functionH(u,v).

    4) Compute the inverse DFT of the result in (3).

    5) Obtain the real part of the result in (4).6) Multiply the result in (5) by (-1)x+y.

    Filtering in the Frequency DomainBasics of Filtering in the Frequency Domain

    Digital Image Processing, 2nd ed.www imageprocessingbook com

    45

  • 8/22/2019 Ch04-Frequency Domain Processing

    45/77

    www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    1. Obtain the padding parameters:

    PQ = paddedsize(size(f));

    2. Obtain the Fourier transform with padding:

    F = fft2(f, PQ(1), PQ(2));

    3. Generate a filter function, H, of size PQ using any of the methods

    discussed in the later slides. Apply: H = fftshift(H) if necessary.

    4. Multiply the transform 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));

    Filtering in the Frequency DomainImplementation Through MATLAB

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    46

  • 8/22/2019 Ch04-Frequency Domain Processing

    46/77

    www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    Filtering in the spatial domain is described by the following

    equation:

    g(x,y) = h(x,y)*f(x,y)

    wheref(x,y) is the original image, h(x,y) is the filter and * denotes theconvolution operation.

    Filtering in the frequency domain is described by the following

    equation:

    G(u, v) =H(u, v)F(u, v)where

    F(u, v) is the Fourier transform of an image

    H(u, v) is the frequency domain filter

    G(u, v) is the Fourier transform of the filtered image

    Filtering in the Spatial and Frequency Domain

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    47

  • 8/22/2019 Ch04-Frequency Domain Processing

    47/77

    www.imageprocessingbook.com

    2002 R. C. Gonzalez & R. E. Woods

    Correspondence between Filtering in

    the Spatial and Frequency Domain

    Convolution Theorem:

    The foundation for linear filtering in both the spatial and

    frequency domains is the convolution theorem, which may

    be written as:

    where

    F(u,v) andH(u,v) denote the Fourier transforms off(x,y) and h(x,y). * Indicates the convolution of the two functions.

    The discrete convolution of two functionsf(x,y) and h(x,y) of sizeMN

    is defined as:

    1

    0

    1

    0

    ),(),(1

    ),(),(M

    m

    N

    n

    nymxhnmf

    MN

    yxhyxf

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    48

  • 8/22/2019 Ch04-Frequency Domain Processing

    48/77

    g p g

    2002 R. C. Gonzalez & R. E. Woods

    Correspondence between Filtering in

    the Spatial and Frequency Domain

    The third equivalence relation says that given a filter in the

    frequency domain, we can obtain the corresponding filter in the

    spatial domain by taking the inverse Fourier transform of the

    former. The reverse is also true.

    The convolution theorem links filters in both domains (spatial and

    frequency). Filtering is often more intuitive in the frequency

    domain, since one can easily foresee the results, given a filter.

    However, filters in the spatial domain have smaller masks than

    those in the frequency domain. That is, one can first specify a

    filter in the frequency domain, take its inverse Fourier transform,

    and then use the resulting filter in the spatial domain as a guide for

    constructing smaller spatial filter masks!

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    49

  • 8/22/2019 Ch04-Frequency Domain Processing

    49/77

    g p g

    2002 R. C. Gonzalez & R. E. Woods

    Spatial domain Frequency domain

    Average filter Gaussian lowpass filter

    Laplacian Gaussian highpass filter

    The convolution theorem establishes a correspondence

    between filtering in the spatial and frequency domains as

    shown in the following table.

    Correspondence between Filtering in

    the Spatial and Frequency Domain

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    50

  • 8/22/2019 Ch04-Frequency Domain Processing

    50/77

    g p g

    2002 R. C. Gonzalez & R. E. Woods

    Letf(x,y) and h(x,y) are of sizeA B and C D, resp., then wraparound

    error can be avoided by choosing:

    P A + C -1

    Q B + D -1

    Filtering in the Frequency DomainPadding

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    51

  • 8/22/2019 Ch04-Frequency Domain Processing

    51/77

    2002 R. C. Gonzalez & R. E. Woods

    Filtering in the Frequency DomainPadding

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    52

  • 8/22/2019 Ch04-Frequency Domain Processing

    52/77

    2002 R. C. Gonzalez & R. E. Woods

    Filtering in the Frequency DomainPadding Function

    Exercises:

    (1) [1, 4.3.1]

    Write an M-function:

    function PQ = paddedsize(AB, CD, PARAM)

    and use it on figure squareBW.tif to visualize the

    difference between images with padding and without

    padding.

    (2) [1, 4.3.3]

    Write an M-function for filtering in the frequency

    domain.

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    53

  • 8/22/2019 Ch04-Frequency Domain Processing

    53/77

    2002 R. C. Gonzalez & R. E. Woods

    Notch Filter: Force the average value of an image to zero.

    Multiply all values ofF(u,v) by the filter function:

    All this filter would do is setF(0,0) to zero and leave all

    frequency components of the Fourier transform untouched.

    otherwise.1

    )2/,2/(),(if0),(

    NMvuvuH

    Filtering in the Frequency DomainSome Basic Filters & Their Properties

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    54

  • 8/22/2019 Ch04-Frequency Domain Processing

    54/77

    2002 R. C. Gonzalez & R. E. Woods

    Filtering in the Frequency DomainSome Basic Filters & Their Properties

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    55

  • 8/22/2019 Ch04-Frequency Domain Processing

    55/77

    2002 R. C. Gonzalez & R. E. Woods

    Filtering in the Frequency DomainSome Basic Filters & Their Properties

    Lowpass filter is a filter that attenuates high frequencies

    while passing' low frequencies. Low frequencies

    correspond to the slowly varying components of an image

    (e.g., uniform background).

    Highpass filter is a filter that attenuates low frequencies

    while passing high frequencies. High frequencies

    correspond to the sharply varying components of an image(e.g., edges).

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    56

  • 8/22/2019 Ch04-Frequency Domain Processing

    56/77

    2002 R. C. Gonzalez & R. E. Woods

    Filtering in the Frequency DomainSome Basic Filters & Their Properties

    Lowpass Filter

    Highpass Filter

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    57

  • 8/22/2019 Ch04-Frequency Domain Processing

    57/77

    2002 R. C. Gonzalez & R. E. Woods

    Filtering in the Frequency DomainSome Basic Filters & Their Properties

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    58

  • 8/22/2019 Ch04-Frequency Domain Processing

    58/77

    2002 R. C. Gonzalez & R. E. Woods

    A 2-D ideal low-pass filter is one whose transfer

    function satisfies the relation:

    1 ifD(u, v) Do

    whereDo is a non-negative quantity and D(u,v) is the distance from

    the point (u,v) to the origin of the frequency plane:

    Filtering in the Spatial and Frequency DomainIdeal Filters

    22

    22

    ),(

    Nv

    MuvuD

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    59

  • 8/22/2019 Ch04-Frequency Domain Processing

    59/77

    2002 R. C. Gonzalez & R. E. Woods

    H(u, v)

    D(u, v)0

    1

    Do

    Do

    Remove (multiply by zero) all frequencies >Do

    Ideal Low Pass Filter

    Filtering in the Spatial and Frequency DomainIdeal Filters

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    60

  • 8/22/2019 Ch04-Frequency Domain Processing

    60/77

    2002 R. C. Gonzalez & R. E. Woods

    Filtering in the Spatial and Frequency DomainIdeal Filters

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    61

  • 8/22/2019 Ch04-Frequency Domain Processing

    61/77

    2002 R. C. Gonzalez & R. E. Woods

    Ideal low pass filter

    Spatial domain image Filtered frequency domain imageFrequency domain image

    ForwardFFT

    Filtered spatial domain image

    InverseFFT

    Ideal Frequency

    Domain Filtering

    causes ringing

    Filtering in the Spatial and Frequency DomainIdeal Filters

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    62

  • 8/22/2019 Ch04-Frequency Domain Processing

    62/77

    2002 R. C. Gonzalez & R. E. Woods

    Filtering in the Spatial and Frequency DomainIdeal Lowpass Filters (ILPF)

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    63

  • 8/22/2019 Ch04-Frequency Domain Processing

    63/77

    2002 R. C. Gonzalez & R. E. Woods

    Ideal Lowpass Filters

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    64

  • 8/22/2019 Ch04-Frequency Domain Processing

    64/77

    2002 R. C. Gonzalez & R. E. Woods

    Spatial domain image Filtered frequency domain imageFrequency domain image

    Forward

    FFT

    Filtered spatial domain image

    Inverse

    FFT

    Ideal Frequency

    Domain Filtering

    causes ringing

    Ideal high pass filter

    Filtering in the Spatial and Frequency DomainIdeal Filters

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com

    65

  • 8/22/2019 Ch04-Frequency Domain Processing

    65/77

    2002 R. C. Gonzalez & R. E. Woods

    Butterworth Lowpass Filters (BLPFs)With order n

    nDvuDvuH

    2

    0/),(1

    1),(

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com 66

  • 8/22/2019 Ch04-Frequency Domain Processing

    66/77

    2002 R. C. Gonzalez & R. E. Woods

    Butterworth Lowpass

    Filters (BLPFs)

    n=2

    D0=5,15,30,80,and 230

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com 67

  • 8/22/2019 Ch04-Frequency Domain Processing

    67/77

    2002 R. C. Gonzalez & R. E. Woods

    Butterworth Lowpass Filters (BLPFs)

    Spatial Representation

    n=1 n=2 n=5 n=20

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com 68

  • 8/22/2019 Ch04-Frequency Domain Processing

    68/77

    2002 R. C. Gonzalez & R. E. Woods

    Gaussian Lowpass Filters (GLPFs)

    20

    2 2/),(),( DvuDevuH

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com 69

  • 8/22/2019 Ch04-Frequency Domain Processing

    69/77

    2002 R. C. Gonzalez & R. E. Woods

    Gaussian Lowpass

    Filters (GLPFs)

    D0=5,15,30,80,and 230

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com 70

  • 8/22/2019 Ch04-Frequency Domain Processing

    70/77

    2002 R. C. Gonzalez & R. E. Woods

    Additional Examples of Lowpass Filtering

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com 71

  • 8/22/2019 Ch04-Frequency Domain Processing

    71/77

    2002 R. C. Gonzalez & R. E. Woods

    Additional Examples of Lowpass Filtering

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com 72

  • 8/22/2019 Ch04-Frequency Domain Processing

    72/77

    2002 R. C. Gonzalez & R. E. Woods

    Spatial domain image Filtered frequency domain imageFrequency domain image

    Forward

    FFT

    Filtered spatial domain image

    Inverse

    FFT

    Smoother Gaussian

    Filtering in the

    Frequency

    Domain shows no

    ringing

    Filtering in the Spatial and Frequency DomainIdeal Filters

    Gaussian high pass filter

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com 73

  • 8/22/2019 Ch04-Frequency Domain Processing

    73/77

    2002 R. C. Gonzalez & R. E. Woods

    Sharpening Frequency Domain Filter

    ),(),( vuHvuH lphp Ideal highpass filter

    Butterworth highpass filter

    Gaussian highpass filter

    ),(if1

    ),(if0),(

    0

    0

    DvuD

    DvuDvuH

    nvuDDvuH

    2

    0 ),(/1

    1),(

    20

    2 2/),(1),( DvuDevuH

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com 74

  • 8/22/2019 Ch04-Frequency Domain Processing

    74/77

    2002 R. C. Gonzalez & R. E. Woods

    Highpass Filters

    Spatial Representations

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com 75

  • 8/22/2019 Ch04-Frequency Domain Processing

    75/77

    2002 R. C. Gonzalez & R. E. Woods

    Ideal Highpass Filters

    ),(if1

    ),(if0),(

    0

    0

    DvuD

    DvuDvuH

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com 76

  • 8/22/2019 Ch04-Frequency Domain Processing

    76/77

    2002 R. C. Gonzalez & R. E. Woods

    Butterworth Highpass Filters

    nvuDDvuH

    2

    0 ),(/1

    1),(

    Digital Image Processing, 2nd ed.www.imageprocessingbook.com 77

  • 8/22/2019 Ch04-Frequency Domain Processing

    77/77

    Gaussian Highpass Filters

    20

    2 2/),(1),( DvuDevuH