Image Processing 5-SpatialFiltering1.ppt

download Image Processing 5-SpatialFiltering1.ppt

of 15

Transcript of Image Processing 5-SpatialFiltering1.ppt

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    1/33

    1

    of 

    19

    Interesting article in

    the March, 2006

    issue of Wired

    magazine

    Read it here

    http://www.wired.com/wired/archive/14.03/lapd.htmlhttp://www.wired.com/wired/archive/14.03/lapd.html

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    2/33

    Course Website: htt:!!"""#com#dit#ie!bmacnamee

    $igital Image %rocessing

    Image &nhancement'(atial )iltering 1*

    http://www.comp.dit.ie/bmacnameehttp://www.comp.dit.ie/bmacnamee

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    3/33

    +

    of 

    19Contents

    In this lecture "e "ill loo at satial filteringtechni-ues:

     . /eighbourhood oerations

     . What is satial filtering . (moothing oerations

     . What haens at the edges

     . Correlation and conolution

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    4/33

    of 

    19/eighbourhood 3erations

    /eighbourhood oerations siml4 oerateon a larger neighbourhood of i5els than

    oint oerations

    /eighbourhoods aremostl4 a rectangle

    around a central i5el

     n4 size rectangleand an4 shae filter

    are ossible

    Origin  x 

     y  Image f (x, y)

    (x, y)

     Neighbourhood 

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    5/33

    7

    of 

    19(imle /eighbourhood 3erations

    (ome simle neighbourhood oerationsinclude:

     . Min: (et the i5el alue to the minimum in

    the neighbourhood . Max: (et the i5el alue to the ma5imum in

    the neighbourhood

     . Median: 8he median alue of a set of

    numbers is the midoint alue in that set 'e#g#

    from the set 1, , 17, 1;, 2< 17 is the

    median*# (ometimes the median "ors better

    than the aerage

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    6/33

    6

    of 

    19

    (imle /eighbourhood 3erations

    &5amle

    12+ 12 12; 119 117 1+0

    10 17 1; 17+ 16 12

    1++ 17 1;+ 192 19 191

    19 199 20 210 19; 197

    16 10 17 162 1+ 171

    Original Image  x 

    y

     Enhanced Image  x 

     y

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    7/33

    of 

    198he (atial )iltering %rocess

    r s t 

    u v w

     x y z 

    Origin  x 

     y  Image f (x, y)

    e processed  = v*e +

    r *a + s*b + t *c +

    u*d + w*f + x*g + y*h + z *i

    Filter Simple 3*3

     Neighbourhood e 3*3 Filter 

    a b c

    d e f 

     g h i

    Original ImagePixels

    *

    8he aboe is reeated for eer4 i5el in the

    original image to generate the filtered image

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    8/33

    ;

    of 

    19(atial )iltering: &-uation )orm

    ∑∑−= −=

    ++=

    a

    a s

    b

    bt 

    t  y s x f t  sw y x g  ),(),(),(

    )iltering can be gienin e-uation form as

    sho"n aboe

    /otations are basedon the image sho"n

    to the left

       I  m  a  g  e  s   t  a     e  n   f  r  o  m   =  o  n  z  a   l  e  z   >   W  o  o   d  s ,

       $   i  g   i   t  a   l   I  m  a

      g  e   %  r  o  c  e  s  s   i  n  g   '   2   0   0   2   *

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    9/33

    9

    of 

    19(moothing (atial )ilters

    3ne of the simlest satial filteringoerations "e can erform is a smoothing

    oeration

     . (iml4 aerage all of the i5els in aneighbourhood around a central alue

     . &seciall4 useful

    in remoing noise

    from images

     . lso useful for

    highlighting gross

    detail

    1!91!9

    1!9

    1!91!9

    1!9

    1!91!9

    1!9

    (imleaeraging

    filter 

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    10/33

    10

    of 

    19(moothing (atial )iltering

    1!9 1!9 1!91!9

    1!91!9

    1!91!9

    1!9

    Origin  x 

     y  Image f (x, y)

    e = 1/9*106 +1/9*104 +

    1/9*100 +1/9*108 +

    1/9*99 + 1/9*98 +1/9*95 +

    1/9*90 +1/9*85

      = 98.3333

    Filter Simple 3*3

    Neighbourhood 1! 

    10

    99

    97

    100 10;

    9;

    90 ;7

    1!91!9

    1!9

    1!91!9

    1!9

    1!91!9

    1!9

    3*3 Smoothing 

    Filter 

    1" 1 1#

    $$ 1! $#

    $% $ #%

    Original ImagePixels

    *

    8he aboe is reeated for eer4 i5el in the

    original image to generate the smoothed image

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    11/33

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    12/33

    12

    of 

    19Image (moothing &5amle

       I  m  a  g  e  s   t  a     e  n   f  r  o  m   =  o  n  z  a   l  e  z   >   W  o  o   d  s ,

       $   i  g   i   t  a   l   I  m  a

      g  e   %  r  o  c  e  s  s   i  n  g   '   2   0   0   2   *

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    13/33

    1+

    of 

    19Image (moothing &5amle

       I  m  a  g  e  s   t  a     e  n   f  r  o  m   =  o  n  z  a   l  e  z   >   W  o  o   d  s ,

       $   i  g   i   t  a   l   I  m  a

      g  e   %  r  o  c  e  s  s   i  n  g   '   2   0   0   2   *

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    14/33

    1

    of 

    19Image (moothing &5amle

       I  m  a  g  e  s   t  a     e  n   f  r  o  m   =  o  n  z  a   l  e  z   >   W  o  o   d  s ,

       $   i  g   i   t  a   l   I  m  a

      g  e   %  r  o  c  e  s  s   i  n  g   '   2   0   0   2   *

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    15/33

    17

    of 

    19Image (moothing &5amle

       I  m  a  g  e  s   t  a     e  n   f  r  o  m   =  o  n  z  a   l  e  z   >   W  o  o   d  s ,

       $   i  g   i   t  a   l   I  m  a

      g  e   %  r  o  c  e  s  s   i  n  g   '   2   0   0   2   *

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    16/33

    16

    of 

    19Image (moothing &5amle

       I  m  a  g  e  s   t  a     e  n   f  r  o  m   =  o  n  z  a   l  e  z   >   W  o  o   d  s ,

       $   i  g   i   t  a   l   I  m  a

      g  e   %  r  o  c  e  s  s   i  n  g   '   2   0   0   2   *

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    17/33

    1

    of 

    19Image (moothing &5amle

       I  m  a  g  e  s   t  a     e  n   f  r  o  m   =  o  n  z  a   l  e  z   >   W  o  o   d  s ,

       $   i  g   i   t  a   l   I  m  a

      g  e   %  r  o  c  e  s  s   i  n  g   '   2   0   0   2   *

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    18/33

    1;

    of 

    19Weighted (moothing )ilters

    More effectie smoothing filters can begenerated b4 allo"ing different i5els in the

    neighbourhood different "eights in the

    aeraging function . %i5els closer to the

    central i5el are more

    imortant

     . 3ften referred to as a

    weighted averaging 

    1!162!16

    1!16

    2!16!16

    2!16

    1!162!16

    1!16

    Weighted

    aeraging filter 

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    19/33

    19

    of 

    19 nother (moothing &5amle

    @4 smoothing the original image "e get ridof lots of the finer detail "hich leaes onl4

    the gross features for thresholding

       I  m  a  g  e  s   t  a     e  n   f  r  o  m   =  o  n  z  a   l  e  z   >   W  o  o   d  s ,

       $   i  g   i   t  a   l   I  m  a

      g  e   %  r  o  c  e  s  s   i  n  g   '   2   0   0   2   *

    Original Image Smoothed Image Thresholded Image

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    20/33

    20

    of 

    19

     eraging )ilter As# Median )ilter

    &5amle

    )iltering is often used to remoe noise fromimages

    (ometimes a median filter "ors better than

    an aeraging filter 

    Original Image

    With Noise

    Image After 

    Averaging Filter 

    Image After 

    Median Filter 

       I  m  a  g  e  s   t  a     e  n   f  r  o  m   =  o  n  z  a   l  e  z   >   W  o  o   d  s ,

       $   i  g   i   t  a   l   I  m  a

      g  e   %  r  o  c  e  s  s   i  n  g   '   2   0   0   2   *

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    21/33

    21

    of 

    19

     eraging )ilter As# Median )ilter

    &5amle

       I  m  a  g  e  s   t  a     e  n   f  r  o  m   =  o  n  z  a   l  e  z   >   W  o  o   d  s ,

       $   i  g   i   t  a   l   I  m  a

      g  e   %  r  o  c  e  s  s   i  n  g   '   2   0   0   2   *

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    22/33

    22

    of 

    19

     eraging )ilter As# Median )ilter

    &5amle

       I  m  a  g  e  s   t  a     e  n   f  r  o  m   =  o  n  z  a   l  e  z   >   W  o  o   d  s ,

       $   i  g   i   t  a   l   I  m  a

      g  e   %  r  o  c  e  s  s   i  n  g   '   2   0   0   2   *

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    23/33

    2+

    of 

    19

     eraging )ilter As# Median )ilter

    &5amle

       I  m  a  g  e  s   t  a     e  n   f  r  o  m   =  o  n  z  a   l  e  z   >   W  o  o   d  s ,

       $   i  g   i   t  a   l   I  m  a

      g  e   %  r  o  c  e  s  s   i  n  g   '   2   0   0   2   *

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    24/33

    2

    of 

    19

    (imle /eighbourhood 3erations

    &5amle

    12+ 12 12; 119 117 1+0

    10 17 1; 17+ 16 12

    1++ 17 1;+ 192 19 191

    19 199 20 210 19; 197

    16 10 17 162 1+ 171

     x 

     y

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    25/33

    27

    of 

    19(trange 8hings Baen t 8he &dges

    Origin  x 

     y  Image f (x, y)

    e

    e

    e

    e

     t the edges of an image "e are missingi5els to form a neighbourhood

    e e

    e

    ( 8hi B 8h &d

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    26/33

    26

    of 

    19

    (trange 8hings Baen t 8he &dges

    'contD*

    8here are a fe" aroaches to dealing "ithmissing edge i5els:

     . 3mit missing i5els

    E 3nl4 "ors "ith some filtersE Can add e5tra code and slo" do"n rocessing

     . %ad the image

    E 84icall4 "ith either all "hite or all blac i5els

     . Relicate border i5els

     . 8runcate the image

     . llo" i5els wrap around  the image

    E Can cause some strange image artefacts

    (i l / i hb h d 3 ti

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    27/33

    2

    of 

    19

    (imle /eighbourhood 3erations

    &5amle

    12+ 12 12; 119 117 1+0

    10 17 1; 17+ 16 12

    1++ 17 1;+ 192 19 191

    19 199 20 210 19; 197

    16 10 17 162 1+ 171

     x 

     y

    (t 8hi B t 8h &d

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    28/33

    2;

    of 

    19

    (trange 8hings Baen t 8he &dges

    'contD*

    3riginal

    Image

    )iltered Image:

    Fero %adding

    )iltered Image:

    Relicate &dge %i5els

    )iltered Image:

    Wra round &dge %i5els

       I  m

      a  g  e  s   t  a     e  n   f  r  o  m   =  o  n  z  a   l  e  z   >   W  o  o   d  s ,

       $   i  g   i   t  a   l   I  m  a  g  e   %  r  o  c  e  s  s   i  n  g   '   2   0   0   2   *

    (t 8hi B t 8h &d

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    29/33

    29

    of 

    19

    (trange 8hings Baen t 8he &dges

    'contD*

       I  m

      a  g  e  s   t  a     e  n   f  r  o  m   =  o  n  z  a   l  e  z   >   W  o  o   d  s ,

       $   i  g   i   t  a   l   I  m  a  g  e   %  r  o  c  e  s  s   i  n  g   '   2   0   0   2   *

    (t 8hi B t 8h &d

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    30/33

    +0

    of 

    19

    (trange 8hings Baen t 8he &dges

    'contD*

       I  m

      a  g  e  s   t  a     e  n   f  r  o  m   =  o  n  z  a   l  e  z   >   W  o  o   d  s ,

       $   i  g   i   t  a   l   I  m  a  g  e   %  r  o  c  e  s  s   i  n  g   '   2   0   0   2   *

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    31/33

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    32/33

  • 8/9/2019 Image Processing 5-SpatialFiltering1.ppt

    33/33

    ++

    of 

    19(ummar4

    In this lecture "e hae looed at the idea ofsatial filtering and in articular:

     . /eighbourhood oerations

     . 8he filtering rocess

     . (moothing filters

     . $ealing "ith roblems at image edges "henusing filtering

     . Correlation and conolution/e5t time "e "ill looing at shareningfilters and more on filtering and image

    enhancement