CS4442/9542b Artificial Intelligence II prof. Olga Veksler

Similar documents
CS4442/9542b Artificial Intelligence II prof. Olga Veksler

2D Image Processing INFORMATIK. Kaiserlautern University. DFKI Deutsches Forschungszentrum für Künstliche Intelligenz

Filters and Pyramids. CSC320: Introduction to Visual Computing Michael Guerzhoy. Many slides from Steve Marschner, Alexei Efros

Lecture 2 Image Processing and Filtering

Why is computer vision difficult?

Digital Image Processing

Lecture 6: Edge Detection

EE795: Computer Vision and Intelligent Systems

Image gradients and edges April 11 th, 2017

Image gradients and edges April 10 th, 2018

CS 4495 Computer Vision. Linear Filtering 2: Templates, Edges. Aaron Bobick. School of Interactive Computing. Templates/Edges

Computer Vision and Graphics (ee2031) Digital Image Processing I

Image processing. Reading. What is an image? Brian Curless CSE 457 Spring 2017

Lecture 4: Image Processing

Lecture 4: Spatial Domain Transformations

Filtering Images. Contents

Filtering and Enhancing Images

Image gradients and edges

Digital Image Processing. Image Enhancement - Filtering

Computer Vision 2. SS 18 Dr. Benjamin Guthier Professur für Bildverarbeitung. Computer Vision 2 Dr. Benjamin Guthier

What will we learn? Neighborhood processing. Convolution and correlation. Neighborhood processing. Chapter 10 Neighborhood Processing

Vivekananda. Collegee of Engineering & Technology. Question and Answers on 10CS762 /10IS762 UNIT- 5 : IMAGE ENHANCEMENT.

EECS 556 Image Processing W 09. Image enhancement. Smoothing and noise removal Sharpening filters

convolution shift invariant linear system Fourier Transform Aliasing and sampling scale representation edge detection corner detection

Image Processing Lecture 10

Relationship between Fourier Space and Image Space. Academic Resource Center

Computer Vision I - Basics of Image Processing Part 1

Prof. Feng Liu. Winter /15/2019

Image Processing. Traitement d images. Yuliya Tarabalka Tel.

CS334: Digital Imaging and Multimedia Edges and Contours. Ahmed Elgammal Dept. of Computer Science Rutgers University

Sampling and Reconstruction. Most slides from Steve Marschner

Applications of Image Filters

Lecture 16: Computer Vision

Lecture 16: Computer Vision

Computer Vision: 4. Filtering. By I-Chen Lin Dept. of CS, National Chiao Tung University

ECG782: Multidimensional Digital Signal Processing

CHAPTER 3 IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN

Chapter 3: Intensity Transformations and Spatial Filtering

Filtering and Edge Detection. Computer Vision I. CSE252A Lecture 10. Announcement

ECG782: Multidimensional Digital Signal Processing

Point and Spatial Processing

Introduction to Digital Image Processing

Edge and Texture. CS 554 Computer Vision Pinar Duygulu Bilkent University

Digital Image Processing. Prof. P. K. Biswas. Department of Electronic & Electrical Communication Engineering

CS4733 Class Notes, Computer Vision

ME/CS 132: Introduction to Vision-based Robot Navigation! Low-level Image Processing" Larry Matthies"

Bias-Variance Trade-off (cont d) + Image Representations

Image gradients and edges

Biometrics Technology: Image Processing & Pattern Recognition (by Dr. Dickson Tong)

Last update: May 4, Vision. CMSC 421: Chapter 24. CMSC 421: Chapter 24 1

CPSC 425: Computer Vision

Hom o om o or o phi p c Processing

Image Processing. Filtering. Slide 1

[ ] Review. Edges and Binary Images. Edge detection. Derivative of Gaussian filter. Image gradient. Tuesday, Sept 16

CS534: Introduction to Computer Vision Edges and Contours. Ahmed Elgammal Dept. of Computer Science Rutgers University

