SlideShare a Scribd company logo
1 of 33
Digital Image Processing



          Image Enhancement
            (Spatial Filtering 2)


    Course Website: http://www.comp.dit.ie/bmacnamee
2
of
30
                                           Contents
     In this lecture we will look at more spatial
     filtering techniques
        – Spatial filtering refresher
        – Sharpening filters
           • 1st derivative filters
           • 2nd derivative filters
        – Combining filtering techniques
3
 of
 30
                                Spatial Filtering Refresher
Origin                                     x
                                                 a    b   c          r     s      t
                                                 d
                                                 g
                                                      e
                                                      h
                                                           f
                                                           i
                                                                 *   u
                                                                     x
                                                                           v
                                                                           y
                                                                                  w
                                                                                  z
                                                Original Image           Filter
             Simple 3*3                             Pixels
                            e    3*3 Filter
         Neighbourhood
                                               eprocessed = v*e +
                                                            r*a + s*b + t*c +
                                                            u*d + w*f +
  y                       Image f (x, y)                    x*g + y*h + z*i

  The above is repeated for every pixel in the
  original image to generate the smoothed image
4
of
30
                    Sharpening Spatial Filters
     Previously we have looked at smoothing
     filters which remove fine detail
     Sharpening spatial filters seek to highlight
     fine detail
        – Remove blurring from images
        – Highlight edges
     Sharpening filters are based on spatial
     differentiation
5
                                                             of
                                                             30
                                                                                          Spatial Differentiation
                                                                      Differentiation measures the rate of change of
Images taken from Gonzalez & Woods, Digital Image Processing (2002)




                                                                      a function
                                                                      Let’s consider a simple 1 dimensional
                                                                      example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
                                                                      6
                                                                      of
                                                                      30




                                                   A
                                                   B
                                                                      Spatial Differentiation
7
of
30
                                      1st Derivative
     The formula for the 1st derivative of a
     function is as follows:
           ∂f
              = f ( x + 1) − f ( x)
           ∂x
     It’s just the difference between subsequent
     values and measures the rate of change of
     the function
8
of
30
                              1st Derivative (cont…)




     5 5 4 3 2 1 0 0 0 6 0 0 0 0 1 3 1 0 0 0 0 7 7 7 7

       0 -1 -1 -1 -1 0 0 6 -6 0 0 0 1 2 -2 -1 0 0 0 7 0 0 0
9
of
30
                                      2nd Derivative
     The formula for the 2nd derivative of a
     function is as follows:
           ∂ f
            2
               = f ( x + 1) + f ( x − 1) − 2 f ( x)
           ∂ x
            2

     Simply takes into account the values both
     before and after the current value
10
of
30
                                2nd Derivative (cont…)




     5 5 4 3 2 1 0 0 0 6 0 0 0 0 1 3 1 0 0 0 0 7 7 7 7

      -1 0 0 0 0 1 0 6   -12   6 0 0 1 1 -4 1 1 0 0 7 -7 0 0
11
of
           Using Second Derivatives For Image
30                              Enhancement
     The 2nd derivative is more useful for image
     enhancement than the 1st derivative
        – Stronger response to fine detail
        – Simpler implementation

     The first sharpening filter we will look at is
     the Laplacian
        – Isotropic
        – One of the simplest sharpening filters
        – We will look at a digital implementation
12
of
30
                                             The Laplacian
     The Laplacian is defined as follows:
                                ∂ f ∂ f
                                 2       2
                      ∇ f = 2 + 2
                         2

                                ∂ x ∂ y
     where the partial 1st order derivative in the x
     direction is defined as follows:
         ∂ f
          2
              = f ( x + 1, y ) + f ( x − 1, y ) − 2 f ( x, y )
         ∂ x
          2

     and in the y direction as follows:
         ∂ f
          2
              = f ( x, y + 1) + f ( x, y − 1) − 2 f ( x, y )
         ∂ y
          2
13
of
30
                           The Laplacian (cont…)
     So, the Laplacian can be given as follows:
      ∇ f = [ f ( x + 1, y ) + f ( x − 1, y )
        2


              + f ( x, y + 1) + f ( x, y − 1)]
              − 4 f ( x, y )
     We can easily build a filter based on this
                       0    1    0

                       1    -4   1

                       0    1    0
14
                                                             of
                                                             30
                                                                                        The Laplacian (cont…)
                                                                      Applying the Laplacian to an image we get a
Images taken from Gonzalez & Woods, Digital Image Processing (2002)




                                                                      new image that highlights edges and other
                                                                      discontinuities




                                                                             Original      Laplacian         Laplacian
                                                                             Image      Filtered Image    Filtered Image
                                                                                                         Scaled for Display
