Digital Image Processing

Slides:



Advertisements
Similar presentations
Basis beeldverwerking (8D040) dr. Andrea Fuster dr. Anna Vilanova Prof.dr.ir. Marcel Breeuwer Filtering.
Advertisements

Linear Filtering – Part I Selim Aksoy Department of Computer Engineering Bilkent University
Spatial Filtering (Chapter 3)
Topic 6 - Image Filtering - I DIGITAL IMAGE PROCESSING Course 3624 Department of Physics and Astronomy Professor Bob Warwick.
Digital Image Processing
Image Processing Lecture 4
CS & CS Multimedia Processing Lecture 2. Intensity Transformation and Spatial Filtering Spring 2009.
Spatial Filtering.
Chapter 3 Image Enhancement in the Spatial Domain.
Lecture 6 Sharpening Filters
DREAM PLAN IDEA IMPLEMENTATION Introduction to Image Processing Dr. Kourosh Kiani
Digital Image Processing
Digital Image Processing In The Name Of God Digital Image Processing Lecture3: Image enhancement M. Ghelich Oghli By: M. Ghelich Oghli
Chapter 3: Image Enhancement in the Spatial Domain
Multimedia communications EG 371Dr Matt Roach Multimedia Communications EG 371 and EE 348 Dr Matt Roach Lecture 6 Image processing (filters)
6/9/2015Digital Image Processing1. 2 Example Histogram.
Digital Image Processing
1 Image Filtering Readings: Ch 5: 5.4, 5.5, 5.6,5.7.3, 5.8 (This lecture does not follow the book.) Images by Pawan SinhaPawan Sinha formal terminology.
Lecture 2. Intensity Transformation and Spatial Filtering
ECE 472/572 - Digital Image Processing Lecture 4 - Image Enhancement - Spatial Filter 09/06/11.
Chapter 3 (cont).  In this section several basic concepts are introduced underlying the use of spatial filters for image processing.  Mainly spatial.
Neighborhood Operations
Spatial Filtering: Basics
Image Restoration and Reconstruction (Noise Removal)
Digital Image Processing Image Enhancement Part IV.
University of Ioannina - Department of Computer Science Intensity Transformations (Point Processing) Christophoros Nikou Digital Image.
Digital Image Processing (DIP)
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell Image processing.
Introduction to Image Processing Grass Sky Tree ? ? Sharpening Spatial Filters.
Digital Image Processing Lecture 5: Neighborhood Processing: Spatial Filtering Prof. Charlene Tsai.
Lecture 03 Area Based Image Processing Lecture 03 Area Based Image Processing Mata kuliah: T Computer Vision Tahun: 2010.
Introduction to Image Processing
Image Processing is replacing Original Pixels by new Pixels using a Transform rst uvw xyz Origin x y Image f (x, y) e processed = v *e + r *a + s *b +
انجمن دانشجویان ایران – مرجع دانلود کتاب ، نمونه سوال و جزوات درسی
Digital Image Processing Lecture 10: Image Restoration March 28, 2005 Prof. Charlene Tsai.
Course Website: Digital Image Processing Image Enhancement (Spatial Filtering 1)
Digital Image Processing Lecture 10: Image Restoration
Spatial Filtering.
Digital Image Processing, 3rd ed. © 1992–2008 R. C. Gonzalez & R. E. Woods Gonzalez & Woods Chapter 3 Intensity Transformations.
Digital Image Processing Lecture 16: Segmentation: Detection of Discontinuities Prof. Charlene Tsai.
Mestrado em Ciência de Computadores Mestrado Integrado em Engenharia de Redes e Sistemas Informáticos VC 15/16 – TP7 Spatial Filters Miguel Tavares Coimbra.
Digital Image Processing Lecture 5: Neighborhood Processing: Spatial Filtering March 9, 2004 Prof. Charlene Tsai.
Digital Image Processing Lecture 16: Segmentation: Detection of Discontinuities May 2, 2005 Prof. Charlene Tsai.
Machine Vision Edge Detection Techniques ENT 273 Lecture 6 Hema C.R.
Instructor: Mircea Nicolescu Lecture 7
Digital Image Processing
Sharpening Spatial Filters ( high pass)  Previously we have looked at smoothing filters which remove fine detail  Sharpening spatial filters seek to.
Digital Image Processing Week V Thurdsak LEAUHATONG.
Digital Image Processing CSC331
Spatial Filtering (Chapter 3) CS474/674 - Prof. Bebis.
Image Enhancement in the Spatial Domain.
Environmental Remote Sensing GEOG 2021
Miguel Tavares Coimbra
Fundamentals of Spatial Filtering:
Digital Image Processing CSC331
Digital Image Processing Lecture 16: Segmentation: Detection of Discontinuities Prof. Charlene Tsai.
Digital Image Processing Lecture 10: Image Restoration
ECE 692 – Advanced Topics in Computer Vision
Digital Image Processing
IMAGE PROCESSING INTENSITY TRANSFORMATION AND SPATIAL FILTERING
Digital Image Processing
Lecture 10 Image sharpening.
CIS 350 – 3 Image ENHANCEMENT SPATIAL DOMAIN
Digital Image Processing
Digital Image Processing
Digital Image Processing Week IV
Interesting article in the March, 2006 issue of Wired magazine
Digital Image Processing
Image Filtering Readings: Ch 5: 5. 4, 5. 5, 5. 6, , 5
Presentation transcript:

