+ All Categories
Home > Documents > topic_6_rev

topic_6_rev

Date post: 05-Apr-2018
Category:
Upload: rishikesh-pathak
View: 214 times
Download: 0 times
Share this document with a friend

of 29

Transcript
  • 7/31/2019 topic_6_rev

    1/29

    Topic 6 - Image Filtering - I

    DIGITAL IMAGE PROCESSING

    Course 3624

    Department of Physics and Astronomy

    Professor Bob Warwick

  • 7/31/2019 topic_6_rev

    2/29

    6. Image Filtering I: Spatial Domain Filtering

    The goal of spatial filtering is typically either to (a) reduce theimpact of noise in the image via image smoothing or (b) to

    sharpen the detail within the image. Both processes involve thesuppression and/or enhancement of particular spatial frequencycomponents in the image (see Topic 8).

    Point process (eg. Mapping) Neighbourhood process (eg. Spatial filtering)

    gxy=hij

    j=0

    j=n-1

    i=0

    i=n-1

    fx-m+i, y-m-j

    hijj=0

    j=n-1

    i=0

    i=n-1

    For a mask of dimension n x n (n odd),

    where m = (n-1)/2 is the central element.

    Calculate for all x & y

    Note that the denominator is a normalisationfactor sometimes not applicable!

    (ii) Compute a new image gxy from the old image fxy via:

    Procedure

    (i) Define an array of values known variously as the mask, filter,

    operator etc.. (usually with a 3 x 3 or 5 x 5 or 7 x 7 etc.. format)

    h01 h02h00

    h11 h12h10

    h21 h22h20i

    j

    h ij

  • 7/31/2019 topic_6_rev

    3/29

    3

    Computing the 2-d Result

    original 3x3 average

  • 7/31/2019 topic_6_rev

    4/29

    6.1 Smoothing FiltersSmoothing filters involve calculating the average value (withsome defined weighting) within the masked region.

    Assuming a 3 x 3 format, some possibilities are:

    1 1 1 Replaces the original value with

    1 1 1 the average of 9 values (the central

    1 1 1 pixel plus its 8 nearest neighbours)

    1 1 1 Double weighting of the central pixel

    1 2 1

    1 1 1

    0 1 0 Replaces the original value with

    1 1 1 the average of 5 values (the central

    0 1 0 pixel plus its 4 nearest neighbours)

    1 1 1

    1 2 1

    1 1 1

    1 1 1

    1 1 11 1 1

    0 1 0

    1 1 1

    0 1 0

  • 7/31/2019 topic_6_rev

    5/29

    Author: Richard Alan Peters II

    Smoothing Examples: Original Images

  • 7/31/2019 topic_6_rev

    6/29

    Smoothing Examples: 33 Blur

    111

    111

    111

    9

    1

  • 7/31/2019 topic_6_rev

    7/29

    Smoothing Examples: 55 Blur

    11111

    11111

    11111

    11111

    11111

    25

    1

  • 7/31/2019 topic_6_rev

    8/29

    Smoothing Examples: 99 Blur

    111111111

    111111111

    111111111

    111111111

    111111111

    111111111

    111111111

    111111111

    111111111

    81

    1

  • 7/31/2019 topic_6_rev

    9/29

    Smoothing Examples: 1717 Blur

    11111111111111111

    11111111111111111

    11111111111111111

    11111111111111111

    11111111111111111

    11111111111111111

    11111111111111111

    11111111111111111

    11111111111111111

    11111111111111111

    11111111111111111

    11111111111111111

    11111111111111111

    11111111111111111

    11111111111111111

    11111111111111111

    11111111111111111

    289

    1

  • 7/31/2019 topic_6_rev

    10/29

    Image Smoothing Examples

    Original Smoothed

  • 7/31/2019 topic_6_rev

    11/29

    Noise Suppression Example

  • 7/31/2019 topic_6_rev

    12/29

    Noise Suppression Example

  • 7/31/2019 topic_6_rev

    13/29

    Calculating the effective noise reduction

    Example

    Applying a 3 x 3smoothing filter withunit coefficientsresults in a factor 3reduction in thenoise.

    gxy=

    fxy9

    9

    m g = m fs g = s f9

    P(f) = 1s 2p e- (f- m )2

    2s 2

    mean and standard deviation,s

    Gaussian Distribution

    f

    P(f)

  • 7/31/2019 topic_6_rev

    14/29

    The Median FilterSmoothing filters can be used to reduce the impact of the noise in animage but also cause unwanted blurring. The larger the dimension

    of the smoothing mask the greater the noise reduction factor butalso the greater the blurring.

    Non-linear filters, such as the Median Filter, can to some degreedecouple these two effects but in a way which is hard to quantify.

    133

    133

    140

    147

    152154

    163

    164

    171

    The median filter wouldreplace the central value withthe median value containedwithin the mask (or window)

    region.

  • 7/31/2019 topic_6_rev

    15/29

    Suppression of Impulsive Noise

    Smoothing Filter Median Filter

  • 7/31/2019 topic_6_rev

    16/29

    Suppression of Impulsive Noise

  • 7/31/2019 topic_6_rev

    17/29

    6.2 Sharpening Filters

    Smoothing Averaging Sharpening Differencing

    In practice with discretevariables differencing isequivalent to differentiationand both the 1st and 2nd

    differentials can be used tomark the position in animage where there arerapid changes in gray level(ie edges).

    f(x) + f(x)

    f(x) - f (x)

    f(x)

    f(x)

    f (x)

    Continuous variables

    The objective is to enhance the detail in the image by accentuatingedges and boundaries.

  • 7/31/2019 topic_6_rev

    18/29

    Types of Filters Used in Image Sharpening - I

    Pairs of masks of various formats which give the vertical (axy)and horizontal (bxy) gradients:

    (i) The Roberts Operators

    (ii)

    (iii) The Prewitt Operators

    - 1 1

    bxy =fx,y+1-fxy

    - 1

    1

    a xy =fx+1,y -fxy

    - 1 0 1

    bxy =fx,y+1-fx,y-1

    - 10

    1

    axy =fx+1,y-fx-1,y

    - 1 0 1

    - 1 0 1

    - 1 0 1

    gxy = axy2 +bxy

    2

    or

    gxy

    = axy

    + bxy

    Where the finalgradient image iscalculated as:

    - 1 - 1 - 1

    0 0 0

    1 1 1

  • 7/31/2019 topic_6_rev

    19/29

    Image Sharpening Examples

    Consider an image consisting of:

    Applying the following filters gives:

    (i)

    (ii)

    0 0 0 0 1 1 1 ..

    0 0 0 0 1 1 1 ..

    0 0 0 0 1 1 1 ..

    0 0 0 0 1 1 1 ..

    0 0 0 0 0 0 0 ..

    0 0 0 0 0 0 0 ..

    0 0 0 0 0 0 0 ..

    0 0 0 0 0 0 0 ..

    - 1 0 1

    - 1 0 1

    - 1 0 1

    0 0 0 3 3 0 0 ..

    0 0 0 3 3 0 0 ..

    0 0 0 3 3 0 0 ..

    0 0 0 3 3 0 0 ..

    - 1 - 1 - 1

    0 0 01 1 1

  • 7/31/2019 topic_6_rev

    20/29

    Calculating the Gradient Image

    Lena

  • 7/31/2019 topic_6_rev

    21/29

    The Sobel Operators

    Calculating the Gradient Image

    - 1 - 2 - 1

    0 0 0

    1 2 1

    - 1 0 1

    - 2 0 2

    - 1 0 1

  • 7/31/2019 topic_6_rev

    22/29

    Types of Filters Used in Image Sharpening - II

    (i)

    (ii)

    (iii)- 1 - 1 - 1

    - 1 8 - 1

    - 1 - 1 - 1

    0 - 1 0

    - 1 4 - 1

    0 - 1 0

    - 1 2 - 1

    - 1

    2

    - 1

    For discrete data :

    fx'= fx-fx-1

    fx''= fx

    ' -fx-1'

    = (fx-fx-1) - (fx-1-fx-2)

    = fx - 2fx-1 + fx-2

    - fx-1 + 2fx - fx+1

    Masks which give the 2nd differential or Laplacian image

  • 7/31/2019 topic_6_rev

    23/29

    2fxy-fx,y-1-fx,y+1

    4fxy-

    fx-1,y-fx+1,y-

    fx,y-1-fx,y+1

    fxy

    0

    255

    -255

    510

    2 -1-1 2

    -1

    -1

    4 -1-1

    -1

    -1

    The 1-d and 2-d Laplacian Mask in Action

    2fxy-fx-1,y-fx+1,y

  • 7/31/2019 topic_6_rev

    24/29

    The Image Sharpening Process

    In image sharpening the usual approach is to add thederived gradient or Laplacian image to the originalimage in a process known as high frequency emphasis.Thus:

    Final image = original image + gradient or Laplacian image

    0 - 1 0

    - 1 5 - 1

    0 - 1 0

    - 1 - 1 - 1

    - 1 9 - 1

    - 1 - 1 - 1

    For the Laplacian case this can be achieved in onestep by modifying the 2-d mask to:

    or

  • 7/31/2019 topic_6_rev

    25/29

    Image Sharpening Examples

    Consider an image consisting of:

    Applying the following filters gives:

    (i)

    (ii)

    0 0 0 0 1 1 1 ..

    0 0 0 0 1 1 1 ..

    0 0 0 0 1 1 1 ..

    0 0 0 0 1 1 1 ..

    0 0 0 -3 3 0 0 ..

    0 0 0 -3 3 0 0 ..

    0 0 0 -3 3 0 0 ..

    0 0 0 -3 3 0 0 ..

    0 0 0 -3 4 1 1 ..

    0 0 0 -3 4 1 1 ..

    0 0 0 -3 4 1 1 ..

    0 0 0 -3 4 1 1 ..

    - 1 - 1 - 1

    - 1 9 - 1

    - 1 - 1 - 1

    - 1 - 1 - 1

    - 1 8 - 1

    - 1 - 1 - 1

    I Sh i E l

  • 7/31/2019 topic_6_rev

    26/29

    Image Sharpening Examples

  • 7/31/2019 topic_6_rev

    27/29

    The Mathematical Process of Spatial Filtering

    Consider the 1-d case of spatial filtering with an n element mask(n odd), where m= (n-1)/2 and ignoring the normalization factor.

    gx = h i'h

    fx+i' (2)

    gx = h i''h

    fx-i'' (3)

    gx = hx- ah

    fa (4)

    gx= hii=0

    i=n-1 fx-m+i (1) f0 f1 fx fN-1

    h0 hm hn-1

    x

    ii'

    i''

    a

    i'=i-m

    i''=-i'a = x-i''Equation 4 is the discrete version ofthe CONVOLUTION INTEGRAL.

    g(x)= f(a )h(x - a )da-

    Shorthand versions :

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

    gx = fx * hx

    SPATIAL FILTERING IS A

    CONVOLUTION PROCESS

  • 7/31/2019 topic_6_rev

    28/29

    The Mathematical Process of Convolution

    P ti l C id ti

  • 7/31/2019 topic_6_rev

    29/29

    Practical Considerations

    (i) Edge Errors

    For an n x n mask there is a (n-1)/2 border to the new image where exact valuescannot be calculated. Solutions are:

    (a) Reduce the dimensions of the new image (usually impractical)(b) Calculate approximate values for the border pixels

    (c) Compute the cyclic convolution (beyond our scope).

    (ii) Separability

    A 2-d mask is separable if the successive application of two 1-d masks gives theequivalent result to the application of the 2-d mask.

    For example, considered as matrices:

    Therefore this smoothing mask is separable.

    There are computational advantages if the mask is separable.

    1 1 1

    1 1 1

    1 1 1

    1 1 1( ) 1

    1

    1

    Note: Both gradient and Laplacian filters can also be used in

    EDGE DETECTION see topic 10