15
                                                             of
                                                             30
                                                                              But That Is Not Very Enhanced!
                                                                      The result of a Laplacian filtering
Images taken from Gonzalez & Woods, Digital Image Processing (2002)




                                                                      is not an enhanced image
                                                                      We have to do more work in
                                                                      order to get our final image
                                                                      Subtract the Laplacian result
                                                                                                                Laplacian
                                                                      from the original image to             Filtered Image
                                                                                                            Scaled for Display
                                                                      generate our final sharpened
                                                                      enhanced image
                                                                        g ( x, y ) = f ( x, y ) − ∇ f
                                                                                                  2
16
                                                             of
                                                             30
                                                                                Laplacian Image Enhancement
Images taken from Gonzalez & Woods, Digital Image Processing (2002)




                                                                                    -                    =
                                                                         Original          Laplacian         Sharpened
                                                                         Image          Filtered Image         Image

                                                                      In the final sharpened image edges and fine
                                                                      detail are much more obvious
Images taken from Gonzalez & Woods, Digital Image Processing (2002)


                                                                      of
                                                                      30
                                                                      17
                                                                      Laplacian Image Enhancement
18
of
30
              Simplified Image Enhancement
     The entire enhancement can be combined
     into a single filtering operation
      g ( x, y ) = f ( x, y ) − ∇ f
                                  2


               = f ( x, y ) − [ f ( x + 1, y ) + f ( x − 1, y )
                              + f ( x, y + 1) + f ( x, y − 1)
                             − 4 f ( x, y )]
                = 5 f ( x, y ) − f ( x + 1, y ) − f ( x − 1, y )
                               − f ( x, y + 1) − f ( x, y − 1)
19
                                                             of
                                                             30
                                                                        Simplified Image Enhancement (cont…)

                                                                      This gives us a new filter which does the
Images taken from Gonzalez & Woods, Digital Image Processing (2002)




                                                                      whole job for us in one step

                                                                                        0    -1   0

                                                                                        -1   5    -1

                                                                                        0    -1   0
Images taken from Gonzalez & Woods, Digital Image Processing (2002)


                                                                      of
                                                                      30
                                                                      20
                                                                      Simplified Image Enhancement (cont…)
21
                                                             of
                                                             30
                                                                          Variants On The Simple Laplacian
                                                                      There are lots of slightly different versions of
Images taken from Gonzalez & Woods, Digital Image Processing (2002)




                                                                      the Laplacian that can be used:
                                                                           0   1    0                 1    1    1
                                                                                        Simple                      Variant of
                                                                           1   -4   1                 1    -8   1
                                                                                        Laplacian                   Laplacian
                                                                           0   1    0                 1    1    1


                                                                                            -1   -1   -1

                                                                                            -1   9    -1

                                                                                            -1   -1   -1
22
of
30
            Simple Convolution Tool In Java
     A great tool for testing out different filters
        – From the book “Image Processing tools in
          Java”
        – Available from webCT later on today
        – To launch: java ConvolutionTool Moon.jpg
23
of
30
                           1st Derivative Filtering
     Implementing 1st derivative filters is difficult in
     practice
     For a function f(x, y) the gradient of f at
     coordinates (x, y) is given as the column
     vector:
                                  ∂f 
                          Gx   ∂x 
                     ∇f =   =  ∂f 
                          G y   
                                  ∂y 
                                  
24
of
30
              1st Derivative Filtering (cont…)
     The magnitude of this vector is given by:
                 ∇f = mag (∇f )
                      [
                    = G +G2
                          x
                                  2
                                  y   ]   1
                                              2

                                                      1
                       ∂f   ∂f  
                              2                   2       2

                    =   +   
                       ∂x   ∂y  
                                
                      
     For practical reasons this can be simplified as:
                     ∇f ≈ G x + G y
25
of
30
               1st Derivative Filtering (cont…)
     There is some debate as to how best to
     calculate these gradients but we will use:
            ∇f ≈ ( z7 + 2 z8 + z9 ) − ( z1 + 2 z 2 + z3 )
                + ( z3 + 2 z6 + z9 ) − ( z1 + 2 z 4 + z7 )
     which is based on these coordinates
                            z1   z2    z3

                            z4   z5    z6

                            z7   z8    z9
26
of
30
                                  Sobel Operators
     Based on the previous equations we can
     derive the Sobel Operators
               -1   -2   -1     -1   0   1

                0   0    0      -2   0   2

                1   2    1      -1   0   1

     To filter an image it is filtered using both
     operators the results of which are added
     together
