Computer Vision: Filtering

Similar documents
Convolution. 1D Formula: 2D Formula: Example on the web:

Edge detection. (Trucco, Chapt 4 AND Jain et al., Chapt 5) -Edges are significant local changes of intensity in an image.

Computational Foundations of Cognitive Science

jorge s. marques image processing

Correlation and Convolution Class Notes for CMSC 426, Fall 2005 David Jacobs

Bildverarbeitung und Mustererkennung Image Processing and Pattern Recognition

Digital Imaging and Multimedia. Filters. Ahmed Elgammal Dept. of Computer Science Rutgers University

Linear Filtering Part II

Image Filtering & Edge Detection

Implementation of Canny Edge Detector of color images on CELL/B.E. Architecture.

Admin stuff. 4 Image Pyramids. Spatial Domain. Projects. Fourier domain 2/26/2008. Fourier as a change of basis

Canny Edge Detection

REAL TIME TRAFFIC LIGHT CONTROL USING IMAGE PROCESSING

Image Gradients. Given a discrete image Á Òµ, consider the smoothed continuous image ܵ defined by

QUALITY TESTING OF WATER PUMP PULLEY USING IMAGE PROCESSING

Sharpening through spatial filtering

SGN-1158 Introduction to Signal Processing Test. Solutions

Automatic 3D Reconstruction via Object Detection and 3D Transformable Model Matching CS 269 Class Project Report

Analecta Vol. 8, No. 2 ISSN

Lectures 6&7: Image Enhancement

Railway Expansion Joint Gaps and Hooks Detection Using Morphological Processing, Corner Points and Blobs

EECS 556 Image Processing W 09. Interpolation. Interpolation techniques B splines

MVA ENS Cachan. Lecture 2: Logistic regression & intro to MIL Iasonas Kokkinos Iasonas.kokkinos@ecp.fr

Visualization and Feature Extraction, FLOW Spring School 2016 Prof. Dr. Tino Weinkauf. Flow Visualization. Image-Based Methods (integration-based)

Module II: Multimedia Data Mining

Image Segmentation and Registration

Sachin Patel HOD I.T Department PCST, Indore, India. Parth Bhatt I.T Department, PCST, Indore, India. Ankit Shah CSE Department, KITE, Jaipur, India

Assessment. Presenter: Yupu Zhang, Guoliang Jin, Tuo Wang Computer Vision 2008 Fall

Lecture 14. Point Spread Function (PSF)

Armstrong Atlantic State University Engineering Studies MATLAB Marina Image Processing Primer

Computational Optical Imaging - Optique Numerique. -- Deconvolution --

Segmentation & Clustering

The Image Deblurring Problem

Mean-Shift Tracking with Random Sampling

Environmental Remote Sensing GEOG 2021

3D Scanner using Line Laser. 1. Introduction. 2. Theory

An Iterative Image Registration Technique with an Application to Stereo Vision

Resolution Enhancement of images with Interpolation and DWT-SWT Wavelet Domain Components

How To Filter Spam Image From A Picture By Color Or Color

Object Recognition and Template Matching

Classification of Fingerprints. Sarat C. Dass Department of Statistics & Probability

OBJECT TRACKING USING LOG-POLAR TRANSFORMATION

DIGITAL IMAGE PROCESSING AND ANALYSIS

INTRODUCTION TO RENDERING TECHNIQUES

Aliasing, Image Sampling and Reconstruction

A Study on SURF Algorithm and Real-Time Tracking Objects Using Optical Flow

Signature Region of Interest using Auto cropping

Feature Tracking and Optical Flow

Multi-Zone Adjustment

Practical Tour of Visual tracking. David Fleet and Allan Jepson January, 2006

Modelling, Extraction and Description of Intrinsic Cues of High Resolution Satellite Images: Independent Component Analysis based approaches

Solving Systems of Linear Equations Using Matrices

VECTORAL IMAGING THE NEW DIRECTION IN AUTOMATED OPTICAL INSPECTION

SIGNAL PROCESSING & SIMULATION NEWSLETTER

A New Image Edge Detection Method using Quality-based Clustering. Bijay Neupane Zeyar Aung Wei Lee Woon. Technical Report DNA #

Microsoft Excel 2010 Charts and Graphs