Edges and Binary Images

Edge and local feature detection - 2. Importance of edge detection in computer vision

Digital Image Fundamentals

Filters (cont.) CS 554 Computer Vision Pinar Duygulu Bilkent University

EEM 463 Introduction to Image Processing. Week 3: Intensity Transformations

Perception. Autonomous Mobile Robots. Sensors Vision Uncertainties, Line extraction from laser scans. Autonomous Systems Lab. Zürich.

PROCESS > SPATIAL FILTERS

Digital Image Processing. Lecture 6

Chapter - 2 : IMAGE ENHANCEMENT

EXAM SOLUTIONS. Image Processing and Computer Vision Course 2D1421 Monday, 13 th of March 2006,

Multimedia Computing: Algorithms, Systems, and Applications: Edge Detection

Image Processing. Bilkent University. CS554 Computer Vision Pinar Duygulu

Segmentation and Grouping

Edge and corner detection

Babu Madhav Institute of Information Technology Years Integrated M.Sc.(IT)(Semester - 7)

Peripheral drift illusion

Outlines. Medical Image Processing Using Transforms. 4. Transform in image space

Basic Algorithms for Digital Image Analysis: a course

Lecture 4 Image Enhancement in Spatial Domain

Edge Detection (with a sidelight introduction to linear, associative operators). Images

Lecture 20: Tracking. Tuesday, Nov 27

SYDE 575: Introduction to Image Processing

Announcements. Edge Detection. An Isotropic Gaussian. Filters are templates. Assignment 2 on tracking due this Friday Midterm: Tuesday, May 3.

Linear Operations Using Masks

Other Linear Filters CS 211A

Image Enhancement in Spatial Domain (Chapter 3)

Broad field that includes low-level operations as well as complex high-level algorithms

Filtering Images in the Spatial Domain Chapter 3b G&W. Ross Whitaker (modified by Guido Gerig) School of Computing University of Utah

(Refer Slide Time 00:17) Welcome to the course on Digital Image Processing. (Refer Slide Time 00:22)

PSD2B Digital Image Processing. Unit I -V

Solution: filter the image, then subsample F 1 F 2. subsample blur subsample. blur

Lecture Image Enhancement and Spatial Filtering

Capturing, Modeling, Rendering 3D Structures

Computer Vision I - Filtering and Feature detection

Feature Tracking and Optical Flow

Computer Vision for HCI. Topics of This Lecture

NAME: Sample Final Exam (based on previous CSE 455 exams by Profs. Seitz and Shapiro)

Motivation. Gray Levels

Basic relations between pixels (Chapter 2)

Lecture 2: 2D Fourier transforms and applications

Feature Tracking and Optical Flow

Filtering in frequency domain

Lecture 4: Nonlinear Filters

Motivation. Intensity Levels

To Do. Advanced Computer Graphics. Discrete Convolution. Outline. Outline. Implementing Discrete Convolution

Transcription:

CS4442/9542b Artificial Intelligence II prof. Olga Veksler Lecture 2 Computer Vision Introduction, Filtering Some slides from: D. Jacobs, D. Lowe, S. Seitz, A.Efros, X. Li, R. Fergus, J. Hayes, S. Lazebnik, D. Hoiem, S. Marschner

Outline Very Brief Intro to Computer Vision Digital Images Image Filtering noise reduction

Every Picture Tells a Story Goal of computer vision is to write computer programs that can interpret images bridge the gap between the pixels and the story 2 2 2 9 2 2 7 2 2 8 2 3 2 2 4 2 2 7 2 8 2 2 2 6 2 8 3 2 5 2 2 7 2 4 2 9 what we see what computers see

Origin of Computer Vision: MIT Summer Project

The problem Want to make a computer understand images We know it is possible, we do it effortlessly! sensing device interpreting device interpretations real world scene a person, a person with folded arms, Pietro Perona