27
                                                             of
                                                             30
                                                                                                   Sobel Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)




                                                                                                         An image of a
                                                                                                         contact lens which
                                                                                                         is enhanced in
                                                                                                         order to make
                                                                                                         defects (at four
                                                                                                         and five o’clock in
                                                                                                         the image) more
                                                                                                         obvious


                                                                      Sobel filters are typically used for edge
                                                                      detection
28
of
30
                              1st & 2nd Derivatives
     Comparing the 1st and 2nd derivatives we
     can conclude the following:
       – 1st order derivatives generally produce thicker
         edges
       – 2nd order derivatives have a stronger
         response to fine detail e.g. thin lines
       – 1st order derivatives have stronger response
         to grey level step
       – 2nd order derivatives produce a double
         response at step changes in grey level
29
of
30
                                           Summary
     In this lecture we looked at:
        – Sharpening filters
           • 1st derivative filters
           • 2nd derivative filters
        – Combining filtering techniques
30
                                                             of
                                                                               Combining Spatial Enhancement
                                                             30                                      Methods
                                                                      Successful image
Images taken from Gonzalez & Woods, Digital Image Processing (2002)




                                                                      enhancement is typically
                                                                      not achieved using a single
                                                                      operation
                                                                      Rather we combine a range
                                                                      of techniques in order to
                                                                      achieve a final result
                                                                      This example will focus on
                                                                      enhancing the bone scan to
                                                                      the right
31
                                                             of
                                                                                         Combining Spatial Enhancement
                                                             30                                       Methods (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)




                                                                           (a)
                                                                      Laplacian filter   of
                                                                      bone scan (a)
                                                                                                    (b)
                                                                                              Sharpened version of
                                                                                              bone scan achieved         (c)
                                                                                              by subtracting (a)
                                                                                              and (b)              Sobel filter of bone
                                                                                                                   scan (a)               (d)
32
                                                             of
                                                                                        Combining Spatial Enhancement
                                                             30                                      Methods (cont…)
                                                                                                                  Result of applying a   (h)
                                                                                                                  power-law trans. to
Images taken from Gonzalez & Woods, Digital Image Processing (2002)




                                                                                              Sharpened image (g)
                                                                                              which is sum of (a)
                                                                                              and (f)                  (g)
                                                                      The product of (c)
                                                                      and (e) which will be        (f)
                                                                      used as a mask
                                                                            (e)




                                                                      Image (d) smoothed with
                                                                      a 5*5 averaging filter
33
                                                             of
                                                                               Combining Spatial Enhancement
                                                             30                             Methods (cont…)
                                                                      Compare the original and final images
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

More Related Content

What's hot

5 spatial filtering p1
5 spatial filtering p15 spatial filtering p1
5 spatial filtering p1Gichelle Amon
 
Image enhancement techniques
Image enhancement techniquesImage enhancement techniques
Image enhancement techniquessakshij91
 
Image Enhancement in Spatial Domain
Image Enhancement in Spatial DomainImage Enhancement in Spatial Domain
Image Enhancement in Spatial DomainA B Shinde
 
Enhancement in frequency domain
Enhancement in frequency domainEnhancement in frequency domain
Enhancement in frequency domainAshish Kumar
 
Chapter 9 morphological image processing
Chapter 9   morphological image processingChapter 9   morphological image processing
Chapter 9 morphological image processingAhmed Daoud
 
morphological image processing
morphological image processingmorphological image processing
morphological image processingJohn Williams
 
Erosion and dilation
Erosion and dilationErosion and dilation
Erosion and dilationAkhil .B
 
Image Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain FiltersImage Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain FiltersKarthika Ramachandran
 
Chapter 8 image compression
Chapter 8 image compressionChapter 8 image compression
Chapter 8 image compressionasodariyabhavesh
 
Digital image processing img smoothning
Digital image processing img smoothningDigital image processing img smoothning
Digital image processing img smoothningVinay Gupta
 
Image Restoration (Frequency Domain Filters):Basics
Image Restoration (Frequency Domain Filters):BasicsImage Restoration (Frequency Domain Filters):Basics
Image Restoration (Frequency Domain Filters):BasicsKalyan Acharjya
 
Image Restoration
Image RestorationImage Restoration
Image RestorationPoonam Seth
 
Digital Image Fundamentals
Digital Image FundamentalsDigital Image Fundamentals
Digital Image FundamentalsA B Shinde
 

What's hot (20)

5 spatial filtering p1
5 spatial filtering p15 spatial filtering p1
5 spatial filtering p1
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
Image enhancement techniques
Image enhancement techniquesImage enhancement techniques
Image enhancement techniques
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Image Enhancement in Spatial Domain
Image Enhancement in Spatial DomainImage Enhancement in Spatial Domain
Image Enhancement in Spatial Domain
 