Automatic Traffic Estimation Using Image Processing

Algorithm for License Plate Localization and Recognition for Tanzania Car Plate Numbers

COMP175: Computer Graphics. Lecture 1 Introduction and Display Technologies

WHITE PAPER. Methods for Measuring Flat Panel Display Defects and Mura as Correlated to Human Visual Perception

Blind Deconvolution of Barcodes via Dictionary Analysis and Wiener Filter of Barcode Subsections

Numerical Methods For Image Restoration

ROBUST VEHICLE TRACKING IN VIDEO IMAGES BEING TAKEN FROM A HELICOPTER

Digital Image Processing

Time series analysis Matlab tutorial. Joachim Gross

The continuous and discrete Fourier transforms

Enhanced LIC Pencil Filter

Discrete Convolution and the Discrete Fourier Transform

CMOS Image Sensor Noise Reduction Method for Image Signal Processor in Digital Cameras and Camera Phones

LIST OF CONTENTS CHAPTER CONTENT PAGE DECLARATION DEDICATION ACKNOWLEDGEMENTS ABSTRACT ABSTRAK

Frequency Response of FIR Filters

2.2 Creaseness operator

An edge-from-focus approach to 3D inspection and metrology

Lecture 8: Signal Detection and Noise Assumption

Digital image processing


521466S Machine Vision Assignment #7 Hough transform

Investigation of Color Aliasing of High Spatial Frequencies and Edges for Bayer-Pattern Sensors and Foveon X3 Direct Image Sensors

APPM4720/5720: Fast algorithms for big data. Gunnar Martinsson The University of Colorado at Boulder

FFT Algorithms. Chapter 6. Contents 6.1

A Learning Based Method for Super-Resolution of Low Resolution Images

Probabilistic Latent Semantic Analysis (plsa)

Tutorial for Tracker and Supporting Software By David Chandler

How to resize, rotate, and crop images

Scanners and How to Use Them

Robert Collins CSE598G. More on Mean-shift. R.Collins, CSE, PSU CSE598G Spring 2006

Tutorial. Filtering Images F I L T E R I N G. Filtering Images. with. TNTmips. page 1

GeoGebra. 10 lessons. Gerrit Stols

Comparison of Non-linear Dimensionality Reduction Techniques for Classification with Gene Expression Microarray Data

IMAGE RECOGNITION FOR CATS AND DOGS

WEEK #3, Lecture 1: Sparse Systems, MATLAB Graphics

Excel -- Creating Charts

MATLAB-based Applications for Image Processing and Image Quality Assessment Part I: Software Description

Characterizing Digital Cameras with the Photon Transfer Curve

Correcting the Lateral Response Artifact in Radiochromic Film Images from Flatbed Scanners

Transcription:

Computer Vision: Filtering Raquel Urtasun TTI Chicago Jan 10, 2013 Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 1 / 82

Today s lecture... Image formation Image Filtering Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 2 / 82

Readings Chapter 2 and 3 of Rich Szeliski s book Available online here Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 3 / 82

How is an image created? The image formation process that produced a particular image depends on lighting conditions scene geometry surface properties camera optics [Source: R. Szeliski] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 4 / 82

Image formation Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 5 / 82

[Source: A. Efros] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 6 / 82 What is an image?!"#"$%&'(%)*+%' 0*1&&'23456'37'$-*6*'"7'$-"6'4&%66',-*'./*'

From photons to RGB values Sample the 2D space on a regular grid. Quantize each sample, i.e., the photons arriving at each active cell are integrated and then digitized. [Source: D. Hoiem] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 7 / 82

What is an image? A grid (matrix) of intensity values #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #% % #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ &$ &$ &$ #$$ #$$ #$$ #$$ #$$ #$$!" #$$ #$$ &$ '$ '$ &$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ '( )#& )*$ )&$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ )#& )*$ )&$ )&$ )&$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ )#& )*$ #%% #%% )&$ )&$ '$ #$$ #$$ #$$ #$$ #$$ )#& )*$ #%% #%% )&$ )&$ '$ *& #$$ #$$ #$$ #$$ )#& )*$ )*$ )&$ )#& )#& '$ *& #$$ #$$ #$$ #$$ &* )#& )#& )#& '$ '$ '$ *& #$$ #$$ #$$ #$$ #$$ &* &* &* &* &* &* #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ #$$ Common to use one byte per value: 0=black, 255=white) [Source: N. Snavely] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 8 / 82

