SlideShare une entreprise Scribd logo
1  sur  45
Télécharger pour lire hors ligne
Robert Collins
CSE486, Penn State




                            Lecture 4:
                            Smoothing

             Related text is T&V Section 2.3.3 and Chapter 3
Robert Collins
CSE486, Penn State
                     Summary about Convolution
    Computing a linear operator in neighborhoods centered at each
    pixel. Can be thought of as sliding a kernel of fixed coefficients
    over the image, and doing a weighted sum in the area of overlap.

     things to take note of:
       full : compute a value for any overlap between kernel and image
                (resulting image is bigger than the original)
      same: compute values only when center pixel of kernel aligns with a pixel in
                the image (resulting image is same size as original)

      convolution : kernel gets rotated 180 degrees before sliding over the image
      cross-correlation: kernel does not get rotated first

      border handling methods : defining values for pixels off the image
Robert Collins
CSE486, Penn State
                     Problem: Derivatives and Noise




M.Hebert, CMU
Robert Collins
CSE486, Penn State
                     Problem: Derivatives and Noise
         •First derivative operator is affected by noise
                 Increasing noise




         • Numerical derivatives can amplify noise!
            (particularly higher order derivatives)



M.Nicolescu, UNR
Robert Collins
CSE486, Penn State
                                     Image Noise

         • Fact: Images are noisy
         • Noise is anything in the image that we are
           not interested in
         • Examples:
              –   Light fluctuations
              –   Sensor noise
              –   Quantization effects
              –   Finite precision




  O.Camps, PSU
Robert Collins
CSE486, Penn State
                       Modeling Image Noise
         Simple model: additive RANDOM noise

         I(x,y) = s(x,y) + ni
           Where s(x,y) is the deterministic signal
           ni is a random variable
                                                      Note: This really
         Common Assumptions:                          only models the
           n is i.i.d for all pixels                  sensor noise.
           n is zero-mean Gaussian (normal)
           E(n) = 0 var(n) = σ2
           E(ni nj) = 0 (independence)



  O.Camps, PSU
Robert Collins
CSE486, Penn State    Example: Additive Gaussian Noise
                            mean 0, sigma = 16




  Forsyth and Ponce
Robert Collins
CSE486, Penn State
                     Empirical Evidence




                                Mean = 164 Std = 1.8
Robert Collins
CSE486, Penn State
                           Other Noise Models
          We won’t cover them. Just be aware they exist!!


      •Multiplicative noise:                            ˆ
                                            I (i, j ) = I (i, j ) ⋅N (i, j )

      •Impulse (“shot”) noise (aka salt and pepper):
                                       ˆ
                                        I (i, j ) if x < l
                     I (i, j ) =                                      See Textbook
                                 imin + y (imax − imin ) x ≥ l




  O.Camps, PSU
Robert Collins
CSE486, Penn State
                     Smoothing Reduces Noise

     From Numerical Recipes in C:

       The premise of data smoothing is that one is measuring
       a variable that is both slowly varying and also corrupted
       by random noise. Then it can sometimes be useful to
       replace each data point by some kind of local average of
       surrounding data points. Since nearby points measure
       very nearly the same underlying value, averaging can
       reduce the level of noise without (much) biasing the
       value obtained.
Robert Collins
CSE486, Penn State
                     Today: Smoothing Reduces Noise
              Image patch              Noisy surface




                                          smoothing reduces noise,
                                          giving us (perhaps) a more
                                          accurate intensity surface.
Robert Collins
CSE486, Penn State
                                Preview

         • We will talk about two smoothing filters
              – Box filter (simple averaging)
              – Gaussian filter (center pixels weighted more)
Robert Collins
CSE486, Penn State
                       Averaging / Box Filter
       • Mask with positive
         entries that sum to 1.
                                                  Box filter
       • Replaces each pixel
         with an average of its
                                                 1     1   1
         neighborhood.
       • Since all weights are               1/9 1     1   1
         equal, it is called a                   1     1   1
         BOX filter.
          important point:
                since this is a linear operator, we can take the
                average around each pixel by convolving the
                image with this 3x3 filter!
O.Camps, PSU
Robert Collins
CSE486, Penn State
                     Why Averaging Reduces Noise
       • Intuitive explanation: variance of noise in the average
         is smaller than variance of the pixel noise (assuming
         zero-mean Gaussian noise).

       • Sketch of more rigorous explanation:




  O.Camps, PSU