Enhancement in frequency domain
Enhancement in frequency domainEnhancement in frequency domain
Enhancement in frequency domain
 
Chapter 9 morphological image processing
Chapter 9   morphological image processingChapter 9   morphological image processing
Chapter 9 morphological image processing
 
Image segmentation
Image segmentation Image segmentation
Image segmentation
 
morphological image processing
morphological image processingmorphological image processing
morphological image processing
 
Erosion and dilation
Erosion and dilationErosion and dilation
Erosion and dilation
 
Chap6 image restoration
Chap6 image restorationChap6 image restoration
Chap6 image restoration
 
Spatial domain and filtering
Spatial domain and filteringSpatial domain and filtering
Spatial domain and filtering
 
Image Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain FiltersImage Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain Filters
 
Chapter 8 image compression
Chapter 8 image compressionChapter 8 image compression
Chapter 8 image compression
 
Digital image processing img smoothning
Digital image processing img smoothningDigital image processing img smoothning
Digital image processing img smoothning
 
Morphological image processing
Morphological image processingMorphological image processing
Morphological image processing
 
Image Restoration (Frequency Domain Filters):Basics
Image Restoration (Frequency Domain Filters):BasicsImage Restoration (Frequency Domain Filters):Basics
Image Restoration (Frequency Domain Filters):Basics
 
SPATIAL FILTER
SPATIAL FILTERSPATIAL FILTER
SPATIAL FILTER
 
Image Restoration
Image RestorationImage Restoration
Image Restoration
 
Digital Image Fundamentals
Digital Image FundamentalsDigital Image Fundamentals
Digital Image Fundamentals
 

Viewers also liked

Image processing spatialfiltering
Image processing spatialfilteringImage processing spatialfiltering
Image processing spatialfilteringJohn Williams
 
Digital Image Processing
Digital Image ProcessingDigital Image Processing
Digital Image ProcessingSahil Biswas
 
LAPLACE TRANSFORM SUITABILITY FOR IMAGE PROCESSING
LAPLACE TRANSFORM SUITABILITY FOR IMAGE PROCESSINGLAPLACE TRANSFORM SUITABILITY FOR IMAGE PROCESSING
LAPLACE TRANSFORM SUITABILITY FOR IMAGE PROCESSINGPriyanka Rathore
 
Mathematical operations in image processing
Mathematical operations in image processingMathematical operations in image processing
Mathematical operations in image processingAsad Ali
 
06 spatial filtering DIP
06 spatial filtering DIP06 spatial filtering DIP
06 spatial filtering DIPbabak danyal
 
Chapter 3 image enhancement (spatial domain)
Chapter 3 image enhancement (spatial domain)Chapter 3 image enhancement (spatial domain)
Chapter 3 image enhancement (spatial domain)asodariyabhavesh
 
Image enhancement
Image enhancementImage enhancement
Image enhancementAyaelshiwi
 
Digital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency DomainDigital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency DomainMostafa G. M. Mostafa
 
Image Enhancement in Spatial Domain
Image Enhancement in Spatial DomainImage Enhancement in Spatial Domain
Image Enhancement in Spatial DomainDEEPASHRI HK
 
Frequency Domain Image Enhancement Techniques
Frequency Domain Image Enhancement TechniquesFrequency Domain Image Enhancement Techniques
Frequency Domain Image Enhancement TechniquesDiwaker Pant
 
Matlab Image Enhancement Techniques
Matlab Image Enhancement TechniquesMatlab Image Enhancement Techniques
Matlab Image Enhancement TechniquesDataminingTools Inc
 
Image enhancement techniques
Image enhancement techniquesImage enhancement techniques
Image enhancement techniquesSaideep
 
Image processing
Image processingImage processing
Image processingVarun Raj
 
Introduction to digital image processing
Introduction to digital image processingIntroduction to digital image processing
Introduction to digital image processingHossain Md Shakhawat
 
Digital Image Processing - Image Enhancement
Digital Image Processing  - Image EnhancementDigital Image Processing  - Image Enhancement
Digital Image Processing - Image EnhancementMathankumar S
 
Image processing
Image processingImage processing
Image processingPooja G N
 

Viewers also liked (20)

2.spatial filtering
2.spatial filtering2.spatial filtering
2.spatial filtering
 
Image processing spatialfiltering
Image processing spatialfilteringImage processing spatialfiltering
Image processing spatialfiltering
 
Kerberos
KerberosKerberos
Kerberos
 
Digital Image Processing
Digital Image ProcessingDigital Image Processing
Digital Image Processing
 
