4 lecture image enhancement filtering
play

4. Lecture Image enhancement: Filtering 1 Image preprocessing - PowerPoint PPT Presentation

4. Lecture Image enhancement: Filtering 1 Image preprocessing Aims: Improvement of image data Suppress unwanted distortions Highlight interesting features Image preprocessing does not increase the information content


  1. 4. Lecture Image enhancement: Filtering 1

  2. Image preprocessing • Aims: – Improvement of image data – Suppress unwanted distortions – Highlight interesting features • Image preprocessing does not increase the information content • Best preprocessing is no preprocessing – better: high quality image acquisition 2

  3. Classification of preprocessing • Point operations – Grayvalue transformations • Local operations – Spatial filters, look at local neighbourhoods • Global operations – Inverse filtering • Geometric Transformations 3

  4. Grayvalue transformations • Alteration of the brightness of the pixels independent of the position in the image • Function T to transform original grayvalue p to grayvalue q q = T(p) • Fast implementation possible by creation of a look-up table • Used for interactive image viewers 4

  5. Examples q q q p p c p p 1 p 2 Thresholding Image negative Contrast stretching [Matlab] 5

  6. Dynamic range compression • Image values can be to large for the display or for the image data format • E.g. storing a Fourier transformed image in a 8Bit grayvalue image T : q = c ¢ log(1 + p ) 6

  7. Gamma correction Image can be made brighter or darker T : q = p ° ° • < 1 image gets brighter ° • > 1 image gets darker [Matlab] 7

  8. Histogram equalization • Histogram counts the instances of each grayvalues in the image • It is the grayvalue distribution of the image • Can be computed with the Matlab command imhist 8

  9. Plotting histograms in Matlab 9

  10. Histogram equalization • Transform the initial distribution to match a uniform distribution • All the grayvalues appear similarly often • Transformation leads to enhanced contrast G(p) H(p) p p 10

  11. Example 2000 3000 1800 1600 2500 1400 2000 1200 1000 1500 800 1000 600 400 500 200 0 0 [Matlab] 11 0 50 100 150 200 250 0 50 100 150 200 250

  12. Pseudo color transformation • Each grayvalue gets a color value • Grayvalues that are very similar can get totally different color values and are therefore distinguishable 13

  13. Illumination correction • When is this necessary? • Ideally the sensitivity of an image sensor is independent of the pixel location. This is however not always true. • Artificial lighting might lead to non uniform illumination • If the deviation is systematic it can be corrected 14

  14. Example: Illumination [Matlab] 15

  15. Illumination correction • f(i,j) = e(i,j)g(i,j) – g(i,j)...original image (not distorted) – e(i,j)... distortion – f(i,j)... distorted images • Distortion can be computed by use of reference image of constant color/grayvalue:  g ( i , j ) c correction:  f ( i , j ) e ( i , j ) c c f ( i , j ) cf ( i , j )   g ( i , j ) f ( i , j )  e ( i , j ) f ( i , j ) c e ( i , j ) c c 16

  16. Local image preprocessing • The local neighbourhood of a pixel will be used to compute the new pixel value (spatial filtering) • Smoothing – to suppress noise – image gets blurred – high frequencies vanish • Gradient operators – using local derivatives – Sharpening/Edge detection noisy image 17

  17. Spatial filtering • Definition: A filter kernel (window) will be moved from pixel to pixel and for every pixel a new value is computed as a linear combination of the filter kernel and the grayvalues of the local neighborhood. • This process is mathematically a convolution • Convolution of the kernel w and the image f: 18

  18. Illustration y origin W(-1,-1) W(-1,0) W(-1,1) mask W(0,-1) W(0,0) W(0,1) W(1,-1) W(1,0) W(1,1) f(x-1,y-1) f(x-1,y) f(x-1,y+1) Mask coefficients x f(x,y) f(x,y-1) f(x,y+1)  g ( x , y ) f(x+1,y-1) f(x+1,y) f(x+1,y+1) a b    w ( s , t ) f ( x s , y t )     s a t b Image section under mask 19

  19. Example1: Averaging • One simple example is smoothing using a 3x3 mask. f(x-1,y-1) f(x-1,y) f(x-1,y+1) 1/9 1/9 1/9 f(x,y) f(x,y-1) f(x,y+1) 1/9 1/9 1/9 f(x+1,y-1) f(x+1,y) f(x+1,y+1) 1/9 1/9 1/9   1             g ( x , y ) f ( x 1 , y 1 ) f ( x 1 , y ) f ( x 1 , y 1 ) ... f ( x 1 , y 1 ) 9 20

  20. What happens at the borders? • Problem: What happens at the borders? – Ignore the edges • The resulting image is smaller than the original – Pad with zeros • Introducing unwanted artifacts – Mirror image at edges 21

  21. Values Outside the Range • Linear filtering might bring the intensity outside the display range. • Solutions :   0 if x 0  – Clip values     y x if 0 x 255    255 if 255 x – Scaling transformation New min  x g  255 L y  g g New max H L • Transform values in [gL,gH] to [0,255] 22

  22. Separable Filters • A filter matrix with rank(w)=1 can be implemented by successive application of two simpler filters. • A rank=1 matrix can be written as the outer product of 2 vectors.     1 1 1 1       1 1 1  1 1 1 1 1 1 1     9 3 3         1 1 1 1 • Separating filters results in great time saving. • By how much? – For a mask of size nxn, for each image pixel • Originally, n 2 multiplications and n(n-1) additions • After separation, 2n multiplications and 2(n-1) additions 23

  23. Some terminology on Frequency… • Frequencies: a measure of the amount by which gray values change with distance. • High/low-frequency components: large/small changes in gray values over small distances. • High/low-pass filter: passing high/low components, and reducing or eliminating low/high-frequency filter. 24

  24. Low-Pass Filter • Mostly for noise reduction/removal and smoothing – 3x3 averaging filter to blur edges – Gaussian filter, • based on Gaussian probability distribution function • a popular filter for smoothing • more later when we discuss image restoration  2 2 x y    1   2 2 G x , y e  2 2 25

  25. Gauss filtering • A Gaussian filter is a weighted average filter. Pixel in the center of the filter window are weighted stronger than pixel on the border (according to the Gaussian distribution).  • The only parameter is (sigma), which is the standard deviation. This value controls the degree of smoothing. – as this parameter goes up, more pixels in the neighborhood are involved in “averaging”, – the image gets more blurred, and – noise is more effectively suppressed 26

  26. Coefficients for filtering mask • In theory, the Gaussian distribution is non-zero everywhere, which would require an infinitely large convolution mask.  • but in practice it is effectively zero more than about three from the mean, and so we can truncate the mask at this point. 0.1299 0.2793 0.3604 0.2793 0.1299 0.2793 0.6004 0.7748 0.6004 0.2793 0.3604 0.7748 1.0000 0.7748 0.3604 0.2793 0.6004 0.7748 0.6004 0.2793 0.1299 0.2793 0.3604 0.2793 0.1299 1299 0.2793 0. Discrete approximation to   Gaussian function with 1 . 4 27

  27. Separating a 2D Gauss filter • 2-D isotropic Gaussian is separable into x and y components. • Thus the 2-D convolution can be performed by first convolving with a 1-D Gaussian in the x direction, and then convolving with another 1-D Gaussian in the y direction. • 1-D x component for the 2D kernel. 0.3604 0.7748 1.0000 0.7748 0.3604 1299 0.2793 0. • The y component is exactly the same but is oriented vertically. 28

  28. Example: Gauss filtering original sigma =1 sigma =2 sigma =3 29

  29. High-Pass Filter    2 f x , y • The Laplacian is a high-pass filter, based on second derivatives.      0 1 0 0 1 0     or      h 1 4 1 h 1 4 1     1 2          0 1 0 0 1 0 • Sum of coefficients is zero • Insight: in areas where the gray values are similar (low- frequency), application of the filter makes the gray values close to zero. 30

  30. Laplace Filter: Demo Laplacian-filtered Original 31

  31. Edge sharpening: Laplace Filter • Laplacian highlights discontinuities, and turn featureless regions into dark background. • How can we make good use of the property? – One example is edge enhancement        2 f x , y f x , y , using h     1 , g x y       2  f x , y f x , y , using h 2 Laplacian original enhanced 32

Recommend


More recommend