What is an image? We can think of a (grayscale) image as a function f : R 2 R giving the intensity at position (x, y) f (x, y) x y A digital image is a discrete (sampled, quantized) version of this function [Source: N. Snavely] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 9 / 82

Image Transformations As with any function, we can apply operators to an image!g (x,y) = f (x,y) + 20!g (x,y) = f (-x,y) We ll talk about special kinds of operators, correlation and convolution (linear filtering) [Source: N. Snavely] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 10 / 82

Filtering Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 11 / 82

Question: Noise reduction Given a camera and a still scene, how can you reduce noise? Take lots of images and average them! Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 12 / 82

Question: Noise reduction Given a camera and a still scene, how can you reduce noise? Take lots of images and average them! Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 12 / 82

Question: Noise reduction Given a camera and a still scene, how can you reduce noise? Take lots of images and average them! What s the next best thing? [Source: S. Seitz] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 12 / 82

Question: Noise reduction Given a camera and a still scene, how can you reduce noise? Take lots of images and average them! What s the next best thing? [Source: S. Seitz] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 12 / 82

Image filtering Modify the pixels in an image based on some function of a local neighborhood of each pixel #'" $" #"!" &"!" #" #" %" 5).0"678*9)8" %" ()*+,"-.+/0"1+2+" 3)1-401"-.+/0"1+2+" [Source: L. Zhang] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 13 / 82

Applications of Filtering Enhance an image, e.g., denoise, resize. Extract information, e.g., texture, edges. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 14 / 82

Applications of Filtering Enhance an image, e.g., denoise, resize. Extract information, e.g., texture, edges. Detect patterns, e.g., template matching. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 14 / 82

Applications of Filtering Enhance an image, e.g., denoise, resize. Extract information, e.g., texture, edges. Detect patterns, e.g., template matching. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 14 / 82

Noise reduction Simplest thing: replace each pixel by the average of its neighbors. This assumes that neighboring pixels are similar, and the noise to be independent from pixel to pixel. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 15 / 82

Noise reduction Simplest thing: replace each pixel by the average of its neighbors. This assumes that neighboring pixels are similar, and the noise to be independent from pixel to pixel. [Source: S. Marschner] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 15 / 82

Noise reduction Simplest thing: replace each pixel by the average of its neighbors. This assumes that neighboring pixels are similar, and the noise to be independent from pixel to pixel. [Source: S. Marschner] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 15 / 82

Noise reduction Simplest thing: replace each pixel by the average of its neighbors This assumes that neighboring pixels are similar, and the noise to be independent from pixel to pixel. Moving average in 1D: [1, 1, 1, 1, 1]/5 [Source: S. Marschner] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 16 / 82

Noise reduction Simpler thing: replace each pixel by the average of its neighbors This assumes that neighboring pixels are similar, and the noise to be independent from pixel to pixel. Non-uniform weights [1, 4, 6, 4, 1] / 16 [Source: S. Marschner] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 17 / 82

Moving Average in 2D [Source: S. Seitz] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 18 / 82

Moving Average in 2D [Source: S. Seitz] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 18 / 82

Moving Average in 2D [Source: S. Seitz] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 18 / 82

Moving Average in 2D [Source: S. Seitz] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 18 / 82

Moving Average in 2D [Source: S. Seitz] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 18 / 82

Moving Average in 2D [Source: S. Seitz] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 18 / 82

Linear Filtering: Correlation Involves weighted combinations of pixels in small neighborhoods. The output pixels value is determined as a weighted sum of input pixel values g(i, j) = k,l f (i + k, j + l)h(k, l) Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 19 / 82

Linear Filtering: Correlation Involves weighted combinations of pixels in small neighborhoods. The output pixels value is determined as a weighted sum of input pixel values g(i, j) = k,l f (i + k, j + l)h(k, l) The entries of the weight kernel or mask h(k, l) are often called the filter coefficients. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 19 / 82

Linear Filtering: Correlation Involves weighted combinations of pixels in small neighborhoods. The output pixels value is determined as a weighted sum of input pixel values g(i, j) = k,l f (i + k, j + l)h(k, l) The entries of the weight kernel or mask h(k, l) are often called the filter coefficients. This operator is the correlation operator g = f h Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 19 / 82