LAPLACE TRANSFORM SUITABILITY FOR IMAGE PROCESSING
LAPLACE TRANSFORM SUITABILITY FOR IMAGE PROCESSINGLAPLACE TRANSFORM SUITABILITY FOR IMAGE PROCESSING
LAPLACE TRANSFORM SUITABILITY FOR IMAGE PROCESSING
 
Mathematical operations in image processing
Mathematical operations in image processingMathematical operations in image processing
Mathematical operations in image processing
 
06 spatial filtering DIP
06 spatial filtering DIP06 spatial filtering DIP
06 spatial filtering DIP
 
Chapter 3 image enhancement (spatial domain)
Chapter 3 image enhancement (spatial domain)Chapter 3 image enhancement (spatial domain)
Chapter 3 image enhancement (spatial domain)
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
Digital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency DomainDigital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency Domain
 
Image Enhancement in Spatial Domain
Image Enhancement in Spatial DomainImage Enhancement in Spatial Domain
Image Enhancement in Spatial Domain
 
Frequency Domain Image Enhancement Techniques
Frequency Domain Image Enhancement TechniquesFrequency Domain Image Enhancement Techniques
Frequency Domain Image Enhancement Techniques
 
Matlab Image Enhancement Techniques
Matlab Image Enhancement TechniquesMatlab Image Enhancement Techniques
Matlab Image Enhancement Techniques
 
Image enhancement techniques
Image enhancement techniquesImage enhancement techniques
Image enhancement techniques
 
Image processing
Image processingImage processing
Image processing
 
Introduction to digital image processing
Introduction to digital image processingIntroduction to digital image processing
Introduction to digital image processing
 
Network security
Network securityNetwork security
Network security
 
Digital Image Processing - Image Enhancement
Digital Image Processing  - Image EnhancementDigital Image Processing  - Image Enhancement
Digital Image Processing - Image Enhancement
 
Lec1 final
Lec1 finalLec1 final
Lec1 final
 
Image processing
Image processingImage processing
Image processing
 

Similar to 6 spatial filtering p2

Fourier basics
Fourier basicsFourier basics
Fourier basicsNGHIPHAM14
 
Spatial domain filtering.ppt
Spatial domain filtering.pptSpatial domain filtering.ppt
Spatial domain filtering.pptssuser4bbfb1
 
Calculusseveralvariables.ppt
Calculusseveralvariables.pptCalculusseveralvariables.ppt
Calculusseveralvariables.pptssuser055963
 
Bahan ajar kalkulus integral
Bahan ajar kalkulus integralBahan ajar kalkulus integral
Bahan ajar kalkulus integralgrand_livina_good
 
01. Differentiation-Theory & solved example Module-3.pdf
01. Differentiation-Theory & solved example Module-3.pdf01. Differentiation-Theory & solved example Module-3.pdf
01. Differentiation-Theory & solved example Module-3.pdfRajuSingh806014
 
Partial Differentiation & Application
Partial Differentiation & Application Partial Differentiation & Application
Partial Differentiation & Application Yana Qlah
 
9-Functions.pptx
9-Functions.pptx9-Functions.pptx
9-Functions.pptxjaffarbikat
 
monotonicity thoery & solved & execise Module-4.pdf
monotonicity thoery & solved & execise Module-4.pdfmonotonicity thoery & solved & execise Module-4.pdf
monotonicity thoery & solved & execise Module-4.pdfRajuSingh806014
 
CSE367 Lecture- image sinal processing lecture
CSE367 Lecture- image sinal processing lectureCSE367 Lecture- image sinal processing lecture
CSE367 Lecture- image sinal processing lectureFatmaNewagy1
 
chAPTER1CV.pptx is abouter computer vision in artificial intelligence
chAPTER1CV.pptx is abouter computer vision in artificial intelligencechAPTER1CV.pptx is abouter computer vision in artificial intelligence
chAPTER1CV.pptx is abouter computer vision in artificial intelligenceshesnasuneer
 
computervision1.pptx its about computer vision
computervision1.pptx its about computer visioncomputervision1.pptx its about computer vision
computervision1.pptx its about computer visionshesnasuneer
 
interpolation-190605141327 (1).pptx
interpolation-190605141327 (1).pptxinterpolation-190605141327 (1).pptx
interpolation-190605141327 (1).pptxsinghakhil952
 
interpolation-190605141327 (1).pptx
interpolation-190605141327 (1).pptxinterpolation-190605141327 (1).pptx
interpolation-190605141327 (1).pptxsinghakhil952
 