Robert Collins
CSE486, Penn State
                       Smoothing with Box Filter
                     original       Convolved with 11x11 box filter




               Drawback: smoothing reduces fine image detail
Robert Collins

                Important Point about Smoothing
CSE486, Penn State




       Averaging attenuates noise (reduces the variance),
       leading to a more “accurate” estimate.

       However, the more accurate estimate is of the mean of
       a local pixel neighborhood! This might not be what
       you want.

       Balancing act: smooth enough to “clean up” the noise,
       but not so much as to remove important image gradients.
Robert Collins
CSE486, Penn State
                     Gaussian Smoothing Filter
         • a case of weighted averaging
              – The coefficients are a 2D Gaussian.
              – Gives more weight at the central pixels and less
                weights to the neighbors.
              – The farther away the neighbors, the smaller the
                weight.




         Confusion alert: there are now two Gaussians being discussed
         here (one for noise, one for smoothing). They are different.
  O.Camps, PSU
Robert Collins
CSE486, Penn State
                     Gaussian Smoothing Filter
        An isotropic (circularly symmetric) Gaussian:
Robert Collins
CSE486, Penn State
                                          In Matlab
             >> sigma = 1

             sigma =

                     1

             >> halfwid = 3*sigma

             halfwid =

                     3

             >> [xx,yy] = meshgrid(-halfwid:halfwid, -halfwid:halfwid);
             >> tmp = exp(-1/(2*sigma^2) * (xx.^2 + yy.^2))

             tmp =

                     0.0001   0.0015   0.0067   0.0111   0.0067    0.0015   0.0001
                     0.0015   0.0183   0.0821   0.1353   0.0821    0.0183   0.0015
                     0.0067   0.0821   0.3679   0.6065   0.3679    0.0821   0.0067
                     0.0111   0.1353   0.6065   1.0000   0.6065    0.1353   0.0111
                     0.0067   0.0821   0.3679   0.6065   0.3679    0.0821   0.0067
                     0.0015   0.0183   0.0821   0.1353   0.0821    0.0183   0.0015
                     0.0001   0.0015   0.0067   0.0111   0.0067    0.0015   0.0001


           Note: we have not included the normalization constant.
           Values of a Gaussian should sum to one. However, it’s
           OK to ignore the constant since you can divide by it later.
Robert Collins
CSE486, Penn State
                         Gaussian Smoothing Filter
             >> sigma = 1

             sigma =

                     1

             >> halfwid = 3*sigma

             halfwid =

                  3
             >> [xx,yy] = meshgrid(-halfwid:halfwid, -halfwid:halfwid);
             >> gau = exp(-1/(2*sigma^2) * (xx.^2 + yy.^2))

             gau =

                 0.0001     0.0015   0.0067    0.0111    0.0067    0.0015   0.0001
                 0.0015     0.0183   0.0821    0.1353    0.0821    0.0183   0.0015
                 0.0067     0.0821   0.3679    0.6065    0.3679    0.0821   0.0067
                 0.0111     0.1353   0.6065    1.0000    0.6065    0.1353   0.0111
                 0.0067     0.0821   0.3679    0.6065    0.3679    0.0821   0.0067
                 0.0015     0.0183   0.0821    0.1353    0.0821    0.0183   0.0015
                 0.0001     0.0015   0.0067    0.0111    0.0067    0.0015   0.0001



      Just another linear filter. Performs a weighted average.
      Can be convolved with an image to produce a smoother image.
Robert Collins
CSE486, Penn State
                     Gaussian Smoothing Example




                     original          sigma = 3
Robert Collins
CSE486, Penn State
                              Box vs Gaussian




                     box filter            gaussian
Robert Collins
CSE486, Penn State
                          Box vs Gaussian
     Note: Gaussian is a true low-pass filter, so won’t cause
     high frequency artifacts. See T&V Chap3 for more info.




             box filter               gaussian
Robert Collins
CSE486, Penn State       Gaussian Smoothing at
                            Different Scales




                     original            sigma = 1
Robert Collins
CSE486, Penn State       Gaussian Smoothing at
                            Different Scales




                     original            sigma = 3