Linear Filtering: Correlation Involves weighted combinations of pixels in small neighborhoods. The output pixels value is determined as a weighted sum of input pixel values g(i, j) = k,l f (i + k, j + l)h(k, l) The entries of the weight kernel or mask h(k, l) are often called the filter coefficients. This operator is the correlation operator g = f h Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 19 / 82

Smoothing by averaging What if the filter size was 5 x 5 instead of 3 x 3? [Source: K. Graumann] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 20 / 82

Gaussian filter What if we want nearest neighboring pixels to have the most influence on the output? Removes high-frequency components from the image (low-pass filter). [Source: S. Seitz] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 21 / 82

Smoothing with a Gaussian [Source: K. Grauman] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 22 / 82

Mean vs Gaussian Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 23 / 82

Gaussian filter: Parameters Size of kernel or mask: Gaussian function has infinite support, but discrete filters use finite kernels. [Source: K. Grauman] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 24 / 82

Gaussian filter: Parameters Variance of the Gaussian: determines extent of smoothing. [Source: K. Grauman] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 25 / 82

Gaussian filter: Parameters [Source: K. Grauman] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 26 / 82

Is this the most general Gaussian? No, the most general form for x R d N (x; µ, Σ) = ( 1 exp 1 ) (2π) d/2 Σ 1/2 2 (x µ)t Σ 1 (x µ) But the simplified version is typically use for filtering. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 27 / 82

Properties of the Smoothing All values are positive. They all sum to 1. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 28 / 82

Properties of the Smoothing All values are positive. They all sum to 1. Amount of smoothing proportional to mask size. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 28 / 82

Properties of the Smoothing All values are positive. They all sum to 1. Amount of smoothing proportional to mask size. Remove high-frequency components; low-pass filter. [Source: K. Grauman] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 28 / 82

Properties of the Smoothing All values are positive. They all sum to 1. Amount of smoothing proportional to mask size. Remove high-frequency components; low-pass filter. [Source: K. Grauman] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 28 / 82

Example of Correlation What is the result of filtering the impulse signal (image) F with the arbitrary kernel H? [Source: K. Grauman] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 29 / 82

Convolution Convolution operator g(i, j) = k,l f (i k, j l)h(k, l) = k,l f (k, l)h(i k, j l) = f h and h is then called the impulse response function. Equivalent to flip the filter in both dimensions (bottom to top, right to left) and apply cross-correlation. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 30 / 82

Convolution Convolution operator g(i, j) = k,l f (i k, j l)h(k, l) = k,l f (k, l)h(i k, j l) = f h and h is then called the impulse response function. Equivalent to flip the filter in both dimensions (bottom to top, right to left) and apply cross-correlation. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 30 / 82

Matrix form Correlation and convolution can both be written as a matrix-vector multiply, if we first convert the two-dimensional images f (i, j) and g(i, j) into raster-ordered vectors f and g with H a sparse matrix. g = Hf Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 31 / 82

Correlation vs Convolution Convolution g(i, j) = k,l f (i k, j l)h(k, l) G = H F Correlation g(i, j) = k,l f (i + k, j + l)h(k, l) G = H F For a Gaussian or box filter, how will the outputs differ? If the input is an impulse signal, how will the outputs differ? h δ?, and h δ? Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 32 / 82

Example What s the result? [Source: D. Lowe] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 33 / 82

Example What s the result? [Source: D. Lowe] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 33 / 82

Example What s the result? [Source: D. Lowe] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 33 / 82

Example What s the result? [Source: D. Lowe] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 33 / 82

Example What s the result? * #" #" #" #" $" #" #" #" #"!"!"!" -!!"!"!" %"!"!"!" Original! [Source: D. Lowe] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 33 / 82

Example What s the result? * #" #" #" #" $" #" #" #" #" -!!"!"!"!"!"!"!"!"!" 0" Original!!"#$%&'(')*+,-&$* %&''()*+&*(,"(-.(,/* [Source: D. Lowe] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 33 / 82

Sharpening [Source: D. Lowe] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 34 / 82