Lesson 2: A Catalog of Essential Functions
Lesson 2: A Catalog of Essential FunctionsLesson 2: A Catalog of Essential Functions
Lesson 2: A Catalog of Essential FunctionsMatthew Leingang
 

Similar to 6 spatial filtering p2 (20)

Fourier basics
Fourier basicsFourier basics
Fourier basics
 
Spatial domain filtering.ppt
Spatial domain filtering.pptSpatial domain filtering.ppt
Spatial domain filtering.ppt
 
Calculusseveralvariables.ppt
Calculusseveralvariables.pptCalculusseveralvariables.ppt
Calculusseveralvariables.ppt
 
Bahan ajar kalkulus integral
Bahan ajar kalkulus integralBahan ajar kalkulus integral
Bahan ajar kalkulus integral
 
01. Differentiation-Theory & solved example Module-3.pdf
01. Differentiation-Theory & solved example Module-3.pdf01. Differentiation-Theory & solved example Module-3.pdf
01. Differentiation-Theory & solved example Module-3.pdf
 
Partial Differentiation & Application
Partial Differentiation & Application Partial Differentiation & Application
Partial Differentiation & Application
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
gfg
gfggfg
gfg
 
9-Functions.pptx
9-Functions.pptx9-Functions.pptx
9-Functions.pptx
 
Functions (Theory)
Functions (Theory)Functions (Theory)
Functions (Theory)
 
monotonicity thoery & solved & execise Module-4.pdf
monotonicity thoery & solved & execise Module-4.pdfmonotonicity thoery & solved & execise Module-4.pdf
monotonicity thoery & solved & execise Module-4.pdf
 
CSE367 Lecture- image sinal processing lecture
CSE367 Lecture- image sinal processing lectureCSE367 Lecture- image sinal processing lecture
CSE367 Lecture- image sinal processing lecture
 
Functions
FunctionsFunctions
Functions
 
Derivatives
DerivativesDerivatives
Derivatives
 
chAPTER1CV.pptx is abouter computer vision in artificial intelligence
chAPTER1CV.pptx is abouter computer vision in artificial intelligencechAPTER1CV.pptx is abouter computer vision in artificial intelligence
chAPTER1CV.pptx is abouter computer vision in artificial intelligence
 
computervision1.pptx its about computer vision
computervision1.pptx its about computer visioncomputervision1.pptx its about computer vision
computervision1.pptx its about computer vision
 
PPT s04-machine vision-s2
PPT s04-machine vision-s2PPT s04-machine vision-s2
PPT s04-machine vision-s2
 
interpolation-190605141327 (1).pptx
interpolation-190605141327 (1).pptxinterpolation-190605141327 (1).pptx
interpolation-190605141327 (1).pptx
 
interpolation-190605141327 (1).pptx
interpolation-190605141327 (1).pptxinterpolation-190605141327 (1).pptx
interpolation-190605141327 (1).pptx
 
Lesson 2: A Catalog of Essential Functions
Lesson 2: A Catalog of Essential FunctionsLesson 2: A Catalog of Essential Functions
Lesson 2: A Catalog of Essential Functions
 

More from Gichelle Amon (20)

Os module 2 d
Os module 2 dOs module 2 d
Os module 2 d
 
Os module 2 c
Os module 2 cOs module 2 c
Os module 2 c
 
Image segmentation ppt
Image segmentation pptImage segmentation ppt
Image segmentation ppt
 
Lec3 final
Lec3 finalLec3 final
Lec3 final
 
Lec 3
Lec 3Lec 3
Lec 3
 
Lec2 final
Lec2 finalLec2 final
Lec2 final
 
Lec 4
Lec 4Lec 4
Lec 4
 
Module 3 law of contracts
Module 3  law of contractsModule 3  law of contracts
Module 3 law of contracts
 
Transport triggered architecture
Transport triggered architectureTransport triggered architecture
Transport triggered architecture
 
Time triggered arch.
Time triggered arch.Time triggered arch.
Time triggered arch.
 
Subnetting
SubnettingSubnetting
Subnetting
 
Os module 2 c
Os module 2 cOs module 2 c
Os module 2 c
 
Os module 2 ba
Os module 2 baOs module 2 ba
Os module 2 ba
 
Lec5
Lec5Lec5
Lec5
 
Delivery
DeliveryDelivery
Delivery
 
Addressing
AddressingAddressing
Addressing
 
Medical image analysis
Medical image analysisMedical image analysis
Medical image analysis
 
Presentation2
Presentation2Presentation2
Presentation2
 
Harvard architecture
Harvard architectureHarvard architecture
Harvard architecture
 
Micro channel architecture
Micro channel architectureMicro channel architecture
Micro channel architecture
 

