Digital Image Processing
Lecture 4.2: Intensity Transformation and Spatial Filtering
                             (sharpening)
Prepared by: Moussab Haraj
                                  outline
➢ Introduction
➢ Fundamentals of Spatial Filtering
     ❖ Linear Filtering
        ▪   The Mechanics of Linear Spatial Filtering
        ▪   Spatial Correlation and Convolution
        ▪   Smoothing (Lowpass) Spatial Filters
        ▪   Sharpening (Highpass) Spatial Filters
     ❖ Nonlinear Filtering
                           outline
▪ Sharpening (Highpass) Spatial Filters
    Using The Second Derivative for Image Sharpening (The Laplacian)
    Unsharp Masking and Highboost Filtering
    Using First-order Derivatives for Image Sharpening (The Gradient)
    Highpass, Bandreject, and Bandpass Filters from Lowpass Filters
      Sharpening (Highpass) Spatial Filters
• Sharpening is used to enhance structures or other details in an image.
• Sharpening Spatial Filters:
 ▪ To highlight fine detail or edges in an image.
 ▪ To enhance and focus on details that has ben blurred either in error or as a
    natural effect of a particular method of image acquisition.
• It is called Highpass filter: it passes over the high frequency component and
  reduce or eliminate low frequency component.
          Sharpening (Highpass) Spatial Filters
•   Image blurring could be accomplished in the spatial domain by pixel averaging (smoothing) in a
    neighborhood.
•   Because averaging is analogous to integration, So sharpening can be accomplished by spatial
    differentiation.
•   Image differentiation
      •   Enhances edges and ot her di scont i nuities ( such as noi se) .
      •   De-emphasi zes ar eas wi t h sl owl y var yi ng i nt ensit ies.
•   Derivatives of a digital function are defined in terms of differences.
•   First-order derivatives
•   Second-order Derivatives
     Sharpening (Highpass) Spatial Filters
❖ Any definition for first-order derivative must satisfy:
1. Must be zero in areas of constant intensity.
2. Must be nonzero at the onset of an intensity step or ramp.
3. Must be nonzero along intensity ramps.
     Sharpening (Highpass) Spatial Filters
• Any definition for second-order derivative must satisfy:
1. Must be zero in areas of constant intensity.
2. Must be nonzero at the onset and end of an intensity step or ramp.
3. Must be zero along intensity ramps.
                                                                                 outline
➢   Introduction
➢   Fundamentals of Spatial Filtering
        ❖ Linear Filtering
             ▪     T he Mechani cs of Li near Spat i al Fi l t er ing
             ▪     Spat i al Cor r el at i on and Convol ut i on
             ▪     Smoot hi ng ( Lowpass) Spat i al Fi l t er s
             ▪     Shar peni ng ( Hi ghpass ) Spat i al Fi l t ers
                     U s i n g T h e S e c o n d D e r i v a t i v e fo r I ma g e S h a r p e n i n g ( T h e La p l a c i a n )
                     Unsharp Masking and Highboost Filtering
                     U s i n g F i r s t - o r d e r D e r i v a t i v e s fo r I ma g e S h a r p e n i n g ( T h e G r a d i e n t )
                     H i g h p a s s , B a n d r e j e c t , a n d B a n d p a s s F i l t e r s fr o m Lo wp a s s F i l t e r s
        ❖   Nonlinear Filtering
     Using The Second Derivative For Image
           Sharpening—The Laplacian
• The simplest derivative operator (kernel) is the Laplacian, which for a
  function (image) f (x, y) of two variables, is defined as:
Using The Second Derivative For Image
      Sharpening—The Laplacian
Using The Second Derivative For Image
      Sharpening—The Laplacian
Using The Second Derivative For Image
      Sharpening—The Laplacian
     Using The Second Derivative For Image
           Sharpening—The Laplacian
• Because the Laplacian is a derivative operator:
   • highlights sharp intensity transitions in an image .
   • de-emphasizes regions of slowly varying intensities.
• This will tend to produce images that have grayish edge lines and other
  discontinuities, all superimposed on a dark, featureless background.
        Using The Second Derivative For Image
             Sharpening—The Laplacian
• It is important to keep in mind which definition of the Laplacian is used.
• The basic way in which we use the Laplacian for image sharpening is
• where f (x, y) and g(x, y) are the input and sharpened images, respectively.
• Let c = −1 if the Laplacian kernels has negative center
• Let c = 1 if the Laplacian kernels has positive center .
Composite Laplacian filter (Mask of Laplacian
               + addition)