Robert Collins
CSE486, Penn State       Gaussian Smoothing at
                            Different Scales




                     original            sigma = 10
Robert Collins
CSE486, Penn State
                     Gaussian Smoothing at
                        Different Scales
            Later in the course we will look more deeply into
            the notions of scale and resolution.
Robert Collins
CSE486, Penn State
                     A Small Aside...




                             can you guess what
                             border-handling method
                             I used when convolving???
Robert Collins
CSE486, Penn State
                      Implementation Issues
               How big should a Gaussian mask be?
 • The std. dev σ of the Gaussian
   determines the amount of
   smoothing.
 • Gaussian theoretically has
   infinite support, but we
   need a filter of finite size.
 • For a 98.76% of the area, we
   need +/-2.5σ
 • +/- 3σ covers over 99% of the
   area.




  O.Camps, PSU
Robert Collins
CSE486, Penn State
                     Efficient Implementation
         • Both, the Box filter and the Gaussian filter are
           separable:
            – First convolve each row with a 1D filter
            – Then convolve each column with a 1D filter.

       Separable Gaussian:          associativity



         • Explain why Gaussian can be factored, on the
           board. (sketch: write out convolution and use
           identity             )
Robert Collins
CSE486, Penn State
                      Efficient Implementation
        • Cascaded Gaussians
             – Repeated convolution by a smaller Gaussian
               to simulate effects of a larger one.
        • G*(G*f) = (G*G)*f             [associative]
       This is important!

        • Note:

        • explanation sketch: convolution in spatial domain is
          multiplication in frequency domain (Fourier space).
          Fourier transform of Gaussian is
Robert Collins
CSE486, Penn State
                      Efficient Implementation
        • Cascaded Gaussians
             – Repeated convolution by a smaller Gaussian
               to simulate effects of a larger one.
        • G*(G*f) = (G*G)*f [associativity]
       This is important!

        • Note:
                                                    Confusion alert!
        • explanation sketch: convolution in spatial domain is
                                                      σ is std.dev
          multiplication in frequency domain (Fourier space).
          Fourier transform of Gaussian is
                                                      σ2 is variance
Robert Collins
CSE486, Penn State
                     Recall: Derivatives and Noise
         • derivative operator is affected by noise
                 Increasing noise




         • Numerical derivatives can amplify noise!
            (particularly higher order derivatives)



M.Nicolescu, UNR
Robert Collins
CSE486, Penn State Solution: Smooth before
                 Applying Derivative Operator!

          E(x,y)                                         I(x,y)
                         Derivative           Smooth



                     Question: Do we have to apply two
                     linear operations here (convolutions)?

                     DerivFilter * (SmoothFilter * I)



O.Camps, PSU
Robert Collins
CSE486, Penn State
                     Smoothing and Differentiation

         No, we can combine filters!
         By associativity of convolution operator:
                   DerivFilter * (SmoothFilter * I)
                = (DerivFilter * SmoothFilter) * I

                      we can precompute this part as
                         a single kernel to apply
Robert Collins
CSE486, Penn State
                     Example: Prewitt Operator




                                                     Noise Smoothing
          Convolve with:      -1    0     1
                              -1    0     1

                              -1    0     1


                           Vertical Edge Detection

    This mask is called the (vertical) Prewitt Edge Detector




O.Camps, PSU
Robert Collins
CSE486, Penn State
                     Example: Prewitt Operator




                                                 Horizontal Edge Detection
           Convolve with:      -1   -1    -1
                               0    0     0

                               1    1     1



                            Noise Smoothing

    This mask is called the (horizontal) Prewitt Edge Detector



O.Camps, PSU
Robert Collins
CSE486, Penn State
                     Example: Sobel Operator


  Convolve with:         -1   0    1
                         -2   0    2
                         -1   0    1
                                        Gives more weight
        and              -1   -2   -1   to the 4-neighbors

                         0    0    0
                         1    2    1



O.Camps, PSU
Robert Collins
CSE486, Penn State
                     Important Observation
        Note that a Prewitt operator is a box filter convolved
         with a derivative operator [using “full” option].
                                                       Simple box filter
                                Finite diff operator




        Also note: a Sobel operator is a [1 2 1] filter convolved
          with a derivative operator.
                                                        Simple Gaussian
                                Finite diff operator
Robert Collins
CSE486, Penn State
                     Generalize: Smooth Derivatives