Digital Image Processing Spatial Filtering Christophoros Nikou cnikou@cs.uoi.gr

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 Sharpening filters Combining filtering techniques

Neighbourhood Operations Neighbourhood operations simply operate on a larger neighbourhood of pixels than point operations Neighbourhoods are mostly a rectangle around a central pixel Any size rectangle and any shape filter are possible Origin x y Image f (x, y) (x, y) Neighbourhood

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

Simple Neighbourhood Operations Example 123 127 128 119 115 130 140 145 148 153 167 172 133 154 183 192 194 191 199 207 210 198 195 164 170 175 162 173 151 Original Image x y Enhanced Image x y

The Spatial Filtering Process Origin x a b c d e f g h i r s t u v w x y z * Original Image Pixels Filter Simple 3*3 Neighbourhood e 3*3 Filter eprocessed = v*e + r*a + s*b + t*c + u*d + w*f + x*g + y*h + z*i y Image f (x, y) The above is repeated for every pixel in the original image to generate the filtered image

Spatial Filtering: Equation Form Images taken from Gonzalez & Woods, Digital Image Processing (2002) Filtering can be given in equation form as shown above Notations are based on the image shown to the left

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 in removing noise from images Also useful for highlighting gross detail 1/9 Simple averaging filter

Smoothing Spatial Filtering Origin x 104 100 108 99 106 98 95 90 85 1/9 * Original Image Pixels Filter 1/9 104 99 95 100 108 98 90 85 Simple 3*3 Neighbourhood 3*3 Smoothing Filter 106 e = 1/9*106 + 1/9*104 + 1/9*100 + 1/9*108 + 1/9*99 + 1/9*98 + 1/9*95 + 1/9*90 + 1/9*85 = 98.3333 y Image f (x, y) The above is repeated for every pixel in the original image to generate the smoothed image.

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)

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 Weighted averaging filter

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 Images taken from Gonzalez & Woods, Digital Image Processing (2002) Original Image Smoothed Image Thresholded Image

Averaging Filter Vs. Median Filter Example Original Image With Noise Image After Averaging Filter Image After Median Filter Images taken from Gonzalez & Woods, Digital Image Processing (2002) Filtering is often used to remove noise from images Sometimes a median filter works better than an averaging filter

Spatial smoothing and image approximation Spatial smoothing may be viewed as a process for estimating the value of a pixel from its neighbours. What is the value that “best” approximates the intensity of a given pixel given the intensities of its neighbours? We have to define “best” by establishing a criterion. Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Spatial smoothing and image approximation (cont...) A standard criterion is the the sum of squares differences. Images taken from Gonzalez & Woods, Digital Image Processing (2002) The average value

Spatial smoothing and image approximation (cont...) Another criterion is the the sum of absolute differences. Images taken from Gonzalez & Woods, Digital Image Processing (2002) There must be equal in quantity positive and negative values.