Gaussian Filter Convolution with itself is another Gaussian *!" Convolving twice with Gaussian kernel of width σ is the same as convolving once with kernel of width σ 2 [Source: K. Grauman] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 35 / 82

Sharpening revisited What does blurring take away?!" #"!"#$#%&'( )*!!+,-.(/0102(.-+&#'( Let s add it back #"$"!" *$+,+'#-) (&.#+-)!"#$%&'&() [Source: S. Lazebnik] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 36 / 82

Sharpening!"#$%&'&() #$%&'&() [Source: N. Snavely] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 37 / 82

Optical Convolution Camera Shake!" * Figure: Fergus, et al., SIGGRAPH 2006 Blur in out-of-focus regions of an image. Figure: Bokeh: Click for more info [Source: N. Snavely] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 38 / 82

Correlation vs Convolution The convolution is both commutative and associative. The Fourier transform of two convolved images is the product of their individual Fourier transforms. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 39 / 82

Correlation vs Convolution The convolution is both commutative and associative. The Fourier transform of two convolved images is the product of their individual Fourier transforms. Both correlation and convolution are linear shift-invariant (LSI) operators, which obey both the superposition principle and the shift invariance principle h (f 0 + f 1 ) = h f o + h f 1 if g(i, j) = f (i + k, j + l) (h g)(i, j) = (h f )(i + k, j + l) which means that shifting a signal commutes with applying the operator. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 39 / 82

Correlation vs Convolution The convolution is both commutative and associative. The Fourier transform of two convolved images is the product of their individual Fourier transforms. Both correlation and convolution are linear shift-invariant (LSI) operators, which obey both the superposition principle and the shift invariance principle h (f 0 + f 1 ) = h f o + h f 1 if g(i, j) = f (i + k, j + l) (h g)(i, j) = (h f )(i + k, j + l) which means that shifting a signal commutes with applying the operator. Is the same as saying that the effect of the operator is the same everywhere. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 39 / 82

Correlation vs Convolution The convolution is both commutative and associative. The Fourier transform of two convolved images is the product of their individual Fourier transforms. Both correlation and convolution are linear shift-invariant (LSI) operators, which obey both the superposition principle and the shift invariance principle h (f 0 + f 1 ) = h f o + h f 1 if g(i, j) = f (i + k, j + l) (h g)(i, j) = (h f )(i + k, j + l) which means that shifting a signal commutes with applying the operator. Is the same as saying that the effect of the operator is the same everywhere. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 39 / 82

Boundary Effects The results of filtering the image in this form will lead to a darkening of the corner pixels. The original image is effectively being padded with 0 values wherever the convolution kernel extends beyond the original image boundaries. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 40 / 82

Boundary Effects The results of filtering the image in this form will lead to a darkening of the corner pixels. The original image is effectively being padded with 0 values wherever the convolution kernel extends beyond the original image boundaries. A number of alternative padding or extension modes have been developed. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 40 / 82

Boundary Effects The results of filtering the image in this form will lead to a darkening of the corner pixels. The original image is effectively being padded with 0 values wherever the convolution kernel extends beyond the original image boundaries. A number of alternative padding or extension modes have been developed. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 40 / 82

Boundary Effects The results of filtering the image in this form will lead to a darkening of the corner pixels. The original image is effectively being padded with 0 values wherever the convolution kernel extends beyond the original image boundaries. A number of alternative padding or extension modes have been developed. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 40 / 82

Separable Filters The process of performing a convolution requires K 2 operations per pixel, where K is the size (width or height) of the convolution kernel. In many cases, this operation can be speed up by first performing a 1D horizontal convolution followed by a 1D vertical convolution, requiring 2K operations. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 41 / 82

Separable Filters The process of performing a convolution requires K 2 operations per pixel, where K is the size (width or height) of the convolution kernel. In many cases, this operation can be speed up by first performing a 1D horizontal convolution followed by a 1D vertical convolution, requiring 2K operations. If his is possible, then the convolution kernel is called separable. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 41 / 82

Separable Filters The process of performing a convolution requires K 2 operations per pixel, where K is the size (width or height) of the convolution kernel. In many cases, this operation can be speed up by first performing a 1D horizontal convolution followed by a 1D vertical convolution, requiring 2K operations. If his is possible, then the convolution kernel is called separable. And it is the outer product of two kernels K = vh T Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 41 / 82