M.Hebert, CMU
Robert Collins

               First (partial) Derivative of a Gaussian
CSE486, Penn State




                               x2
                             − 2
                g ( x) = e    2σ



                                      x2              x2
                    1               − 2       x     − 2
       g ' ( x) = − 2 2 xe           2σ
                                           =− 2 e    2σ
                   2σ                        σ

O.Camps, PSU
Robert Collins

               First (partial) Derivative of a Gaussian
CSE486, Penn State




                                    x2                 x2
                      1           − 2       x        − 2
         g ' ( x) = − 2 2 xe       2σ
                                         =− 2 e       2σ
                     2σ                    σ

             Positive
                                                Negative


       As a mask, it is also computing a difference (derivative)


O.Camps, PSU
Robert Collins

                Compare with finite diff operator
CSE486, Penn State




                 deriv of Gaussian   finite diff operator
Robert Collins
CSE486, Penn State
                     Derivative of Gaussian Filter




                                     Gsx       Gsy


M.Hebert, CMU
Robert Collins
CSE486, Penn State
                     Summary: Smooth Derivatives




M.Hebert, CMU

Contenu connexe

Similaire à Lecture04

Lecture05
Lecture05Lecture05
Lecture05
zukun
 
Lecture10
Lecture10Lecture10
Lecture10
zukun
 
Presentation at SMI 2023
Presentation at SMI 2023Presentation at SMI 2023
Presentation at SMI 2023
Joaquim Jorge
 
Lecture31
Lecture31Lecture31
Lecture31
zukun
 
Lecture23
Lecture23Lecture23
Lecture23
zukun
 
Lecture14
Lecture14Lecture14
Lecture14
zukun
 

Similaire à Lecture04 (20)

Filtering.ppt
Filtering.pptFiltering.ppt
Filtering.ppt
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Lecture05
Lecture05Lecture05
Lecture05
 
Lecture10
Lecture10Lecture10
Lecture10
 
Spatial filtering using image processing
Spatial filtering using image processingSpatial filtering using image processing
Spatial filtering using image processing
 
Lec05 filter
Lec05 filterLec05 filter
Lec05 filter
 
Presentation at SMI 2023
Presentation at SMI 2023Presentation at SMI 2023
Presentation at SMI 2023
 
Normalized averaging using adaptive applicability functions with applications...
Normalized averaging using adaptive applicability functions with applications...Normalized averaging using adaptive applicability functions with applications...
Normalized averaging using adaptive applicability functions with applications...
 
Lecture31
Lecture31Lecture31
Lecture31
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
sampling-alising.pdf
sampling-alising.pdfsampling-alising.pdf
sampling-alising.pdf
 
Pseudo and Quasi Random Number Generation
Pseudo and Quasi Random Number GenerationPseudo and Quasi Random Number Generation
Pseudo and Quasi Random Number Generation
 
Lecture23
Lecture23Lecture23
Lecture23
 
03 cie552 image_filtering_spatial
03 cie552 image_filtering_spatial03 cie552 image_filtering_spatial
03 cie552 image_filtering_spatial
 
Comparing the Performance of Different Ultrasonic Image Enhancement Technique...
Comparing the Performance of Different Ultrasonic Image Enhancement Technique...Comparing the Performance of Different Ultrasonic Image Enhancement Technique...
Comparing the Performance of Different Ultrasonic Image Enhancement Technique...
 
2. filtering basics
2. filtering basics2. filtering basics
2. filtering basics
 
1610 probability review
1610 probability review1610 probability review
1610 probability review
 
Lecture14
Lecture14Lecture14
Lecture14
 
Digital Image restoration
Digital Image restorationDigital Image restoration
Digital Image restoration
 
LaplacianPyramids which is a image processing to extract the information
LaplacianPyramids which is a image processing to extract the informationLaplacianPyramids which is a image processing to extract the information
LaplacianPyramids which is a image processing to extract the information
 

Plus de zukun

My lyn tutorial 2009
My lyn tutorial 2009My lyn tutorial 2009
My lyn tutorial 2009
zukun
 
ETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCVETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCV
zukun
 
ETHZ CV2012: Information
ETHZ CV2012: InformationETHZ CV2012: Information
ETHZ CV2012: Information
zukun
 
