Image enhancement using Spatial filtering By Md. Fazle Rabbi 16CSE057
4.2 Introduction To Filters • Filtering is a technique used for modifying or enhancing an image like highlight certain features or remove other features. • Image filtering include smoothing, sharpening, and edge enhancement • Term ‘convolution ‘ means applying filters to an image . • It may be applied in either spatial domain frequency domain
4.3 SPATIAL DOMAIN FILTERS
4.4 SPATIAL FILTER The spatial filter is just moving the filter mask from point to point in an image. The filter mask may be 3x3 mask or 5x5 mask or to be 7x7 mask. Example 3x3 mask in a 5x5 image
4.5 MECHANISM OF SPATIAL FILTERING Filter at each point (x , y) are calculated by predefined relationship This process shows moving filter mask point to point
4.6 Spatial Filtering • Similar to neighborhood operation • A mask or filter or template or kernel or window defines the neighborhood • Mask size is usually m × n o m = 2a+1, n = 2b+1 • Output pixel value is determined from the pixels under the mask
4.7 The Approaches of Spatial Filtering O A neighborhood (small rectangle) O A predefined operation performed on image pixels. Spatial filter consist of two steps Filtering creates a new pixel value replaced by old pixel value
4.8 Image Enhancement using Spatial Filtering Mask Image Origin Image f(x,y)
4.9 Image Enhancement using Spatial Filtering Mask Image Origin Image f(x,y) w(-1,-1) w(-1,0) w(-1,1) w(0,-1) w(0,0) w(0,1) w(1,0) w(1,1) Mask Coefficients showing coordinate arrangement w(1,-1)
4.10 Image Enhancement using Spatial Filtering Mask Image Origin Image f(x,y) f(x-1,y-1) f(x-1,y) f(x-1,y+1) f(x,y-1) f(x,y) f(x,y+1) f(x+1,y-1) f(x+1,y) f(x+1,y+1) Pixels of image section under Mask
4.11 Image Enhancement using Spatial Filtering Mask Image Origin Image f(x,y) w(-1,-1) w(-1,0) w(-1,1) w(0,-1) w(0,0) w(0,1) w(1,0) w(1,1) f(x-1,y-1) f(x-1,y) f(x-1,y+1) f(x,y) f(x,y+1) f(x+1,y-1) f(x+1,y) f(x+1,y+1) Mask Coefficients Pixels under Mask w(1,-1) f(x,y-1)
4.12 Types Of Spatial Filters There are two types of filter, 1.Linear Spatial Filter 2.Non Linear Spatial Filter  Each pixel in an image can be replaced with constant value then it is called as linear spatial filter otherwise it is called as non-linear.
4.13 LINEAR SPATIAL FILTERING
4.14 LINEAR SPATIAL FILTERING
4.15 LINEAR SPATIAL FILTERING
4.16 CONVOLUTION
4.17 CONVOLUTION
4.18 Image Enhancement using Spatial Filtering Mask Image Origin Image f(x,y) w(-1,-1) w(-1,0) w(-1,1) w(0,-1) w(0,0) w(0,1) w(1,0) w(1,1) f(x-1,y-1) f(x-1,y) f(x-1,y+1) f(x,y) f(x,y+1) f(x+1,y-1) f(x+1,y) f(x+1,y+1) Mask Coefficients Pixels under Mask w(1,-1) f(x,y-1)
4.19 Image Enhancement using Spatial Filtering w(-1,-1) w(-1,0) w(-1,1) w(0,-1) w(0,0) w(0,1) w(1,0) w(1,1) f(x-1,y-1) f(x-1,y) f(x-1,y+1) f(x,y) f(x,y+1) f(x+1,y-1) f(x+1,y) f(x+1,y+1) Mask Coefficients Pixels under Mask w(1,-1) f(x,y-1) Response of the filter at point (x, y): ) 1 , 1 ( ) 1 , 1 ( ) , 1 ( ) 0 , 1 ( ) , 1 ( ) 0 , 1 ( ) 1 , 1 ( ) 1 , 1 (               y x f w y x f w y x f w y x f w R  
4.20 Image Enhancement using Spatial Filtering w(-1,-1) w(-1,0) w(-1,1) w(0,-1) w(0,0) w(0,1) w(1,0) w(1,1) f(x-1,y-1) f(x-1,y) f(x-1,y+1) f(x,y) f(x,y+1) f(x+1,y-1) f(x+1,y) f(x+1,y+1) Mask Coefficients Pixels under Mask w(1,-1) f(x,y-1) Response of the filter at point (x, y): ) 1 , 1 ( ) 1 , 1 ( ) , 1 ( ) 0 , 1 ( ) , 1 ( ) 0 , 1 ( ) 1 , 1 ( ) 1 , 1 (               y x f w y x f w y x f w y x f w R   **This type of response is called linear filtering
4.21 Image Enhancement using Spatial Filtering A more general equation for response: w(-1,-1) w(-1,0) w(-1,1) w(0,-1) w(0,0) w(0,1) w(1,0) w(1,1) f(x-1,y-1) f(x-1,y) f(x-1,y+1) f(x,y-1) f(x,y) f(x,y+1) f(x+1,y-1) f(x+1,y) f(x+1,y+1) Mask Coefficients w(1,-1)         a a s b b t t y s x f t s w y x g ) , ( ) , ( ) , ( g(x,y) M N 2b+1 2a+1
4.22 Image Enhancement using Spatial Filtering    mn i i i z w R 1 w1 w2 w3 w4 w5 w6 w8 w9 Mask Coefficients w7 Or, for a general case of mask size mXn: z1 z2 z3 z4 z5 z6 z8 z9 z7    9 1 i i i z w R
4.23 Thank You

7. image enhancement using spatial filtering

  • 1.
    Image enhancement using Spatialfiltering By Md. Fazle Rabbi 16CSE057
  • 2.
    4.2 Introduction To Filters •Filtering is a technique used for modifying or enhancing an image like highlight certain features or remove other features. • Image filtering include smoothing, sharpening, and edge enhancement • Term ‘convolution ‘ means applying filters to an image . • It may be applied in either spatial domain frequency domain
  • 3.
  • 4.
    4.4 SPATIAL FILTER The spatialfilter is just moving the filter mask from point to point in an image. The filter mask may be 3x3 mask or 5x5 mask or to be 7x7 mask. Example 3x3 mask in a 5x5 image
  • 5.
    4.5 MECHANISM OF SPATIALFILTERING Filter at each point (x , y) are calculated by predefined relationship This process shows moving filter mask point to point
  • 6.
    4.6 Spatial Filtering • Similarto neighborhood operation • A mask or filter or template or kernel or window defines the neighborhood • Mask size is usually m × n o m = 2a+1, n = 2b+1 • Output pixel value is determined from the pixels under the mask
  • 7.
    4.7 The Approaches ofSpatial Filtering O A neighborhood (small rectangle) O A predefined operation performed on image pixels. Spatial filter consist of two steps Filtering creates a new pixel value replaced by old pixel value
  • 8.
    4.8 Image Enhancement usingSpatial Filtering Mask Image Origin Image f(x,y)
  • 9.
    4.9 Image Enhancement usingSpatial Filtering Mask Image Origin Image f(x,y) w(-1,-1) w(-1,0) w(-1,1) w(0,-1) w(0,0) w(0,1) w(1,0) w(1,1) Mask Coefficients showing coordinate arrangement w(1,-1)
  • 10.
    4.10 Image Enhancement usingSpatial Filtering Mask Image Origin Image f(x,y) f(x-1,y-1) f(x-1,y) f(x-1,y+1) f(x,y-1) f(x,y) f(x,y+1) f(x+1,y-1) f(x+1,y) f(x+1,y+1) Pixels of image section under Mask
  • 11.
    4.11 Image Enhancement usingSpatial Filtering Mask Image Origin Image f(x,y) w(-1,-1) w(-1,0) w(-1,1) w(0,-1) w(0,0) w(0,1) w(1,0) w(1,1) f(x-1,y-1) f(x-1,y) f(x-1,y+1) f(x,y) f(x,y+1) f(x+1,y-1) f(x+1,y) f(x+1,y+1) Mask Coefficients Pixels under Mask w(1,-1) f(x,y-1)
  • 12.
    4.12 Types Of SpatialFilters There are two types of filter, 1.Linear Spatial Filter 2.Non Linear Spatial Filter  Each pixel in an image can be replaced with constant value then it is called as linear spatial filter otherwise it is called as non-linear.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
    4.18 Image Enhancement usingSpatial Filtering Mask Image Origin Image f(x,y) w(-1,-1) w(-1,0) w(-1,1) w(0,-1) w(0,0) w(0,1) w(1,0) w(1,1) f(x-1,y-1) f(x-1,y) f(x-1,y+1) f(x,y) f(x,y+1) f(x+1,y-1) f(x+1,y) f(x+1,y+1) Mask Coefficients Pixels under Mask w(1,-1) f(x,y-1)
  • 19.
    4.19 Image Enhancement usingSpatial Filtering w(-1,-1) w(-1,0) w(-1,1) w(0,-1) w(0,0) w(0,1) w(1,0) w(1,1) f(x-1,y-1) f(x-1,y) f(x-1,y+1) f(x,y) f(x,y+1) f(x+1,y-1) f(x+1,y) f(x+1,y+1) Mask Coefficients Pixels under Mask w(1,-1) f(x,y-1) Response of the filter at point (x, y): ) 1 , 1 ( ) 1 , 1 ( ) , 1 ( ) 0 , 1 ( ) , 1 ( ) 0 , 1 ( ) 1 , 1 ( ) 1 , 1 (               y x f w y x f w y x f w y x f w R  
  • 20.
    4.20 Image Enhancement usingSpatial Filtering w(-1,-1) w(-1,0) w(-1,1) w(0,-1) w(0,0) w(0,1) w(1,0) w(1,1) f(x-1,y-1) f(x-1,y) f(x-1,y+1) f(x,y) f(x,y+1) f(x+1,y-1) f(x+1,y) f(x+1,y+1) Mask Coefficients Pixels under Mask w(1,-1) f(x,y-1) Response of the filter at point (x, y): ) 1 , 1 ( ) 1 , 1 ( ) , 1 ( ) 0 , 1 ( ) , 1 ( ) 0 , 1 ( ) 1 , 1 ( ) 1 , 1 (               y x f w y x f w y x f w y x f w R   **This type of response is called linear filtering
  • 21.
    4.21 Image Enhancement usingSpatial Filtering A more general equation for response: w(-1,-1) w(-1,0) w(-1,1) w(0,-1) w(0,0) w(0,1) w(1,0) w(1,1) f(x-1,y-1) f(x-1,y) f(x-1,y+1) f(x,y-1) f(x,y) f(x,y+1) f(x+1,y-1) f(x+1,y) f(x+1,y+1) Mask Coefficients w(1,-1)         a a s b b t t y s x f t s w y x g ) , ( ) , ( ) , ( g(x,y) M N 2b+1 2a+1
  • 22.
    4.22 Image Enhancement usingSpatial Filtering    mn i i i z w R 1 w1 w2 w3 w4 w5 w6 w8 w9 Mask Coefficients w7 Or, for a general case of mask size mXn: z1 z2 z3 z4 z5 z6 z8 z9 z7    9 1 i i i z w R
  • 23.