Just Copy Human Visual System? People try to but we don t yet have a sufficient understanding of how our visual system works O( ) neurons used in vision about /3 of human brain Latest CPUs have only O( 8 ) transistors most are cache memory Very different architectures: Brain is slow but parallel Computer is fast but mainly serial Bird vs Airplane Same underlying principles Very different hardware

Why Computer Vision Matters Safety Health Security Comfort Fun Personal Photos

Early Vision Problems Edge extraction Corner extraction Blob extraction

Mid-level Vision Problems 3D Structure extraction Motion and tracking Segmentation

High-level Vision Problems Face Detection Action Recognition Object Recognition Scene Recognition

Vision is inferential: Illumination Vision is hard: even the simple problem of color perception is inferential http://web.mit.edu/persci/people/adelson/checkershadow_illusion.html

Image Formation

Sampling and Quantization

Sensor Array real world object after quantization and sampling

Digital Grayscale Image Image is array f(x,y) approximates continuous function f(x,y) from R 2 to R: f(x,y) is the intensity or grayscale at position (x,y) proportional to brightness of the real world point it images standard range:,, 2,., 255 (,) x y f(3,2)=75 f(5,9)= 7

Digital Color Image Color image is three functions pasted together Write this as a vectorvalued function: f ( ) x,y = ( ) r x,y g( x,y) ( ) b x,y 2 5 5 2

Digital Color Image Can consider color image as 3 separate images: R, G, B R G B

Image filtering Given f(x,y) filtering computes a new image h(x,y) As a function of local neighborhood at each position (x,y) h(x,y) = f(x,y)+f(x-,y) f(x,y-) Linear filtering: function is a weighted sum (or difference) of pixel values h(x,y) = f(x,y) + 2 f(x-,y-) - 3 f(x+,y+) Many applications: Enhance images denoise, resize, increase contrast, Extract information from images Texture, edges, distinctive points Detect patterns Template matching 2 4 2 8 9 2 2 7 5 2 8 3 9 4 3 2 7 2 2 2 2 6 8 3 2 5 4 h(2,3) = 3 + 4 8 = 35 h(4,5) = 4 + 5 = 9 h(3,) = 7 + 2 4-3 9 = -2

Filtering for Noise Reduction: Motivation Multiple images of even the same static scene are not identical

Common Types of Noise original image Impulse noise: random occurrences of white pixels Salt and pepper noise: random occurrences of black and white pixels Gaussian noise: variations in intensity drawn from a Gaussian distribution

Gaussian Noise Most Commonly Assumed original image G(,25) noise

Noise Reduction = + + + Noise can be reduced by averaging If we had multiple images, simply average them: f final (x,y) = (f (x,y) + f 2 (x,y) + + f n (x,y)))/n But usually there is only one image!

First Attempt at a Solution Replace each pixel with an average of all the values in its neighborhood Assumptions: expect a pixel to have intensities similar to its neighbors Noise is independent at each pixel

First attempt at a solution Replace each pixel with an average of all the values in its neighborhood (= 5 pixels, say) Moving average in D:

First attempt at a solution Replace each pixel with an average of all the values in its neighborhood (= 5 pixels, say) Moving average in D:

First attempt at a solution Replace each pixel with an average of all the values in its neighborhood (= 5 pixels, say) Moving average in D:

First attempt at a solution Replace each pixel with an average of all the values in its neighborhood (= 5 pixels, say) Moving average in D:

First attempt at a solution Replace each pixel with an average of all the values in its neighborhood (= 5 pixels, say) Moving average in D:

Weighted Moving Average Write down moving average as weighted sum have not done anything new yet Weights [,,,, ]/5

Weighted Moving Average Non-uniform weights [, 4, 6, 4, ] / 6 Non-uniform weights give smoother result

Moving Average In 2D f(x,y) g(x,y) 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9

Moving Average In 2D f(x,y) g(x,y) 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9

Moving Average In 2D f(x,y) g(x,y) 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 2