Separable Filters The process of performing a convolution requires K 2 operations per pixel, where K is the size (width or height) of the convolution kernel. In many cases, this operation can be speed up by first performing a 1D horizontal convolution followed by a 1D vertical convolution, requiring 2K operations. If his is possible, then the convolution kernel is called separable. And it is the outer product of two kernels K = vh T Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 41 / 82

Let s play a game... Is this separable? If yes, what s the separable version? Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 42 / 82

Let s play a game... Is this separable? If yes, what s the separable version? What does this filter do? Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 42 / 82

Let s play a game... Is this separable? If yes, what s the separable version? Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 43 / 82

Let s play a game... Is this separable? If yes, what s the separable version? What does this filter do? Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 43 / 82

Let s play a game... Is this separable? If yes, what s the separable version? Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 44 / 82

Let s play a game... Is this separable? If yes, what s the separable version? What does this filter do? Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 44 / 82

Let s play a game... Is this separable? If yes, what s the separable version? Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 45 / 82

Let s play a game... Is this separable? If yes, what s the separable version? What does this filter do? Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 45 / 82

Let s play a game... Is this separable? If yes, what s the separable version? Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 46 / 82

Let s play a game... Is this separable? If yes, what s the separable version? What does this filter do? Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 46 / 82

How can we tell if a given kernel K is indeed separable? Inspection... this is what we were doing. Looking at the analytic form of it. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 47 / 82

How can we tell if a given kernel K is indeed separable? Inspection... this is what we were doing. Looking at the analytic form of it. Look at the singular value decomposition (SVD), and if only one singular value is non-zero, then it is separable K = UΣV T = i σ i u i v T i with Σ = diag(σ i ). Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 47 / 82

How can we tell if a given kernel K is indeed separable? Inspection... this is what we were doing. Looking at the analytic form of it. Look at the singular value decomposition (SVD), and if only one singular value is non-zero, then it is separable K = UΣV T = i σ i u i v T i with Σ = diag(σ i ). σ1 u 1 and σ 1 v T 1 are the vertical and horizontal kernels. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 47 / 82

How can we tell if a given kernel K is indeed separable? Inspection... this is what we were doing. Looking at the analytic form of it. Look at the singular value decomposition (SVD), and if only one singular value is non-zero, then it is separable K = UΣV T = i σ i u i v T i with Σ = diag(σ i ). σ1 u 1 and σ 1 v T 1 are the vertical and horizontal kernels. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 47 / 82

Application of filtering: Template matching Filters as templates: filters look like the effects they are intended to find. Use normalized cross-correlation score to find a given pattern (template) in the image. Normalization needed to control for relative brightnesses. [Source: K. Grauman] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 48 / 82

Template matching [Source: K. Grauman] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 49 / 82

More complex Scenes Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 50 / 82

Let s talk about Edge Detection Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 51 / 82

Filtering: Edge detection Map image from 2d array of pixels to a set of curves or line segments or contours. More compact than pixels. Look for strong gradients, post-process. Figure: [Shotton et al. PAMI, 07] [Source: K. Grauman] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 52 / 82

Origin of edges Edges are caused by a variety of factors surface normal discontinuity depth discontinuity surface color discontinuity illumination discontinuity [Source: N. Snavely] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 53 / 82

What causes an edge? [Source: K. Grauman] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 54 / 82

Looking more locally... [Source: K. Grauman] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 55 / 82

Images as functions Edges look like steep cliffs [Source: N. Snavely] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 56 / 82

Characterizing Edges An edge is a place of rapid change in the image intensity function. [Source: S. Lazebnik] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 57 / 82

How to Implement Derivatives with Convolution How can we differentiate a digital image F[x,y]? Option 1: reconstruct a continuous image f, then compute the partial derivative as f (x, y) x = lim ɛ 0 f (x + ɛ, y) f (x) ɛ Option 2: take discrete derivative (finite difference) f (x, y) x f [x + 1, y] f [x] 1 Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 58 / 82

How to Implement Derivatives with Convolution How can we differentiate a digital image F[x,y]? Option 1: reconstruct a continuous image f, then compute the partial derivative as f (x, y) x = lim ɛ 0 f (x + ɛ, y) f (x) ɛ Option 2: take discrete derivative (finite difference) f (x, y) x f [x + 1, y] f [x] 1 What would be the filter to implement this using convolution? Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 58 / 82

