Wilf LaLonde ©2012 Comp 4501 95.4501 Filters. Wilf LaLonde ©2012 Comp 4501 A filter is a matrix of weights centered on a specific pixel in an image and.

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.
Image Processing Lecture 4
Image Filtering. Outline Outline Concept of image filter  Focus on spatial image filter Various types of image filter  Smoothing, noise reductions 
Image Enhancement in the Frequency Domain Part III
CS 551 / CS 645 Antialiasing. What is a pixel? A pixel is not… –A box –A disk –A teeny tiny little light A pixel is a point –It has no dimension –It occupies.
Digital Image Processing In The Name Of God Digital Image Processing Lecture3: Image enhancement M. Ghelich Oghli By: M. Ghelich Oghli
Lecture 4 Linear Filters and Convolution
1 © 2010 Cengage Learning Engineering. All Rights Reserved. 1 Introduction to Digital Image Processing with MATLAB ® Asia Edition McAndrew ‧ Wang ‧ Tseng.
Image Filtering CS485/685 Computer Vision Prof. George Bebis.
1 Image filtering Hybrid Images, Oliva et al.,
General Functions A non-periodic function can be represented as a sum of sin’s and cos’s of (possibly) all frequencies: F(  ) is the spectrum of the function.
Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain.
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.
CS443: Digital Imaging and Multimedia Filters Spring 2008 Ahmed Elgammal Dept. of Computer Science Rutgers University Spring 2008 Ahmed Elgammal Dept.
Image Enhancement.
1 Image filtering Images by Pawan SinhaPawan Sinha.
Image Analysis Preprocessing Arithmetic and Logic Operations Spatial Filters Image Quantization.
1 Image filtering Hybrid Images, Oliva et al.,
September 25, 2014Computer Vision Lecture 6: Spatial Filtering 1 Computing Object Orientation We compute the orientation of an object as the orientation.
Most slides from Steve Seitz
02/12/02 (c) 2002 University of Wisconsin, CS 559 Filters A filter is something that attenuates or enhances particular frequencies Easiest to visualize.
Image Processing1 Image Filtering Filtering can be use to enhance some features and de- enhance others. Usually used as a pre-processing step.
Image Processing.  a typical image is simply a 2D array of color or gray values  i.e., a texture  image processing takes as input an image and outputs.
Chapter 2. Image Analysis. Image Analysis Domains Frequency Domain Spatial Domain.
CS 376b Introduction to Computer Vision 02 / 26 / 2008 Instructor: Michael Eckmann.
Presentation Image Filters
Machine Vision ENT 273 Image Filters Hema C.R. Lecture 5.
1 Chapter 8: Image Restoration 8.1 Introduction Image restoration concerns the removal or reduction of degradations that have occurred during the acquisition.
Digital Image Processing Chapter # 4 Image Enhancement in Frequency Domain Digital Image Processing Chapter # 4 Image Enhancement in Frequency Domain.
Filtering Robert Lin April 29, Outline Why filter? Filtering for Graphics Sampling and Reconstruction Convolution The Fourier Transform Overview.
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.
Image Processing Edge detection Filtering: Noise suppresion.
09/19/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Dithering.
Image processing Fourth lecture Image Restoration Image Restoration: Image restoration methods are used to improve the appearance of an image.
Chapter 5: Neighborhood Processing
Lecture 5 Mask/Filter Transformation 1.The concept of mask/filters 2.Mathematical model of filtering Correlation, convolution 3.Smoother filters 4.Filter.
Image Subtraction Mask mode radiography h(x,y) is the mask.
CSC508 Convolution Operators. CSC508 Convolution Arguably the most fundamental operation of computer vision It’s a neighborhood operator –Similar to the.
Autonomous Robots Vision © Manfred Huber 2014.
Intelligent Vision Systems ENT 496 Image Filtering and Enhancement Hema C.R. Lecture 4.
02/05/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Mach Banding –Humans exaggerate sharp boundaries, but not fuzzy ones.
Digital Image Processing Lecture 5: Neighborhood Processing: Spatial Filtering March 9, 2004 Prof. Charlene Tsai.
Sejong Univ. CH3. Area Processes Convolutions Blurring Sharpening Averaging vs. Median Filtering.
(c) 2002 University of Wisconsin, CS 559
: Chapter 5: Image Filtering 1 Montri Karnjanadecha ac.th/~montri Image Processing.
CSE 185 Introduction to Computer Vision Image Filtering: Spatial Domain.
Non-linear filtering Example: Median filter Replaces pixel value by median value over neighborhood Generates no new gray levels.
Image Processing Intro2CS – week 6 1. Image Processing Many devices now have cameras on them Lots of image data recorded for computers to process. But.
Filters– Chapter 6. Filter Difference between a Filter and a Point Operation is that a Filter utilizes a neighborhood of pixels from the input image to.
Spatial Filtering (Chapter 3) CS474/674 - Prof. Bebis.
Image Subtraction Mask mode radiography h(x,y) is the mask.
Image Pre-Processing in the Spatial and Frequent Domain
General Functions A non-periodic function can be represented as a sum of sin’s and cos’s of (possibly) all frequencies: F() is the spectrum of the function.
Image filtering Hybrid Images, Oliva et al.,
Image filtering Images by Pawan Sinha.
Image filtering Images by Pawan Sinha.
Image filtering Images by Pawan Sinha.
Digital Image Processing Week IV
Most slides from Steve Seitz
Image filtering Images by Pawan Sinha.
Image filtering
Image filtering
Magnetic Resonance Imaging
Lecture 2: Image filtering
Intensity Transformation
Image Filtering Readings: Ch 5: 5. 4, 5. 5, 5. 6, , 5
Image Filtering with GLSL
Presentation transcript:

Wilf LaLonde ©2012 Comp Filters

Wilf LaLonde ©2012 Comp 4501 A filter is a matrix of weights centered on a specific pixel in an image and used to produce a weighted average as follows. The center weight is multiplied with the pixel, the other weights are multiplied with corresponding neighbor pixels. The results are added and divided by the sum of the weights (or, avoid the divide by using normalized weights; i.e., pre-divided). What’s a Filter? [ ] [ ] [ ] 3x3 identity filter

Wilf LaLonde ©2012 Comp 4501 This filtering operation applied to each pixel of an image is called a convolution (if the filter is symmetrical) or correlation otherwise. More complex filters, that can use fancier functions, exist as well. What’s a Filter?

Wilf LaLonde ©2012 Comp 4501 If the sampler can be indexed via image sized texture coordinates (otherwise, *pixelSize ). float3 fillterResult = float4 (0.0, 0.0, 0.0); for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { fillterResult += sampler (uv.xy + float2 (i,j) ).xyz * filterWeight [i,j]; } } How filters Get Used: Let Compiler Loop Unroll Filter result is the answer: assuming normalized weights

Wilf LaLonde ©2012 Comp 4501 If the sampler can be indexed via image sized texture coordinates (otherwise, *pixelSize ). float3 fillterResult = sampler (uv.xy + float2 (-1,-1)).xyz * filterWeight [-1,-1] + sampler (uv.xy + float2 (-1, 0)).xyz * filterWeight [-1, 0] + sampler (uv.xy + float2 (-1,+1)).xyz * filterWeight [-1,+1] + sampler (uv.xy + float2 ( 0,-1)).xyz * filterWeight [ 0,-1] + sampler (uv.xy + float2 ( 0, 0)).xyz * filterWeight [ 0, 0] + sampler (uv.xy + float2 ( 0,+1)).xyz * filterWeight [ 0,+1] + sampler (uv.xy + float2 (+1,-1)).xyz * filterWeight [+1,-1] + sampler (uv.xy + float2 (+1, 0)).xyz * filterWeight [+1, 0] + sampler (uv.xy + float2 (+1,+1)).xyz * filterWeight [+1,+1]; How filters Get Used: Unroll Loop Yourself Filter result is the answer: assuming normalized weights