Spatial smoothing and image approximation (cont...) The median filter is non linear: It works well for impulse noise (e.g. salt and pepper). It requires sorting of the image values. It preserves the edges better than an average filter in the case of impulse noise. It is robust to impulse noise at 50%. Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Spatial smoothing and image approximation (cont...) Example x[n] 1 2 Images taken from Gonzalez & Woods, Digital Image Processing (2002) edge Impulse noise x[n] 1 3 2 Median (N=3) x[n] - 1 2 Average (N=3) x[n] - 1.7 1 1.3 2 2.3 2.2 The edge is smoothed

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 e e e e y Image f (x, y)

Strange Things Happen At The Edges! (cont…) There are 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 Truncate the image Allow pixels wrap around the image Can cause some strange image artefacts

Strange Things Happen At The Edges! (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) Filtered Image: Zero Padding Original Image Filtered Image: Replicate Edge Pixels Filtered Image: Wrap Around Edge Pixels

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 For symmetric filters it makes no difference. a b c d e f g h Original Image Pixels r s t u v w x y z Filter eprocessed = v*e + z*a + y*b + x*c + w*d + u*e + t*f + s*g + r*h *

Effect of Low Pass Filtering on White Noise Let f be an observed instance of the image f0 corrupted by noise w: with noise samples having mean value E[w(n)]=0 and being uncorrelated with respect to location:

Effect of Low Pass Filtering on White Noise (cont...) Applying a low pass filter h (e.g. an average filter) by convolution to the degraded image: The expected value of the output is: The noise is removed in average.

Effect of Low Pass Filtering on White Noise (cont...) What happens to the standard deviation of g? Let where the bar represents filtered versions of the signals, then

Effect of Low Pass Filtering on White Noise (cont...) Considering that h is an average filter, we have at pixel n: Therefore,

Effect of Low Pass Filtering on White Noise (cont...) Sum of squares Cross products

Effect of Low Pass Filtering on White Noise (cont...) Sum of squares Cross products (uncorrelated as ml)

Effect of Low Pass Filtering on White Noise (cont...) Finally, substituting the partial results: The effect of the noise is reduced. This processing is not optimal as it also smoothes image edges.

Sharpening Spatial Filters Previously we have looked at smoothing filters which remove fine detail Sharpening spatial filters seek to highlight fine detail Remove blurring from images Highlight edges Sharpening filters are based on spatial differentiation

Spatial Differentiation Differentiation measures the rate of change of a function Let’s consider a simple 1 dimensional example Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Spatial Differentiation Images taken from Gonzalez & Woods, Digital Image Processing (2002) A B

Derivative Filters Requirements First derivative filter output Zero at constant intensities Non zero at the onset of a step or ramp Non zero along ramps Second derivative filter output Non zero at the onset and end of a step or ramp Zero along ramps of constant slope

1st Derivative The formula for the 1st derivative of a function is as follows: It’s just the difference between subsequent values and measures the rate of change of the function

1st Derivative (cont.) The gradient of an image: The gradient points in the direction of most rapid increase in intensity. Gradient direction The edge strength is given by the gradient magnitude Source: Steve Seitz

1st Derivative (cont.)

1st Derivative (cont…) 5 4 3 2 1 6 7 -1 6 -6 1 2 -2 7

2nd Derivative The formula for the 2nd derivative of a function is as follows: Simply takes into account the values both before and after the current value

2nd Derivative (cont…) 5 4 3 2 1 6 7 -1 1 6 -12 -4 7 -7

Using Second Derivatives For Image Enhancement Edges in images are often ramp-like transitions 1st derivative is constant and produces thick edges 2nd derivative zero crosses the edge (double response at the onset and end with opposite signs) A common sharpening filter is the Laplacian Isotropic One of the simplest sharpening filters We will look at a digital implementation

The Laplacian The Laplacian is defined as follows: where the partial 1st order derivative in the x direction is defined as follows: and in the y direction as follows:

The Laplacian (cont…) So, the Laplacian can be given as follows: We can easily build a filter based on this 1 -4