How to Implement Derivatives with Convolution How can we differentiate a digital image F[x,y]? Option 1: reconstruct a continuous image f, then compute the partial derivative as f (x, y) x = lim ɛ 0 f (x + ɛ, y) f (x) ɛ Option 2: take discrete derivative (finite difference) f (x, y) x f [x + 1, y] f [x] 1 What would be the filter to implement this using convolution?!"!" 1-1 -1 1 [Source: S. Seitz] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 58 / 82

How to Implement Derivatives with Convolution How can we differentiate a digital image F[x,y]? Option 1: reconstruct a continuous image f, then compute the partial derivative as f (x, y) x = lim ɛ 0 f (x + ɛ, y) f (x) ɛ Option 2: take discrete derivative (finite difference) f (x, y) x f [x + 1, y] f [x] 1 What would be the filter to implement this using convolution?!"!" 1-1 -1 1 [Source: S. Seitz] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 58 / 82

Partial derivatives of an image Figure: Using correlation filters [Source: K. Grauman] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 59 / 82

Finite Difference Filters [Source: K. Grauman] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 60 / 82

Image Gradient The gradient of an image f = [ ] f x, f y The gradient points in the direction of most rapid change in intensity Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 61 / 82

Image Gradient The gradient of an image f = [ ] f x, f y The gradient points in the direction of most rapid change in intensity The gradient direction (orientation of edge normal) is given by: ( f θ = tan 1 y / f ) x Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 61 / 82

Image Gradient The gradient of an image f = [ ] f x, f y The gradient points in the direction of most rapid change in intensity The gradient direction (orientation of edge normal) is given by: ( f θ = tan 1 y / f ) x The edge strength is given by the magnitude f = ( f x )2 + ( f y )2 [Source: S. Seitz] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 61 / 82

Image Gradient The gradient of an image f = [ ] f x, f y The gradient points in the direction of most rapid change in intensity The gradient direction (orientation of edge normal) is given by: ( f θ = tan 1 y / f ) x The edge strength is given by the magnitude f = ( f x )2 + ( f y )2 [Source: S. Seitz] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 61 / 82

Image Gradient [Source: S. Lazebnik] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 62 / 82

Effects of noise Consider a single row or column of the image. Plotting intensity as a function of position gives a signal.!"#$%&#'()*&#+,-.& [Source: S. Seitz] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 63 / 82

Effects of noise Smooth first, and look for picks in x (h f ). [Source: S. Seitz] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 64 / 82

Derivative theorem of convolution Differentiation property of convolution It saves one operation h (h f ) = ( x x ) f = h ( f x ) [Source: S. Seitz] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 65 / 82

2D Edge Detection Filters Gaussian h σ (x, y) = 1 2πσ exp u 2 2 +v 2 2σ 2 Derivative of Gaussian (x) x h σ(u, v) [Source: N. Snavely] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 66 / 82

Derivative of Gaussians [Source: K. Grauman] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 67 / 82

Laplacian of Gaussians Edge by detecting zero-crossings of bottom graph [Source: S. Seitz] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 68 / 82

2D Edge Filtering with 2 the Laplacian operator 2 f = 2 f x + 2 f 2 y 2 [Source: S. Seitz] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 69 / 82

Effect of σ on derivatives The detected structures differ depending on the Gaussian s scale parameter: Larger values: larger scale edges detected. Smaller values: finer features detected. [Source: K. Grauman] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 70 / 82

Derivatives Use opposite signs to get response in regions of high contrast. They sum to 0 so that there is no response in constant regions. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 71 / 82

Derivatives Use opposite signs to get response in regions of high contrast. They sum to 0 so that there is no response in constant regions. High absolute value at points of high contrast. [Source: K. Grauman] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 71 / 82

Derivatives Use opposite signs to get response in regions of high contrast. They sum to 0 so that there is no response in constant regions. High absolute value at points of high contrast. [Source: K. Grauman] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 71 / 82

Band-pass filters The Sobel and corner filters are band-pass and oriented filters. More sophisticated filters can be obtained by convolving with a Gaussian filter G(x, y, σ) = 1 ( 2πσ 2 exp x 2 + y 2 ) 2σ 2 and taking the first or second derivatives. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 72 / 82

