Spatial Filtering: Basics

Slides:



Advertisements
Similar presentations
Linear Filtering – Part I Selim Aksoy Department of Computer Engineering Bilkent University
Advertisements

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
CS & CS Multimedia Processing Lecture 2. Intensity Transformation and Spatial Filtering Spring 2009.
Spatial Filtering.
Image Filtering. Outline Outline Concept of image filter  Focus on spatial image filter Various types of image filter  Smoothing, noise reductions 
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
Image Enhancement in the Spatial Domain II Jen-Chang Liu, 2006.
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
6/9/2015Digital Image Processing1. 2 Example Histogram.
1 Image filtering Hybrid Images, Oliva et al.,
Median Filter If the objective is to achieve noise reduction rather than blurring, an alternative approach is to use median filters. That is, the gray.
2007Theo Schouten1 Enhancements Techniques for editing an image such that it is more suitable for a specific application than the original image. Spatial.
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.
1 Lecture 12 Neighbourhood Operations (2) TK3813 DR MASRI AYOB.
CS443: Digital Imaging and Multimedia Filters Spring 2008 Ahmed Elgammal Dept. of Computer Science Rutgers University Spring 2008 Ahmed Elgammal Dept.
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.
Presentation Image Filters
Neighborhood Operations
: Office Room #:: 7
Digital Image Processing Image Enhancement Part IV.
Digital Image Processing
Digital Image Processing (DIP)
Linear Filtering – Part I Selim Aksoy Department of Computer Engineering Bilkent University
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 +
Course Website: Digital Image Processing Image Enhancement (Spatial Filtering 1)
Lecture 5 Mask/Filter Transformation 1.The concept of mask/filters 2.Mathematical model of filtering Correlation, convolution 3.Smoother filters 4.Filter.
Spatial Filtering.
Digital Image Processing, 3rd ed. © 1992–2008 R. C. Gonzalez & R. E. Woods Gonzalez & Woods Chapter 3 Intensity Transformations.
Image Subtraction Mask mode radiography h(x,y) is the mask.
COMP322/S2000/L171 Robot Vision System Major Phases in Robot Vision Systems: A. Data (image) acquisition –Illumination, i.e. lighting consideration –Lenses,
CSC508 Convolution Operators. CSC508 Convolution Arguably the most fundamental operation of computer vision It’s a neighborhood operator –Similar to the.
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.
Machine Vision Edge Detection Techniques ENT 273 Lecture 6 Hema C.R.
Digital Filters. What are they?  Local operation (neighborhood operation in GIS terminology) by mask, window, or kernel (different words for the same.
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.
Miguel Tavares Coimbra
Image Pre-Processing in the Spatial and Frequent Domain
ECE 692 – Advanced Topics in Computer Vision
Filtering – Part I Gokberk Cinbis Department of Computer Engineering
Digital Image Processing
Digital Image Processing
Lecture 10 Image sharpening.
Digital Image Processing
Digital Image Processing
Digital Image Processing Week IV
Interesting article in the March, 2006 issue of Wired magazine
Digital Image Processing
Department of Computer Engineering
Lecture 7 Spatial filtering.
Digital Filters.
Image Enhancement in the Spatial Domain
Presentation transcript:

Spatial Filtering: Basics Origin x y Image f (x, y) (x, y) Neighbourhood Neighbourhood operations: Operate on a larger neighbourhood of pixels than point operations Neighbourhoods are mostly a rectangle around a central pixel 1 1

Spatial Filtering: Basics 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 2 2

Spatial Filtering: Basics Moving window (kernel) scans the 3x3 neighborhood of every pixel in the image Original Image 3 3

Spatial Filtering: Basics 4 4

Spatial Filtering: Basics 5 5

Spatial Filtering: Basics 6 6

Spatial Filtering: Basics 7 7

Spatial Filtering: Basics 8 8

Spatial Filtering: Basics Mask operation near the image border: Problem arises when part of the mask is located outside the image plane Discard the problem pixels (e.g. 512x512 input 510x510 output if mask size is 3x3) Pixel replication: We normally use the gray levels of border pixels to fill up the expanded region (for 3x3 mask). For larger masks a border region equal to half of the mask size is mirrored on the expanded region. Zero padding: Expand the input image by padding zeros (512x512 original image, 514x514 padded image, 512x512 output) Zero padding is not recommended as it creates artificial lines or edges on the border 9 9

Spatial Filtering: Basics The output intensity value at (x,y) depends not only on the input intensity value at (x,y) but also on the specified number of neighboring intensity values around (x,y) Spatial masks (also called window, filter, kernel, template) are used and convolved over the entire image for local enhancement (spatial filtering) The size of the masks determines the number of neighboring pixels which influence the output value at (x,y) The values (coefficients) of the mask determine the nature and properties of enhancing technique 10 10

Spatial Filtering: Basics Given the 3×3 mask with coefficients: w1, w2,…, w9 The mask cover the pixels with gray levels: z1, z2,…, z9 z gives the output intensity value for the processed image (to be stored in a new array) at the location of z5 in the input image w1 w2 w3 w4 w5 w6 w7 w8 w9 z1 z2 z3 z4 z5 z6 z7 z8 z9 11 11

Smoothing Spatial Filters For blurring/noise reduction Blurring is usually used in preprocessing steps, e.g., to remove small details from an image prior to object extraction, or to bridge small gaps in lines or curves Equivalent to Low-pass spatial filtering in frequency domain because smaller (high frequency) details are removed based on neighborhood averaging (averaging filters) 12 12

Smoothing Spatial Filters Simply average all of the pixels in a neighbourhood around a central value 1/9 Simple averaging filter 13 13

Spatial Filtering: Basics 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 14 14

Smoothing Spatial Filters Consider the output pixel is positioned at the center Box Filter all coefficients are equal Weighted Average give more (less) weight to near (away from) the output location 15 15

Notice how detail begins to disappear Original image Size: 500x500 Smooth by 3x3 box filter Smooth by 5x5 box filter Smooth by 9x9 box filter Smooth by 35x35 box filter Smooth by 15x15 box filter Notice how detail begins to disappear 16 16

Order-Statistic Filtering Output is based on order of gray levels in the masked area 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 17 17

Median Filtering 20 Particularly effective when Sort the values Determine the median Median = ? 20 Particularly effective when The noise pattern consists of strong impulse noise ( salt-and-pepper) 18 18

Median Filtering 19 19

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 Let’s consider a simple 1 dimensional example

Spatial Differentiation B

1st Derivative The 1st derivative of a function is given by: Its just the difference between subsequent values and measures the rate of change of the function

1st Derivative 5 4 3 2 1 6 7 -1 6 -6 1 2 -2 7

2nd Derivative The 2nd derivative of a function is given by: Simply takes into account the values both before and after the current value

2nd Derivative 5 4 3 2 1 6 7 -1 6 -6 1 2 -2 7 -1 1 6 -12 -4 7 -7

2nd Derivative for Image Enhancement The 2nd derivative is more useful for image enhancement than the 1st derivative - Stronger response to fine detail We will come back to the 1st order derivative later on The first sharpening filter we will look at is the Laplacian

Laplacian Filter The Laplacian is defined as follows:

Laplacian Filter So, the Laplacian can be given as follows: 1 -4 Can we implement it using a filter/ mask?

Laplacian Filter

Laplacian Filter Applying the Laplacian to an image we get a new image that highlights edges and other discontinuities Original Image Laplacian Filtered Image Laplacian Filtered Image Scaled for Display

Laplacian Image Enhancement Laplacian Filtered Image Scaled for Display The result of a Laplacian filtering is not an enhanced image To generate the final enhanced image

Laplacian Image Enhancement - = Original Image Laplacian Filtered Image Sharpened Image In the final sharpened image edges and fine detail are much more obvious

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

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

Simplified Image Enhancement This gives us a new filter which does the whole job for us in one step -1 5

Use of first derivatives for image enhancement: The Gradient The gradient of a function f(x,y) is defined as

Use of first derivatives for image enhancement: The Gradient The magnitude of this vector is given by: For practical reasons this can be simplified as:

Gradient Operators There is some debate as to how best to calculate these gradients Simplest Operator y x

Extract vertical edges Gradient Operators Prewitt Operator -1 1 -1 1 Extract horizontal edges Extract vertical edges

Gradient Operators Sobel Operator -1 -2 1 2 -1 1 -2 2 1 2 -1 1 -2 2 Extract horizontal edges Extract vertical edges Emphasize more the current point (x direction) Emphasize more the current point (y direction) Pixel Arrangement

Sobel Operator: Example Sobel filters are typically used for edge detection An image of a contact lens which is enhanced in order to make defects more obvious