Digital Image Processing Image Enhancement Spatial Filtering 1
- Slides: 45
Digital Image Processing Image Enhancement (Spatial Filtering 1) Course Website: http: //www. comp. dit. ie/bmacnamee
2 of 45 Contents In this lecture we will look at spatial filtering techniques: – Neighbourhood operations – What is spatial filtering? – Smoothing operations – What happens at the edges? – Correlation and convolution
3 of 45 What is a Filter? • • • Capabilities of point operations are limited Filters: combine pixel’s value + values of neighbours E. g. blurring: Compute average intensity of block of pixels • Combining multiple pixels needed for certain operations: - Blurring, Smoothing - Sharpening
4 of 45 What Point Operations Can’t Do • Example: sharpening
5 of 45 What Point Operations Can’t Do • Other cool artistic patterns by combining pixels
6 of 45 Neighbourhood Operations - Neighbourhood operations simply operate on a larger neighbourhood of pixels than point operations, Origin x - Neighbourhoods are mostly a rectangle around a central pixel. (x, y) Neighbourhood y Image f (x, y)
7 of 45 Filter Parameters v Many possible filter parameters (size, weights, function, etc) • Filter size (size of neighbourhood): 3 x 3, 5 x 5, 7 x 7, …, 21 x 21, . . • Filter shape: not necessarily square. Can be rectangle, circle, etc • Filter weights: May apply unequal weighting to different pixels • Filters function: can be linear (a weighted summation) or nonlinear
8 of 45 Simple Neighbourhood Operations Some simple neighbourhood operations include: – Min: Set the pixel value to the minimum in the neighbourhood – Max: Set the pixel value to the maximum in the neighbourhood – Median: The median value of a set of numbers is the midpoint value in that set (e. g. from the set [1, 7, 15, 18, 24] 15 is the median). Sometimes the median works better than the average
9 of 45 Simple Neighbourhood Operations Example Original Image Enhanced Image x 123 127 128 119 115 130 145 148 153 167 172 133 154 183 192 194 191 194 199 207 210 198 195 164 170 175 162 173 151 y y x
10 of 45 The Spatial Filtering Process Origin x Simple 3*3 Neighbourhood y e 3*3 Filter Image f (x, y) a b c d e f g h i Original Image Pixels * r s t u v w x y z Filter eprocessed = v*e + r*a + s*b + t*c + u*d + w*f + x*g + y*h + z*i The above is repeated for every pixel in the original image to generate the filtered image
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 11 of 45 Spatial Filtering: Equation Form Filtering can be given in equation form as shown above Notations are based on the image shown to the left
12 of 45 Smoothing Spatial Filters One of the simplest spatial filtering operations we can perform is a smoothing operation – Simply average all of the pixels in a neighbourhood around a central value – Especially useful 1/ 1/ 1/ 9 9 9 in removing noise Simple from images 1/ 1/ 1/ averaging 9 9 9 – Also useful for filter highlighting gross 1/ 1/ 1/ 9 9 9 detail
13 of 45 Smoothing Spatial Filtering Origin x 99 106 98 95 Simple 3*3 Neighbourhood y 1/ 100 1/ 108 1/ 104 9 9 9 1/ 99 9 1 106 /9 198 /9 195 /9 190 /9 185 /9 1/ 104 100 108 90 85 Original Image 3*3 Smoothing Pixels * 9 1/ 9 1/ 9 Filter Image f (x, y) e = 1/9*106 + 1/ *104 + 1/ *100 + 1/ *108 + 9 9 9 1/ *99 + 1/ *98 + 9 9 1/ *95 + 1/ *90 + 1/ *85 9 9 9 = 98. 3333 The above is repeated for every pixel in the original image to generate the smoothed image
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 14 of 45 Image Smoothing Example The image at the top left is an original image of size 500*500 pixels The subsequent images show the image after filtering with an averaging filter of increasing sizes – 3, 5, 9, 15 and 35 Notice how detail begins to disappear
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 15 of 45 Image Smoothing Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 16 of 45 Image Smoothing Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 17 of 45 Image Smoothing Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 18 of 45 Image Smoothing Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 19 of 45 Image Smoothing Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 20 of 45 Image Smoothing Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 21 of 45 Image Smoothing Example
22 of 45 Weighted Smoothing Filters More effective smoothing filters can be generated by allowing different pixels in the neighbourhood different weights in the averaging function – Pixels closer to the central pixel are more important – Often referred to as a weighted averaging 1/ 16 2/ 16 4/ 16 2/ 16 1/ 16 Weighted averaging filter
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 23 of 45 Another Smoothing Example By smoothing the original image we get rid of lots of the finer detail which leaves only the gross features for thresholding Original Image Smoothed Image Thresholded Image
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 24 of 45 The Filter Matrix Filter operation can be expressed as a matrix Example: averaging filter Filter matrix also called filter mask H(i, j)
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 25 of 45 Example: What does this Filter Do? Identity function ( leaves image alone)
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 26 of 45 Example: What does this Filter Do? Mean (averages neighbourhood)
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 27 of 45 Mean Filters: Effect of Filter Size
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 28 of 45 Averaging Filter Vs. Median Filter Example Original Image With Noise Image After Averaging Filter Image After Median Filtering is often used to remove noise from images Sometimes a median filter works better than an averaging filter
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 29 of 45 Averaging Filter Vs. Median Filter Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 30 of 45 Averaging Filter Vs. Median Filter Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 31 of 45 Averaging Filter Vs. Median Filter Example
32 of 45 Simple Neighbourhood Operations Example x 123 127 128 119 115 130 145 148 153 167 172 133 154 183 192 194 191 194 199 207 210 198 195 164 170 175 162 173 151 y
33 of 45 Strange Things Happen At The Edges! At the edges of an image we are missing pixels to form a neighbourhood Origin x e e e y e e Image f (x, y)
34 of 45 Strange Things Happen At The Edges! (cont…) There a few approaches to dealing with missing edge pixels: – Omit missing pixels • Only works with some filters • Can add extra code and slow down processing – Pad the image • Typically with either all white or all black pixels – Replicate border pixels (Extend) – Truncate the image (crop) – Allow pixels wrap around the image • Can cause some strange image artefacts
35 of 45 What to do at image boundaries? Crop
36 of 45 What to do at image boundaries? Pad
37 of 45 What to do at image boundaries? Extend
38 of 45 What to do at image boundaries? Wrap
39 of 45 Simple Neighbourhood Operations Example x 123 127 128 119 115 130 145 148 153 167 172 133 154 183 192 194 191 194 199 207 210 198 195 164 170 175 162 173 151 y
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 40 of 45 Strange Things Happen At The Edges! (cont…) Filtered Image: Zero Padding Original Image Filtered Image: Replicate Edge Pixels Filtered Image: Wrap Around Edge Pixels
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 41 of 45 Strange Things Happen At The Edges! (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 42 of 45 Strange Things Happen At The Edges! (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002) 43 of 45 Strange Things Happen At The Edges! (cont…)
44 of 45 Correlation & Convolution The filtering we have been talking about so far is referred to as correlation with the filter itself referred to as the correlation kernel Convolution is a similar operation, with just one subtle difference a b c d e e f g h Original Image Pixels * r s t u v w x y z eprocessed = v*e + z*a + y*b + x*c + w*d + u*e + t*f + s*g + r*h Filter For symmetric filters it makes no difference
45 of 45 Summary In this lecture we have looked at the idea of spatial filtering and in particular: – Neighbourhood operations – The filtering process – Smoothing filters – Dealing with problems at image edges when using filtering – Correlation and convolution Next time we will looking at sharpening filters and more on filtering and image enhancement
- In digital image processing
- Intensity transformations and spatial filtering
- Spatial filtering
- Image enhancement in spatial domain
- Image enhancement in spatial domain
- Image enhancement in spatial domain
- Image compression models in digital image processing
- Spatial resolution in digital image processing
- Ingress filtering vs egress filtering
- Image enhancement by point processing
- Histogram processing in digital image processing
- Neighborhood averaging in image processing
- Nonlinear image processing
- Point processing in image processing
- Morphological dilation
- Linear filtering in image processing
- Combining spatial enhancement methods
- Combining spatial enhancement methods
- What is enhancement in the spatial domain?
- Histogram equalization
- Combining spatial enhancement methods
- Combining spatial enhancement methods
- Intensity transformation and spatial filtering
- Abbe imaging and spatial filtering experiment
- Doterra taiwan
- Intensity transformations and spatial filtering
- Intensity transformation functions in image processing
- In geometric mean filter when alpha is
- Bahadir gunturk
- Spatial filtering
- Spatial filtering
- Restoration in the presence of noise only-spatial filtering
- Spatial filtering matlab
- Intensity transformation and spatial filtering
- Translate
- Optimum notch filter in image processing
- Key stages in digital image processing
- Objective fidelity criteria
- Image sharpening in digital image processing
- Geometric transformation in digital image processing
- False contouring
- Image transforms in digital image processing
- Image geometry in digital image processing
- Image restoration in digital image processing
- Spatial operations in image processing
- Spatial data vs non spatial data