Band-pass filters The Sobel and corner filters are band-pass and oriented filters. More sophisticated filters can be obtained by convolving with a Gaussian filter G(x, y, σ) = 1 ( 2πσ 2 exp x 2 + y 2 ) 2σ 2 and taking the first or second derivatives. These filters are band-pass filters: they filter low and high frequencies. Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 72 / 82

Band-pass filters The Sobel and corner filters are band-pass and oriented filters. More sophisticated filters can be obtained by convolving with a Gaussian filter G(x, y, σ) = 1 ( 2πσ 2 exp x 2 + y 2 ) 2σ 2 and taking the first or second derivatives. These filters are band-pass filters: they filter low and high frequencies. The second derivative of a two-dimensional image is the laplacian operator 2 f = 2 f x 2 + 2 f y 2 Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 72 / 82

Band-pass filters The Sobel and corner filters are band-pass and oriented filters. More sophisticated filters can be obtained by convolving with a Gaussian filter G(x, y, σ) = 1 ( 2πσ 2 exp x 2 + y 2 ) 2σ 2 and taking the first or second derivatives. These filters are band-pass filters: they filter low and high frequencies. The second derivative of a two-dimensional image is the laplacian operator 2 f = 2 f x 2 + 2 f y 2 Blurring an image with a Gaussian and then taking its Laplacian is equivalent to convolving directly with the Laplacian of Gaussian (LoG) filter, Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 72 / 82

Band-pass filters The Sobel and corner filters are band-pass and oriented filters. More sophisticated filters can be obtained by convolving with a Gaussian filter G(x, y, σ) = 1 ( 2πσ 2 exp x 2 + y 2 ) 2σ 2 and taking the first or second derivatives. These filters are band-pass filters: they filter low and high frequencies. The second derivative of a two-dimensional image is the laplacian operator 2 f = 2 f x 2 + 2 f y 2 Blurring an image with a Gaussian and then taking its Laplacian is equivalent to convolving directly with the Laplacian of Gaussian (LoG) filter, Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 72 / 82

Band-pass filters The directional or oriented filter can obtained by smoothing with a Gaussian (or some other filter) and then taking a directional derivative u = u u (G f ) = u (G f ) = ( u G) f with u = (cos θ, sin θ). The Sobel operator is a simple approximation of this: Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 73 / 82

Practical Example [Source: N. Snavely] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 74 / 82

Finding Edges Figure: Gradient magnitude [Source: N. Snavely] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 75 / 82

Finding Edges!"#$#%&'%("#%#)*#+% Figure: Gradient magnitude [Source: N. Snavely] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 75 / 82

Non-Maxima Suppression Figure: Gradient magnitude Check if pixel is local maximum along gradient direction: requires interpolation [Source: N. Snavely] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 76 / 82

Finding Edges Figure: Thresholding [Source: N. Snavely] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 77 / 82

Finding Edges Figure: Thinning: Non-maxima suppression [Source: N. Snavely] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 77 / 82

Canny Edge Detector Matlab: edge(image, canny ) 1 Filter image with derivative of Gaussian 2 Find magnitude and orientation of gradient 3 Non-maximum suppression 4 Linking and thresholding (hysteresis): Define two thresholds: low and high Use the high threshold to start edge curves and the low threshold to continue them [Source: D. Lowe and L. Fei-Fei] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 78 / 82

Canny edge detector Still one of the most widely used edge detectors in computer vision J. Canny, A Computational Approach To Edge Detection, IEEE Trans. Pattern Analysis and Machine Intelligence, 8:679-714, 1986. Depends on several parameters: σ of the blur and the thresholds Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 79 / 82

Canny edge detector large σ detects large-scale edges small σ detects fine edges original Canny with Canny with [Source: S. Seitz] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 80 / 82

Scale Space (Witkin 83) first derivative peaks larger Gaussian filtered signal Properties of scale space (w/ Gaussian smoothing) edge position may shift with increasing scale (σ) two edges may merge with increasing scale an edge may not split into two with increasing scale [Source: N. Snavely] Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 81 / 82

Next class... more on filtering and image features Raquel Urtasun (TTI-C) Computer Vision Jan 10, 2013 82 / 82