The Laplacian (cont…) Applying the Laplacian to an image we get a new image that highlights edges and other discontinuities Images taken from Gonzalez & Woods, Digital Image Processing (2002) Original Image Laplacian Filtered Image Laplacian Filtered Image Scaled for Display

But That Is Not Very Enhanced! The result of a Laplacian filtering is not an enhanced image We have to do more work in order to get our final image Subtract the Laplacian result from the original image to generate our final sharpened enhanced image Laplacian Filtered Image Scaled for Display Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Laplacian Image Enhancement Images taken from Gonzalez & Woods, Digital Image Processing (2002) - = Original Image Laplacian Filtered Image Sharpened Image In the final sharpened image edges and fine detail are much more obvious

Laplacian Image Enhancement Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Simplified Image Enhancement The entire enhancement can be combined into a single filtering operation

Simplified Image Enhancement (cont…) This gives us a new filter which does the whole job for us in one step Images taken from Gonzalez & Woods, Digital Image Processing (2002) -1 5

Simplified Image Enhancement (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Variants On The Simple Laplacian There are lots of slightly different versions of the Laplacian that can be used: Images taken from Gonzalez & Woods, Digital Image Processing (2002) 1 -4 1 -8 Simple Laplacian Variant of Laplacian -1 9

Unsharp masking Used by the printing industry Subtracts an unsharped (smooth) image from the original image f(x,y). Blur the image b(x,y)=Blur{f(x,y)} Subtract the blurred image from the original (the result is called the mask) gmask(x,y)=f(x,y)-b(x,y) Add the mask to the original g(x,y)=f(x,y)+k gmask(x,y) with k non negative Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Unsharp masking (cont...) Images taken from Gonzalez & Woods, Digital Image Processing (2002) Sharping mechanism When k>1 the process is referred to as highboost filtering

Unsharp masking (cont...) Original image Images taken from Gonzalez & Woods, Digital Image Processing (2002) Blurred image Mask Unsharp masking Highboost filtering (k=4.5)

1st Derivative Filtering Implementing 1st derivative filters is difficult in practice For a function f(x, y) the gradient of f at coordinates (x, y) is given as the column vector:

1st Derivative Filtering (cont…) The magnitude of this vector is given by: For practical reasons this can be simplified as:

1st Derivative Filtering (cont…) There is some debate as to how best to calculate these gradients but we will use: which is based on these coordinates z1 z2 z3 z4 z5 z6 z7 z8 z9

Sobel Operators Based on the previous equations we can derive the Sobel Operators To filter an image it is filtered using both operators the results of which are added together -1 -2 1 2 -1 1 -2 2

Sobel Example Sobel filters are typically used for edge detection Images taken from Gonzalez & Woods, Digital Image Processing (2002) An image of a contact lens which is enhanced in order to make defects (at four and five o’clock in the image) more obvious

1st & 2nd Derivatives Comparing the 1st and 2nd derivatives we can conclude the following: 1st order derivatives generally produce thicker edges (if thresholded at ramp edges) 2nd order derivatives have a stronger response to fine detail e.g. thin lines 1st order derivatives have stronger response to grey level step 2nd order derivatives produce a double response at step changes in grey level (which helps in detecting zero crossings)

Combining Spatial Enhancement Methods Successful image enhancement is typically not achieved using a single operation Rather we combine a range of techniques in order to achieve a final result This example will focus on enhancing the bone scan to the right Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Combining Spatial Enhancement Methods (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) (a) Laplacian filter of bone scan (a) (b) Sharpened version of bone scan achieved by subtracting (a) and (b) (c) Sobel filter of bone scan (a) (d)

Combining Spatial Enhancement Methods (cont…) Result of applying a power-law trans. to (g) (h) Images taken from Gonzalez & Woods, Digital Image Processing (2002) Sharpened image which is sum of (a) and (f) (g) The product of (c) and (e) which will be used as a mask (f) (e) Image (d) smoothed with a 5*5 averaging filter

Combining Spatial Enhancement Methods (cont…) Compare the original and final images Images taken from Gonzalez & Woods, Digital Image Processing (2002)

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 Sharpening filters Combining filtering techniques