Moving Average In 2D f(x,y) g(x,y) 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 2 3

Moving Average In 2D f(x,y) g(x,y) 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 2 3 3

Moving Average In 2D f(x,y) g(x,y) 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 2 3 3 3 2 2 4 6 6 6 4 2 3 6 9 9 9 6 3 3 5 8 8 9 6 3 3 5 8 8 9 6 3 2 3 5 5 6 4 2 2 3 3 3 3 2

Moving Average In 2D f(x,y) sharp border 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 sticking out g(x,y) border washed out 2 3 3 3 2 2 4 6 6 6 4 2 3 6 9 9 9 6 3 3 5 8 8 9 6 3 3 5 8 8 9 6 3 2 3 5 5 6 4 2 2 3 3 3 3 2 not sticking out

Correlation Filtering Write as equation, averaging window (2k+)x(2k+) g( i, j) = ( k + ) 2 2 k k u= k v= k f ( ) i + u, j + v -k,-k k,k 2k+ uniform weight for each pixel loop over all pixels in neighborhood around pixel f(i,j) Generalize by allowing different weights for different pixels in the neighborhood g ( ) [ ] ( ) i, j = k k H u,v u= k v= k non-uniform weight for each pixel f i + u, j + v

g Correlation filtering ( ) [ ] ( ) i, j = k k u= k v= k H u,v This is called cross-correlation, denoted g = H f Filtering an image: replace each pixel with a linear combination of its neighbors The filter kernel or mask H is gives the weights in linear combination f i + u, j + v

Averaging Filter What is kernel H for the moving average example? f(x,y) H[u,v] =? g(x,y) 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 box filter 2 3 3 g = H f

Smoothing by Averaging Pictorial representation of box filter: white means large value, black means low value original filtered What if the mask is larger than 3x3?

Effect of Average Filter Gaussian noise Salt and Pepper noise 7 7 9 9

Boundary Issues What is the size of the output? MATLAB: output size / shape options shape = full : output size is sum of sizes of f and g shape = same : output size is same as f shape = valid : output size is difference of sizes of f and g g g g g g g f f f g g g g g full same valid g

Boundary issues What about near the edge? the filter window falls off the edge of the image need to extrapolate image clip filter (black) copy edge wrap around reflect across edge

9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 Gaussian Filter May want nearest neighboring pixels to have the most influence f(x,y) 6 H[u,v] 2 2 4 2 2 This kernel H is an approximation of a 2d Gaussian function:

Gaussian Filters: Mask Size Gaussian has infinite domain, discrete filters use finite mask larger mask contributes to more smoothing σ = 5 with x mask σ = 5 with 3 x 3 mask blue weights are so small they are effectively

Gaussian filters: Variance Variance (σ) also contributes to the extent of smoothing larger σ gives less rapidly decreasing weights can construct a larger mask with non-negligible weights σ = 2 with 3 x 3 kernel σ = 5 with 3 x 3 kernel σ = 8 with 3 x 3 kernel

Matlab >> hsize = ; im >> sigma = 5; >> h = fspecial( gaussian, hsize, sigma); >> mesh(h); >> imagesc(h); >> outim = imfilter(im, h); % correlation >> imshow(outim); outim

Average vs. Gaussian Filter mean filter Gaussian filter

More Average vs. Gaussian Filter mean filter Gaussian filter 5 5 5 5 3 3

Gaussian Filter with different Ϭ original image filtered with different Ϭ Ϭ=3 Ϭ= Ϭ=2 corrupted by noise Ϭ = corrupted by noise Ϭ = 2 corrupted by noise Ϭ = 3

Properties of Smoothing Filters Values positive Sum to constant regions same as input overall image brightness stays unchanged Amount of smoothing proportional to mask size larger mask means more extensive smoothing

Filtering an Impulse Signal What is the result of filtering the impulse signal (image) with arbitrary kernel H? a b c d e f = g h i H[u,v] f(x,y) g(x,y)=?