Wilf LaLonde ©2012 Comp 4501 An odd size filter looks cleaner but even size works too (consistently applying right and down, for example)... sum of normalized weights  1  brighter image sum of normalized weights  1  darker image A Few Observations Weight 0.25 [x, y][x+1, y] [x, y+1][x+1, y+1] right and up for OpenGL right and down for DirectX

Wilf LaLonde ©2012 Comp 4501 Indexing off the end is can be handled with 0 weight automatically via a clamping sampler Filtered results are sometimes clamped to the bounds of the application; e.g., 0 and 1 for color. A Few Observations

Wilf LaLonde ©2012 Comp 4501 A Blur Filter (Minimal Blur) [ ] [ ] [ ] 3x3 blur filter from LODEV.org Use normalizing factor 1/5 =

Wilf LaLonde ©2012 Comp 4501 A Blur Filter (More Noticeable Blur) [ ] [ ] [ ] [ ] [ ] 5x5 blur filter from LODEV.org 1 13 Use normalizing factor 1/13 = 0.077

Wilf LaLonde ©2012 Comp 4501 A 45 Degree Motion Blur Filter [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] 9x9 motion blur filter from LODEV.org Use normalizing factor 1/9 =

Wilf LaLonde ©2012 Comp 4501 A Horizontal Edge Finding Filter [ ] [ ] [ ] [ ] [ ] 5x5 horizontal edge finding filter from LODEV.org dark since weights sum to 0 deliberately non-symmetric just to see

Wilf LaLonde ©2012 Comp 4501 A Vertical Edge Finding Filter [ ] [ ] [ ] [ ] [ ] 5x5 vertical edge finding filter from LODEV.org dark since weights sum to 0

Wilf LaLonde ©2012 Comp 4501 A 45 Degree Edge Finding Filter [ ] [ ] [ ] [ ] [ ] 5x5 45 degree edge finding filter from LODEV.org dark since weights sum to 0

Wilf LaLonde ©2012 Comp 4501 An Edge Detection Filter [ ] [ ] [ ] 3x3 edge detection filter from LODEV.org dark since weights sum to 0

Wilf LaLonde ©2012 Comp 4501 A Sharpening Filter [ ] [ ] [ ] 3x3 sharpening filter from LODEV.org note that sum is 1

Wilf LaLonde ©2012 Comp 4501 A More Subtle Sharpening Filter [ ] [ ] [ ] [ ] [ ] 5x5 subtle shapening filter from LODEV.org 1 8 Use normalizing factor 1/8 = 0.125

Wilf LaLonde ©2012 Comp 4501 An Excessive Sharpening Filter [1 1 1] [1 -7 1] [1 1 1] 3x3 excessive sharpening filter from LODEV.org note that sum is 1

Wilf LaLonde ©2012 Comp 4501 A 45 Degree Embossing Filter [ ] [-1 0 1] [ 0 1 1] 3x3 45 degree embossing filter from LODEV.org 0.5 +

Wilf LaLonde ©2012 Comp 4501 A 45 Degree Embossing GRAY SCALED Filter [ ] [-1 0 1] [0 1 1] 3x3 45 degree embossing filter from LODEV.org NO CHANGE IN FILTER BUT MAKE GREEN AND BLUE = RED 0.5 +

Wilf LaLonde ©2012 Comp 4501 A More Exaggerated Emboss Filter [ ] [ ] [ ] [ ] [ ] 5x5 exaggerated emboss filter from LODEV.org 0.5 +

Wilf LaLonde ©2012 Comp 4501 A Mean Filter (Average or blur removes PEPPER) [ ] [ ] [ ] 3x3 mean filter removes PEPPER by bluring from LODEV.org 1 9 Use normalizing factor 1/9 = Also called a BOX FILTER