Siwei lyu: natural image statistics
Siwei lyu: natural image statisticsSiwei lyu: natural image statistics
Siwei lyu: natural image statistics
zukun
 
Lecture9 camera calibration
Lecture9 camera calibrationLecture9 camera calibration
Lecture9 camera calibration
zukun
 
Brunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer visionBrunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer vision
zukun
 
Modern features-part-4-evaluation
Modern features-part-4-evaluationModern features-part-4-evaluation
Modern features-part-4-evaluation
zukun
 
Modern features-part-3-software
Modern features-part-3-softwareModern features-part-3-software
Modern features-part-3-software
zukun
 
Modern features-part-2-descriptors
Modern features-part-2-descriptorsModern features-part-2-descriptors
Modern features-part-2-descriptors
zukun
 
Modern features-part-1-detectors
Modern features-part-1-detectorsModern features-part-1-detectors
Modern features-part-1-detectors
zukun
 
Modern features-part-0-intro
Modern features-part-0-introModern features-part-0-intro
Modern features-part-0-intro
zukun
 
Lecture 02 internet video search
Lecture 02 internet video searchLecture 02 internet video search
Lecture 02 internet video search
zukun
 
Lecture 01 internet video search
Lecture 01 internet video searchLecture 01 internet video search
Lecture 01 internet video search
zukun
 
Lecture 03 internet video search
Lecture 03 internet video searchLecture 03 internet video search
Lecture 03 internet video search
zukun
 
Icml2012 tutorial representation_learning
Icml2012 tutorial representation_learningIcml2012 tutorial representation_learning
Icml2012 tutorial representation_learning
zukun
 
Advances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer visionAdvances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer vision
zukun
 
Gephi tutorial: quick start
Gephi tutorial: quick startGephi tutorial: quick start
Gephi tutorial: quick start
zukun
 
EM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysisEM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysis
zukun
 
Object recognition with pictorial structures
Object recognition with pictorial structuresObject recognition with pictorial structures
Object recognition with pictorial structures
zukun
 
Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities
zukun
 

Plus de zukun (20)

My lyn tutorial 2009
My lyn tutorial 2009My lyn tutorial 2009
My lyn tutorial 2009
 
ETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCVETHZ CV2012: Tutorial openCV
ETHZ CV2012: Tutorial openCV
 
ETHZ CV2012: Information
ETHZ CV2012: InformationETHZ CV2012: Information
ETHZ CV2012: Information
 
Siwei lyu: natural image statistics
Siwei lyu: natural image statisticsSiwei lyu: natural image statistics
Siwei lyu: natural image statistics
 
Lecture9 camera calibration
Lecture9 camera calibrationLecture9 camera calibration
Lecture9 camera calibration
 
Brunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer visionBrunelli 2008: template matching techniques in computer vision
Brunelli 2008: template matching techniques in computer vision
 
Modern features-part-4-evaluation
Modern features-part-4-evaluationModern features-part-4-evaluation
Modern features-part-4-evaluation
 
Modern features-part-3-software
Modern features-part-3-softwareModern features-part-3-software
Modern features-part-3-software
 
Modern features-part-2-descriptors
Modern features-part-2-descriptorsModern features-part-2-descriptors
Modern features-part-2-descriptors
 
Modern features-part-1-detectors
Modern features-part-1-detectorsModern features-part-1-detectors
Modern features-part-1-detectors
 
Modern features-part-0-intro
Modern features-part-0-introModern features-part-0-intro
Modern features-part-0-intro
 
Lecture 02 internet video search
Lecture 02 internet video searchLecture 02 internet video search
Lecture 02 internet video search
 
Lecture 01 internet video search
Lecture 01 internet video searchLecture 01 internet video search
Lecture 01 internet video search
 
Lecture 03 internet video search
Lecture 03 internet video searchLecture 03 internet video search
Lecture 03 internet video search
 
Icml2012 tutorial representation_learning
Icml2012 tutorial representation_learningIcml2012 tutorial representation_learning
Icml2012 tutorial representation_learning
 
Advances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer visionAdvances in discrete energy minimisation for computer vision
Advances in discrete energy minimisation for computer vision
 
Gephi tutorial: quick start
Gephi tutorial: quick startGephi tutorial: quick start
Gephi tutorial: quick start
 