Filtering an Impulse Signal What is the result of filtering the impulse signal (image) with arbitrary kernel H? f(x,y) a b c d e f = g h i H[u,v] i h g f e d c b a g(x,y)=?

Convolution: Convolution Flip the mask in both dimensions bottom to top, right to left Then apply cross-correlation g k k ( i, j) = H[ u,v] f ( i u, j v) u= k v= k -k,-k k,k 2k+ H H flipped f Notation for convolution: g = H*f

Convolution vs. Correlation Convolution: g = H*f g ( ) [ ] ( ) i, j = k k u= k v= k H u,v f i u, j v Correlation: g = H f g ( ) [ ] ( ) i, j = k k u= k v= k H u,v For Gaussian or box filter, how the outputs differ? If the input is an impulse signal, how the outputs differ? f i + u, j + v

Predict Outputs Using Correlation Filtering =? =? 2 - =?

Practice with Linear Filters =? original

Practice with Linear Filters = original filtered (no change)

Practice with Linear Filters =? original

Practice with Linear Filters = original shifted left by pixel with correlation

Practice with Linear Filters =? Original

Practice with Linear Filters = original blur (with a box filter)

Practice with Linear Filters apply one mask after the other, or subtract masks and apply one resulting mask -/9 -/9 -/9 -/9 7/9 -/9 -/9 -/9 -/9 2 -? = original

Practice with Linear Filters 2 -? = original sharpened

Practice with Linear Filters Why sharpens? 2 - + - = original f original f smoothed + = original f detail sharpened

Filtering Examples: Sharpening before after

Separability Sometimes filter is separable, can split into two steps: Convolve all rows with D filter Convolve all columns with D filter Both box and Gaussian filters are separable Great for efficiency!

Box Filter /9 /9 /9 /3 9 9 9 9 /9 /9 /9 = /3 * /3 /3 /3 9 9 9 9 /9 /9 /9 /3 *H = 9 9 9 9 H H c H r 9 9 9 9 4 6 6 4 6 9 9 6 6 9 9 6 4 6 6 4 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 *H c *H r = 6 6 6 6 9 9 9 9 9 9 9 9 6 6 6 6 *H r = 4 6 6 4 6 9 9 6 6 9 9 6 4 6 6 4

Gaussian Filter: Example To convolve image with this: First convolve each row with: Then each column with: H H r H c

Gaussian Filter: Example Straightforward convolution with 5 5 kernel 25 multiplications, 24 additions per pixel Smart convolution multiplications, 9 additions per pixel Savings are even larger for larger kernels for n n kernel, straightforward convolution is O(n 2 ) Smart convolution is O(n) per pixel

Median Filters 2 25 3 24 22 2 2 23 X X X X 2 X X X X Median of {,2,25,3,24,22,2,2,23} = {,2,3,2,2,22,23,24,25} is 2 A Median Filter selects median intensity in the window No new intensities are introduced Median filter preserves sharp details better than mean filter, it is not so prone to oversmoothing Better for salt and pepper, impulse (spiky) noise Is a median filter a kind of convolution?

Median filter Salt and pepper noise median filtered row of noisy image row of filtered image

Median Filter Median filter is edge preserving input: average: median:

Comparison: Salt and Pepper Noise Image Gaussian filter median filter 3 3 5 5 7 7

Comparison: Gaussian Noise Image Gaussian filter median filter 3 3 5 5 7 7

Filtering Fun: Face of Faces http://www.salle.url.edu/~ftorre/

Salvador Dali, Gala Contemplating the Mediterranean Sea, which at 3 meters becomes the portrait of Abraham Lincoln, 976

Summary Image noise Linear filters and convolution useful for Enhancing images (smoothing, removing noise) Box filter Gaussian filter Impact of scale / width of smoothing filter Detecting features (next time) Separable filters more efficient Median filter: a non-linear filter, edge-preserving