Wilf LaLonde ©2012 Comp 4501 A Median Filter (Uses Middle in Sorted Result) [ ] [ ] [ ] Slightly better looking de-PEPPERING and blurring (I can’t see it) from LODEV.org the middle value after x-sorting and y-sorting 1 9

Wilf LaLonde ©2012 Comp 4501 A Median Filter 3x35x5 9x915x15

Wilf LaLonde ©2012 Comp 4501 Gaussian Filters Based on the gaussian distribution

Wilf LaLonde ©2012 Comp A Crude Approximation of A Gaussian Filter

Wilf LaLonde ©2012 Comp 4501 Another One Source:Stephen Chenney University of Wisconsin

Wilf LaLonde ©2012 Comp 4501 A More Exact Gaussian Filter For  =

Wilf LaLonde ©2012 Comp 4501 Gaussian Filter Uses Noise reduction blur...

Wilf LaLonde ©2012 Comp 4501 Provides random sample points where each point is at least distance r apart... Poisson Filter (Randomized Points)

Wilf LaLonde ©2012 Comp 4501 Provide image size nxn, the minimum distance r between samples (e.g., r = 1.8 pixels), and the maximum number of attempts k per sample (e.g., k = 30). Initialize a 2D nxn grid with -1, a list of samples initially empty, and a stack of unprocessed indices. Randomly choose a sample x 0, add x 0 to samples, and 0 to indices. Algorithm To Build Random 2D Samples continued on next slide

Wilf LaLonde ©2012 Comp 4501 While indices is not empty Remove i from indices. for (j = 0; j < k; j++) { p = generate random point between radius r and 2r around x i. if (p is further than r from each point in samples) { Add p to samples and its index to indices } } Algorithm To Build Random 2D Samples Fast Poisson Disk Sampling in Arbitrary Dimensions, Bridson, R., ACM SIGGRAPH 2007 Sketches Program Wilf: There’s a better way to present this (see filter tutorial)...

Wilf LaLonde ©2012 Comp 4501 float3 poissonSample (sampler texture, float2 uv, float2 pixelSize, float discRadius) { float2 offsets = {float2 (...), float2 (...),...}; float average = tex2D (texture, uv); for (int tap = 0; tap < 12; tap++) { average += tex2D (texture, uv + offsets [tap] * (discRadius * pixelSize); } return average / 13.0; } Can Find Prebuilt Poisson Filters on Internet Heat and Haze Post-Processing Effects, Oat and Tatarchuk, Game Programming Gems 4, 2004 next slide

Wilf LaLonde ©2012 Comp 4501 float2 offsets = { float2 ( , ), float2 ( , ), float2 ( , ), float2 ( , ), float2 ( , ), float2 ( , ), float2 ( , ), float2 ( , ), float2 ( , ), float2 ( , ), float2 ( , ), float2 ( , ), }; Rest of poissonSample Shader Function

Wilf LaLonde ©2012 Comp 4501 Relates the filter capability to what happens in the frequency domain (fourier transforms) Low-pass filter lets low frequencies through which eliminates speckles and sharp discontinuities. High-pass filter lets high frequencies through, an edge detector. Engineering Terminology

Wilf LaLonde ©2012 Comp 4501 Source:Stephen Chenney University of Wisconsin Box Filter Box filters by averaging neighbors (so it smooths) In frequency domain, keeps low frequencies and attenuates high frequencies (so it’s a low-pass filter) Spatial domain: boxfrequency domain: sinc

Wilf LaLonde ©2012 Comp 4501 Bartlett Filter Triangle shaped filter in spatial domain ( attenuates high frequencies less than a gaussian filter). In frequency domain, product of two box filters (so attenuates high frequencies more than a box). spatial domain: trianglefrequency domain: sinc 2 Source:Stephen Chenney University of Wisconsin

Wilf LaLonde ©2012 Comp 4501 A filter is a matrix of weights centered on a specific pixel in an image and used to produce some sort of weighted average. A host of different effects result from weighting the filters differently... Conclusion