EM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysisEM algorithm and its application in probabilistic latent semantic analysis
EM algorithm and its application in probabilistic latent semantic analysis
 
Object recognition with pictorial structures
Object recognition with pictorial structuresObject recognition with pictorial structures
Object recognition with pictorial structures
 
Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities Iccv2011 learning spatiotemporal graphs of human activities
Iccv2011 learning spatiotemporal graphs of human activities
 

Dernier

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Dernier (20)

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 

Lecture04

  • 1. Robert Collins CSE486, Penn State Lecture 4: Smoothing Related text is T&V Section 2.3.3 and Chapter 3
  • 2. Robert Collins CSE486, Penn State Summary about Convolution Computing a linear operator in neighborhoods centered at each pixel. Can be thought of as sliding a kernel of fixed coefficients over the image, and doing a weighted sum in the area of overlap. things to take note of: full : compute a value for any overlap between kernel and image (resulting image is bigger than the original) same: compute values only when center pixel of kernel aligns with a pixel in the image (resulting image is same size as original) convolution : kernel gets rotated 180 degrees before sliding over the image cross-correlation: kernel does not get rotated first border handling methods : defining values for pixels off the image
  • 3. Robert Collins CSE486, Penn State Problem: Derivatives and Noise M.Hebert, CMU
  • 4. Robert Collins CSE486, Penn State Problem: Derivatives and Noise •First derivative operator is affected by noise Increasing noise • Numerical derivatives can amplify noise! (particularly higher order derivatives) M.Nicolescu, UNR
  • 5. Robert Collins CSE486, Penn State Image Noise • Fact: Images are noisy • Noise is anything in the image that we are not interested in • Examples: – Light fluctuations – Sensor noise – Quantization effects – Finite precision O.Camps, PSU
  • 6. Robert Collins CSE486, Penn State Modeling Image Noise Simple model: additive RANDOM noise I(x,y) = s(x,y) + ni Where s(x,y) is the deterministic signal ni is a random variable Note: This really Common Assumptions: only models the n is i.i.d for all pixels sensor noise. n is zero-mean Gaussian (normal) E(n) = 0 var(n) = σ2 E(ni nj) = 0 (independence) O.Camps, PSU
  • 7. Robert Collins CSE486, Penn State Example: Additive Gaussian Noise mean 0, sigma = 16 Forsyth and Ponce
  • 8. Robert Collins CSE486, Penn State Empirical Evidence Mean = 164 Std = 1.8
  • 9. Robert Collins CSE486, Penn State Other Noise Models We won’t cover them. Just be aware they exist!! •Multiplicative noise: ˆ I (i, j ) = I (i, j ) ⋅N (i, j ) •Impulse (“shot”) noise (aka salt and pepper):  ˆ I (i, j ) if x < l I (i, j ) =  See Textbook imin + y (imax − imin ) x ≥ l O.Camps, PSU
  • 10. Robert Collins CSE486, Penn State Smoothing Reduces Noise From Numerical Recipes in C: The premise of data smoothing is that one is measuring a variable that is both slowly varying and also corrupted by random noise. Then it can sometimes be useful to replace each data point by some kind of local average of surrounding data points. Since nearby points measure very nearly the same underlying value, averaging can reduce the level of noise without (much) biasing the value obtained.
  • 11. Robert Collins CSE486, Penn State Today: Smoothing Reduces Noise Image patch Noisy surface smoothing reduces noise, giving us (perhaps) a more accurate intensity surface.
  • 12. Robert Collins CSE486, Penn State Preview • We will talk about two smoothing filters – Box filter (simple averaging) – Gaussian filter (center pixels weighted more)
  • 13. Robert Collins CSE486, Penn State Averaging / Box Filter • Mask with positive entries that sum to 1. Box filter • Replaces each pixel with an average of its 1 1 1 neighborhood. • Since all weights are 1/9 1 1 1 equal, it is called a 1 1 1 BOX filter. important point: since this is a linear operator, we can take the average around each pixel by convolving the image with this 3x3 filter! O.Camps, PSU
  • 14. Robert Collins CSE486, Penn State Why Averaging Reduces Noise • Intuitive explanation: variance of noise in the average is smaller than variance of the pixel noise (assuming zero-mean Gaussian noise). • Sketch of more rigorous explanation: O.Camps, PSU
  • 15. Robert Collins CSE486, Penn State Smoothing with Box Filter original Convolved with 11x11 box filter Drawback: smoothing reduces fine image detail
  • 16. Robert Collins Important Point about Smoothing CSE486, Penn State Averaging attenuates noise (reduces the variance), leading to a more “accurate” estimate. However, the more accurate estimate is of the mean of a local pixel neighborhood! This might not be what you want. Balancing act: smooth enough to “clean up” the noise, but not so much as to remove important image gradients.
  • 17. Robert Collins CSE486, Penn State Gaussian Smoothing Filter • a case of weighted averaging – The coefficients are a 2D Gaussian. – Gives more weight at the central pixels and less weights to the neighbors. – The farther away the neighbors, the smaller the weight. Confusion alert: there are now two Gaussians being discussed here (one for noise, one for smoothing). They are different. O.Camps, PSU
  • 18. Robert Collins CSE486, Penn State Gaussian Smoothing Filter An isotropic (circularly symmetric) Gaussian:
  • 19. Robert Collins CSE486, Penn State In Matlab >> sigma = 1 sigma = 1 >> halfwid = 3*sigma halfwid = 3 >> [xx,yy] = meshgrid(-halfwid:halfwid, -halfwid:halfwid); >> tmp = exp(-1/(2*sigma^2) * (xx.^2 + yy.^2)) tmp = 0.0001 0.0015 0.0067 0.0111 0.0067 0.0015 0.0001 0.0015 0.0183 0.0821 0.1353 0.0821 0.0183 0.0015 0.0067 0.0821 0.3679 0.6065 0.3679 0.0821 0.0067 0.0111 0.1353 0.6065 1.0000 0.6065 0.1353 0.0111 0.0067 0.0821 0.3679 0.6065 0.3679 0.0821 0.0067 0.0015 0.0183 0.0821 0.1353 0.0821 0.0183 0.0015 0.0001 0.0015 0.0067 0.0111 0.0067 0.0015 0.0001 Note: we have not included the normalization constant. Values of a Gaussian should sum to one. However, it’s OK to ignore the constant since you can divide by it later.
  • 20. Robert Collins CSE486, Penn State Gaussian Smoothing Filter >> sigma = 1 sigma = 1 >> halfwid = 3*sigma halfwid = 3 >> [xx,yy] = meshgrid(-halfwid:halfwid, -halfwid:halfwid); >> gau = exp(-1/(2*sigma^2) * (xx.^2 + yy.^2)) gau = 0.0001 0.0015 0.0067 0.0111 0.0067 0.0015 0.0001 0.0015 0.0183 0.0821 0.1353 0.0821 0.0183 0.0015 0.0067 0.0821 0.3679 0.6065 0.3679 0.0821 0.0067 0.0111 0.1353 0.6065 1.0000 0.6065 0.1353 0.0111 0.0067 0.0821 0.3679 0.6065 0.3679 0.0821 0.0067 0.0015 0.0183 0.0821 0.1353 0.0821 0.0183 0.0015 0.0001 0.0015 0.0067 0.0111 0.0067 0.0015 0.0001 Just another linear filter. Performs a weighted average. Can be convolved with an image to produce a smoother image.
  • 21. Robert Collins CSE486, Penn State Gaussian Smoothing Example original sigma = 3
  • 22. Robert Collins CSE486, Penn State Box vs Gaussian box filter gaussian
  • 23. Robert Collins CSE486, Penn State Box vs Gaussian Note: Gaussian is a true low-pass filter, so won’t cause high frequency artifacts. See T&V Chap3 for more info. box filter gaussian
  • 24. Robert Collins CSE486, Penn State Gaussian Smoothing at Different Scales original sigma = 1
  • 25. Robert Collins CSE486, Penn State Gaussian Smoothing at Different Scales original sigma = 3
  • 26. Robert Collins CSE486, Penn State Gaussian Smoothing at Different Scales original sigma = 10
  • 27. Robert Collins CSE486, Penn State Gaussian Smoothing at Different Scales Later in the course we will look more deeply into the notions of scale and resolution.
  • 28. Robert Collins CSE486, Penn State A Small Aside... can you guess what border-handling method I used when convolving???
  • 29. Robert Collins CSE486, Penn State Implementation Issues How big should a Gaussian mask be? • The std. dev σ of the Gaussian determines the amount of smoothing. • Gaussian theoretically has infinite support, but we need a filter of finite size. • For a 98.76% of the area, we need +/-2.5σ • +/- 3σ covers over 99% of the area. O.Camps, PSU
  • 30. Robert Collins CSE486, Penn State Efficient Implementation • Both, the Box filter and the Gaussian filter are separable: – First convolve each row with a 1D filter – Then convolve each column with a 1D filter. Separable Gaussian: associativity • Explain why Gaussian can be factored, on the board. (sketch: write out convolution and use identity )
  • 31. Robert Collins CSE486, Penn State Efficient Implementation • Cascaded Gaussians – Repeated convolution by a smaller Gaussian to simulate effects of a larger one. • G*(G*f) = (G*G)*f [associative] This is important! • Note: • explanation sketch: convolution in spatial domain is multiplication in frequency domain (Fourier space). Fourier transform of Gaussian is
  • 32. Robert Collins CSE486, Penn State Efficient Implementation • Cascaded Gaussians – Repeated convolution by a smaller Gaussian to simulate effects of a larger one. • G*(G*f) = (G*G)*f [associativity] This is important! • Note: Confusion alert! • explanation sketch: convolution in spatial domain is σ is std.dev multiplication in frequency domain (Fourier space). Fourier transform of Gaussian is σ2 is variance
  • 33. Robert Collins CSE486, Penn State Recall: Derivatives and Noise • derivative operator is affected by noise Increasing noise • Numerical derivatives can amplify noise! (particularly higher order derivatives) M.Nicolescu, UNR
  • 34. Robert Collins CSE486, Penn State Solution: Smooth before Applying Derivative Operator! E(x,y) I(x,y) Derivative Smooth Question: Do we have to apply two linear operations here (convolutions)? DerivFilter * (SmoothFilter * I) O.Camps, PSU
  • 35. Robert Collins CSE486, Penn State Smoothing and Differentiation No, we can combine filters! By associativity of convolution operator: DerivFilter * (SmoothFilter * I) = (DerivFilter * SmoothFilter) * I we can precompute this part as a single kernel to apply
  • 36. Robert Collins CSE486, Penn State Example: Prewitt Operator Noise Smoothing Convolve with: -1 0 1 -1 0 1 -1 0 1 Vertical Edge Detection This mask is called the (vertical) Prewitt Edge Detector O.Camps, PSU
  • 37. Robert Collins CSE486, Penn State Example: Prewitt Operator Horizontal Edge Detection Convolve with: -1 -1 -1 0 0 0 1 1 1 Noise Smoothing This mask is called the (horizontal) Prewitt Edge Detector O.Camps, PSU
  • 38. Robert Collins CSE486, Penn State Example: Sobel Operator Convolve with: -1 0 1 -2 0 2 -1 0 1 Gives more weight and -1 -2 -1 to the 4-neighbors 0 0 0 1 2 1 O.Camps, PSU
  • 39. Robert Collins CSE486, Penn State Important Observation Note that a Prewitt operator is a box filter convolved with a derivative operator [using “full” option]. Simple box filter Finite diff operator Also note: a Sobel operator is a [1 2 1] filter convolved with a derivative operator. Simple Gaussian Finite diff operator
  • 40. Robert Collins CSE486, Penn State Generalize: Smooth Derivatives M.Hebert, CMU
  • 41. Robert Collins First (partial) Derivative of a Gaussian CSE486, Penn State x2 − 2 g ( x) = e 2σ x2 x2 1 − 2 x − 2 g ' ( x) = − 2 2 xe 2σ =− 2 e 2σ 2σ σ O.Camps, PSU
  • 42. Robert Collins First (partial) Derivative of a Gaussian CSE486, Penn State x2 x2 1 − 2 x − 2 g ' ( x) = − 2 2 xe 2σ =− 2 e 2σ 2σ σ Positive Negative As a mask, it is also computing a difference (derivative) O.Camps, PSU
  • 43. Robert Collins Compare with finite diff operator CSE486, Penn State deriv of Gaussian finite diff operator
  • 44. Robert Collins CSE486, Penn State Derivative of Gaussian Filter Gsx Gsy M.Hebert, CMU
  • 45. Robert Collins CSE486, Penn State Summary: Smooth Derivatives M.Hebert, CMU