6 spatial filtering p2

  • 1. Digital Image Processing Image Enhancement (Spatial Filtering 2) Course Website: http://www.comp.dit.ie/bmacnamee
  • 2. 2 of 30 Contents In this lecture we will look at more spatial filtering techniques – Spatial filtering refresher – Sharpening filters • 1st derivative filters • 2nd derivative filters – Combining filtering techniques
  • 3. 3 of 30 Spatial Filtering Refresher Origin x a b c r s t d g e h f i * u x v y w z Original Image Filter Simple 3*3 Pixels e 3*3 Filter Neighbourhood eprocessed = v*e + r*a + s*b + t*c + u*d + w*f + y Image f (x, y) x*g + y*h + z*i The above is repeated for every pixel in the original image to generate the smoothed image
  • 4. 4 of 30 Sharpening Spatial Filters Previously we have looked at smoothing filters which remove fine detail Sharpening spatial filters seek to highlight fine detail – Remove blurring from images – Highlight edges Sharpening filters are based on spatial differentiation
  • 5. 5 of 30 Spatial Differentiation Differentiation measures the rate of change of Images taken from Gonzalez & Woods, Digital Image Processing (2002) a function Let’s consider a simple 1 dimensional example
  • 6. Images taken from Gonzalez & Woods, Digital Image Processing (2002) 6 of 30 A B Spatial Differentiation
  • 7. 7 of 30 1st Derivative The formula for the 1st derivative of a function is as follows: ∂f = f ( x + 1) − f ( x) ∂x It’s just the difference between subsequent values and measures the rate of change of the function
  • 8. 8 of 30 1st Derivative (cont…) 5 5 4 3 2 1 0 0 0 6 0 0 0 0 1 3 1 0 0 0 0 7 7 7 7 0 -1 -1 -1 -1 0 0 6 -6 0 0 0 1 2 -2 -1 0 0 0 7 0 0 0
  • 9. 9 of 30 2nd Derivative The formula for the 2nd derivative of a function is as follows: ∂ f 2 = f ( x + 1) + f ( x − 1) − 2 f ( x) ∂ x 2 Simply takes into account the values both before and after the current value
  • 10. 10 of 30 2nd Derivative (cont…) 5 5 4 3 2 1 0 0 0 6 0 0 0 0 1 3 1 0 0 0 0 7 7 7 7 -1 0 0 0 0 1 0 6 -12 6 0 0 1 1 -4 1 1 0 0 7 -7 0 0
  • 11. 11 of Using Second Derivatives For Image 30 Enhancement The 2nd derivative is more useful for image enhancement than the 1st derivative – Stronger response to fine detail – Simpler implementation The first sharpening filter we will look at is the Laplacian – Isotropic – One of the simplest sharpening filters – We will look at a digital implementation
  • 12. 12 of 30 The Laplacian The Laplacian is defined as follows: ∂ f ∂ f 2 2 ∇ f = 2 + 2 2 ∂ x ∂ y where the partial 1st order derivative in the x direction is defined as follows: ∂ f 2 = f ( x + 1, y ) + f ( x − 1, y ) − 2 f ( x, y ) ∂ x 2 and in the y direction as follows: ∂ f 2 = f ( x, y + 1) + f ( x, y − 1) − 2 f ( x, y ) ∂ y 2
  • 13. 13 of 30 The Laplacian (cont…) So, the Laplacian can be given as follows: ∇ f = [ f ( x + 1, y ) + f ( x − 1, y ) 2 + f ( x, y + 1) + f ( x, y − 1)] − 4 f ( x, y ) We can easily build a filter based on this 0 1 0 1 -4 1 0 1 0
  • 14. 14 of 30 The Laplacian (cont…) Applying the Laplacian to an image we get a Images taken from Gonzalez & Woods, Digital Image Processing (2002) new image that highlights edges and other discontinuities Original Laplacian Laplacian Image Filtered Image Filtered Image Scaled for Display
  • 15. 15 of 30 But That Is Not Very Enhanced! The result of a Laplacian filtering Images taken from Gonzalez & Woods, Digital Image Processing (2002) is not an enhanced image We have to do more work in order to get our final image Subtract the Laplacian result Laplacian from the original image to Filtered Image Scaled for Display generate our final sharpened enhanced image g ( x, y ) = f ( x, y ) − ∇ f 2
  • 16. 16 of 30 Laplacian Image Enhancement Images taken from Gonzalez & Woods, Digital Image Processing (2002) - = Original Laplacian Sharpened Image Filtered Image Image In the final sharpened image edges and fine detail are much more obvious
  • 17. Images taken from Gonzalez & Woods, Digital Image Processing (2002) of 30 17 Laplacian Image Enhancement
  • 18. 18 of 30 Simplified Image Enhancement The entire enhancement can be combined into a single filtering operation g ( x, y ) = f ( x, y ) − ∇ f 2 = f ( x, y ) − [ f ( x + 1, y ) + f ( x − 1, y ) + f ( x, y + 1) + f ( x, y − 1) − 4 f ( x, y )] = 5 f ( x, y ) − f ( x + 1, y ) − f ( x − 1, y ) − f ( x, y + 1) − f ( x, y − 1)
  • 19. 19 of 30 Simplified Image Enhancement (cont…) This gives us a new filter which does the Images taken from Gonzalez & Woods, Digital Image Processing (2002) whole job for us in one step 0 -1 0 -1 5 -1 0 -1 0
  • 20. Images taken from Gonzalez & Woods, Digital Image Processing (2002) of 30 20 Simplified Image Enhancement (cont…)
  • 21. 21 of 30 Variants On The Simple Laplacian There are lots of slightly different versions of Images taken from Gonzalez & Woods, Digital Image Processing (2002) the Laplacian that can be used: 0 1 0 1 1 1 Simple Variant of 1 -4 1 1 -8 1 Laplacian Laplacian 0 1 0 1 1 1 -1 -1 -1 -1 9 -1 -1 -1 -1
  • 22. 22 of 30 Simple Convolution Tool In Java A great tool for testing out different filters – From the book “Image Processing tools in Java” – Available from webCT later on today – To launch: java ConvolutionTool Moon.jpg
  • 23. 23 of 30 1st Derivative Filtering Implementing 1st derivative filters is difficult in practice For a function f(x, y) the gradient of f at coordinates (x, y) is given as the column vector:  ∂f  Gx   ∂x  ∇f =   =  ∂f  G y     ∂y   
  • 24. 24 of 30 1st Derivative Filtering (cont…) The magnitude of this vector is given by: ∇f = mag (∇f ) [ = G +G2 x 2 y ] 1 2 1  ∂f   ∂f   2 2 2 =   +     ∂x   ∂y       For practical reasons this can be simplified as: ∇f ≈ G x + G y
  • 25. 25 of 30 1st Derivative Filtering (cont…) There is some debate as to how best to calculate these gradients but we will use: ∇f ≈ ( z7 + 2 z8 + z9 ) − ( z1 + 2 z 2 + z3 ) + ( z3 + 2 z6 + z9 ) − ( z1 + 2 z 4 + z7 ) which is based on these coordinates z1 z2 z3 z4 z5 z6 z7 z8 z9
  • 26. 26 of 30 Sobel Operators Based on the previous equations we can derive the Sobel Operators -1 -2 -1 -1 0 1 0 0 0 -2 0 2 1 2 1 -1 0 1 To filter an image it is filtered using both operators the results of which are added together
  • 27. 27 of 30 Sobel Example Images taken from Gonzalez & Woods, Digital Image Processing (2002) An image of a contact lens which is enhanced in order to make defects (at four and five o’clock in the image) more obvious Sobel filters are typically used for edge detection
  • 28. 28 of 30 1st & 2nd Derivatives Comparing the 1st and 2nd derivatives we can conclude the following: – 1st order derivatives generally produce thicker edges – 2nd order derivatives have a stronger response to fine detail e.g. thin lines – 1st order derivatives have stronger response to grey level step – 2nd order derivatives produce a double response at step changes in grey level
  • 29. 29 of 30 Summary In this lecture we looked at: – Sharpening filters • 1st derivative filters • 2nd derivative filters – Combining filtering techniques
  • 30. 30 of Combining Spatial Enhancement 30 Methods Successful image Images taken from Gonzalez & Woods, Digital Image Processing (2002) enhancement is typically not achieved using a single operation Rather we combine a range of techniques in order to achieve a final result This example will focus on enhancing the bone scan to the right
  • 31. 31 of Combining Spatial Enhancement 30 Methods (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) (a) Laplacian filter of bone scan (a) (b) Sharpened version of bone scan achieved (c) by subtracting (a) and (b) Sobel filter of bone scan (a) (d)
  • 32. 32 of Combining Spatial Enhancement 30 Methods (cont…) Result of applying a (h) power-law trans. to Images taken from Gonzalez & Woods, Digital Image Processing (2002) Sharpened image (g) which is sum of (a) and (f) (g) The product of (c) and (e) which will be (f) used as a mask (e) Image (d) smoothed with a 5*5 averaging filter
  • 33. 33 of Combining Spatial Enhancement 30 Methods (cont…) Compare the original and final images Images taken from Gonzalez & Woods, Digital Image Processing (2002)