Filtering in frequency domain

Similar documents
Review of Filtering. Filtering in frequency domain

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

Edge detection. Goal: Identify sudden. an image. Ideal: artist s line drawing. object-level knowledge)

DIGITAL IMAGE PROCESSING

Edge Detection. Computer Vision Shiv Ram Dubey, IIIT Sri City

Does everyone have an override code?

Lecture 7: Most Common Edge Detectors

Edge and corner detection

Edge Detection. CSE 576 Ali Farhadi. Many slides from Steve Seitz and Larry Zitnick

Edges and Binary Images

Edge detection. Winter in Kraków photographed by Marcin Ryczek

Edge Detection CSC 767

Prof. Feng Liu. Winter /15/2019

Edge detection. Winter in Kraków photographed by Marcin Ryczek

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

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

Edge Detection. CSC320: Introduction to Visual Computing Michael Guerzhoy. René Magritte, Decalcomania. Many slides from Derek Hoiem, Robert Collins

CS5670: Computer Vision

Digital Image Processing COSC 6380/4393

Image Analysis. Edge Detection

What is an edge? Paint. Depth discontinuity. Material change. Texture boundary

Low-level Vision Processing Algorithms Speaker: Ito, Dang Supporter: Ishii, Toyama and Y. Murakami

Edge Detection. Announcements. Edge detection. Origin of Edges. Mailing list: you should have received messages

Image Analysis. Edge Detection

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

Edge Detection. EE/CSE 576 Linda Shapiro

Lecture 6: Edge Detection

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

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

Image Pyramids and Applications

Image gradients and edges April 11 th, 2017

CS4670: Computer Vision Noah Snavely

Image gradients and edges April 10 th, 2018

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

Edge detection. Convert a 2D image into a set of curves. Extracts salient features of the scene More compact than pixels

Lecture 4: Finding lines: from detection to model fitting

CS 2770: Computer Vision. Edges and Segments. Prof. Adriana Kovashka University of Pittsburgh February 21, 2017

Digital Image Processing. Image Enhancement - Filtering

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

Image gradients and edges

Computer Vision I. Announcements. Fourier Tansform. Efficient Implementation. Edge and Corner Detection. CSE252A Lecture 13.

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

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

Edge Detection. Today s reading. Cipolla & Gee on edge detection (available online) From Sandlot Science

Thinking in Frequency

Straight Lines and Hough

Anno accademico 2006/2007. Davide Migliore

Image gradients and edges

2%34 #5 +,,% ! # %& ()% #% +,,%. & /%0%)( 1 ! # %& % %()# +(& ,.+/ +&0%//#/ &

Applications of Image Filters

Other Linear Filters CS 211A

EE795: Computer Vision and Intelligent Systems

EEM 561 Machine Vision. Week 3: Fourier Transform and Image Pyramids

Filtering Images. Contents

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

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

SYDE 575: Introduction to Image Processing

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

Local Image preprocessing (cont d)

Image Processing. Traitement d images. Yuliya Tarabalka Tel.

Biomedical Image Analysis. Point, Edge and Line Detection

Image Processing

Computer Vision I. Announcement. Corners. Edges. Numerical Derivatives f(x) Edge and Corner Detection. CSE252A Lecture 11

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

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

Comparison between Various Edge Detection Methods on Satellite Image

Lecture 4: Spatial Domain Transformations

Ulrik Söderström 16 Feb Image Processing. Segmentation

Announcements. Edges. Last Lecture. Gradients: Numerical Derivatives f(x) Edge Detection, Lines. Intro Computer Vision. CSE 152 Lecture 10

Filtering and Enhancing Images

CS4442/9542b Artificial Intelligence II prof. Olga Veksler

SURVEY ON IMAGE PROCESSING IN THE FIELD OF DE-NOISING TECHNIQUES AND EDGE DETECTION TECHNIQUES ON RADIOGRAPHIC IMAGES

Why is computer vision difficult?

CS4442/9542b Artificial Intelligence II prof. Olga Veksler

Edge detection. Stefano Ferrari. Università degli Studi di Milano Elaborazione delle immagini (Image processing I)

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

Lecture: Edge Detection

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

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

SRCEM, Banmore(M.P.), India

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

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

EECS490: Digital Image Processing. Lecture #19

Lecture 4: Image Processing

Edges, interpolation, templates. Nuno Vasconcelos ECE Department, UCSD (with thanks to David Forsyth)

Lecture 2 Image Processing and Filtering

Edge detection. Gradient-based edge operators

Practical Image and Video Processing Using MATLAB

Filtering Applications & Edge Detection. GV12/3072 Image Processing.

Edge Detection Lecture 03 Computer Vision

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

Edges and Binary Image Analysis April 12 th, 2018

Neighborhood operations

Noise Model. Important Noise Probability Density Functions (Cont.) Important Noise Probability Density Functions

ECG782: Multidimensional Digital Signal Processing

Segmentation and Grouping

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

Feature Detectors - Sobel Edge Detector

Previously. Edge detection. Today. Thresholding. Gradients -> edges 2/1/2011. Edges and Binary Image Analysis

Multimedia Systems Image III (Image Compression, JPEG) Mahdi Amiri April 2011 Sharif University of Technology

Transcription:

Filtering in frequency domain FFT FFT = Inverse FFT

Filtering in frequency domain Can be faster than filtering in spatial domain (for large filters) Can help understand effect of filter Algorithm: 1. Convert image and filter to fft (fft2 in matlab) 2. Pointwise-multiply ffts 3. Convert result to spatial domain with ifft2

Filtering in spatial domain 1 2 0 0-1 -2 1 0-1 * =

Filtering in spatial domain Slide filter over image and take dot product at each position Remember linearity (for linear filters) Examples 2D: [1 0 0 ; 0 2 0 ; 0 0 1]/4

Sinc Filter What is the spatial representation of the hard cutoff in the frequency domain? Frequency Domain Spatial Domain

LPF HPF frequency domain spatial domain

Filtering with the FFT in Matlab (from previous lecture) im = double(imread('baboon1.bmp'))/255; im = rgb2gray(im); % im should be a gray-scale floating point image figure; imshow(im); [imh, imw] = size(im); hs = 50; % filter half-size fil = fspecial('gaussian', hs*2+1, 10); figure; bar3(fil); fftsize = 1024; % should be order of 2 (for speed) and include padding im_fft = fft2(im, fftsize, fftsize); % 1) fft im with padding figure(); imagesc(log(abs(fftshift(im_fft)))), axis image, colormap jet fil_fft = fft2(fil, fftsize, fftsize); image % 2) fft fil, pad to same size as figure(); imagesc(log(abs(fftshift(fil_fft)))), axis image, colormap jet im_fil_fft = im_fft.* fil_fft; % 3) multiply fft images im_fil = ifft2(im_fil_fft); % 4) inverse fft2 im_fil = im_fil(1+hs:size(im,1)+hs, 1+hs:size(im, 2)+hs); % 5) remove padding figure; imshow(im_fil);

image/video enhancement image/video restoration (contrast, sharpness, color) (noise reduction) - remove irrelevant information - increase spatio-temporal correlation - improve compression

Restoration vs. Enhancement Restoration: Undo or invert a mathematical model of the degradation to obtain the ideal image. Some serious image degradations cannot be accounted for by simple filtering techniques unless the degradation is correctly modeled and addressed in a principled way. Enhancement: Produce a more pleasing image without using a particular model of the degradation, but possibly using a model of human perception. contrast improvement, sharpening, etc.

Image Restoration: An Example The power of knowing and using the degradation model (From Gonzalez & Woods, Digital Image Processing)

Noise: random unwanted portion of signal/data without meaning; an unwanted by-product of other activities. Image noise: random variation of brightness or color in images; usually an aspect of electronic noise. Gaussian noise: caused primarily by thermal noise in amplifier circuitry of camera Salt and Pepper noise: caused by analog-todigital converter errors, bit errors in transmission Shot noise: variation in the number of photons sensed at a given exposure level Film grain: due to the grain of photographic film

Salt and pepper noise: contains random occurrences of black and white pixels Impulse noise: contains random occurrences of white pixels Gaussian noise: variations in intensity drawn from a Gaussian normal distribution CMSC 733 Computer Processing of Pictorial Information

Noise Characterization The level of noise is often measured in terms of SNR. It may be impossible to distinguish genuine image details from variations of the image intensity due to noise. Often both will be characterized by statistical models. Noise models: Additive/multiplicative, signaldependent/signal-independent, white/colored, Gaussian/other distribution, etc. A simple additive model: g(x,y,t) = f(x,y,t) + w(x,y,t)

Noise Filters linear filters - mean, average, box filters - Gaussian filters order-statistic filters - median filters multiresolution filters

Noise Reduction Gaussian Filter Additive Gaussian Noise

Reducing Gaussian noise Smoothing with larger standard deviations suppresses noise, but also blurs the image Source: S. Lazebnik

Reducing salt-and-pepper noise by Gaussian smoothing 3x3 5x5 7x7

Alternative idea: Median filtering A median filter operates over a window by selecting the median intensity in the window Is median filtering linear? Source: K. Grauman

Median filter What advantage does median filtering have over Gaussian filtering? Robustness to outliers Source: K. Grauman

Median filter Salt-and-pepper noise Median filtered MATLAB: medfilt2(image, [h w]) Source: M. Hebert

Median vs. Gaussian filtering 3x3 5x5 7x7 Gaussian Median

Other non-linear filters Weighted median (pixels further from center count less) Clipped mean (average, ignoring few brightest and darkest pixels) Bilateral filtering (weight by spatial distance and intensity difference) Bilateral filtering Image: http://vision.ai.uiuc.edu/?p=1455

Compression How is it that a 4MP image can be compressed to a few hundred KB without a noticeable change?

Lossy Image Compression (JPEG) Block-based Discrete Cosine Transform (DCT) Slides: Efros

Using DCT in JPEG The first coefficient B(0,0) is the DC component, the average intensity The top-left coeffs represent low frequencies, the bottom right high frequencies

Image compression using DCT Quantize More coarsely for high frequencies (which also tend to have smaller values) Many quantized high frequency values will be zero Encode Filter responses Can decode with inverse dct Quantization table Quantized values

JPEG Compression Summary 1. Convert image to YCrCb 2. Subsample color by factor of 2 People have bad resolution for color 3. Split into blocks (8x8, typically), subtract 128 4. For each block a. Compute DCT coefficients b. Coarsely quantize Many high frequency components will become zero c. Encode (e.g., with Huffman coding) http://en.wikipedia.org/wiki/ycbcr http://en.wikipedia.org/wiki/jpeg

Detecting Features in an Image - Edges - Lines - Points - Patches Source: D. Lowe

Edge detection Goal: Identify sudden changes (discontinuities) in an image Intuitively, most semantic and shape information from the image can be encoded in the edges More compact than pixels Ideal: artist s line drawing (but artist is also using object-level knowledge) Source: D. Lowe

Why do we care about edges? Extract information, recognize objects Recover geometry and viewpoint Vanishing line Vanishing point Vertical vanishing point (at infinity) Vanishing point

Origin of Edges surface normal discontinuity depth discontinuity surface color discontinuity illumination discontinuity Edges are caused by a variety of factors Source: Steve Seitz

Closeup of edges Source: D. Hoiem

Closeup of edges Source: D. Hoiem

Closeup of edges Source: D. Hoiem

Closeup of edges Source: D. Hoiem

Characterizing edges An edge is a place of rapid change in the image intensity function image intensity function (along horizontal scanline) first derivative edges correspond to extrema of derivative

Edge Detection with Gradient Operators separable

Other filters 1 2 1 0 0 0 Sobel -1-2 -1 Vertical Edge (absolute value)

Other filters 1 0-1 2 0-2 Sobel 1 0-1 Horizontal Edge (absolute value)

Intensity profile Source: D. Hoiem

With a little Gaussian noise Gradient Source: D. Hoiem

Effects of noise Consider a single row or column of the image Plotting intensity as a function of position gives a signal Where is the edge? Source: S. Seitz

Effects of noise Difference filters respond strongly to noise Image noise results in pixels that look very different from their neighbors Generally, the larger the noise the stronger the response What can we do about it? Source: D. Forsyth

Solution: smooth first f g f * g d dx ( f g) To find edges, look for peaks in ( f g) d dx Source: S. Seitz

Derivative theorem of convolution Differentiation is convolution, and convolution is associative: d d ( f g) = f g dx dx This saves us one operation: f d dx g f d dx g Source: S. Seitz

Derivative of Gaussian filter * [1-1] =

Tradeoff between smoothing and localization 1 pixel 3 pixels 7 pixels Smoothed derivative removes noise, but blurs edge. Also finds edges at different scales. Source: D. Forsyth

Implementation issues The gradient magnitude is large along a thick trail or ridge, so how do we identify the actual edge points? How do we link the edge points to form curves? Source: D. Forsyth

Designing an edge detector Criteria for a good edge detector: Good detection: the optimal detector should find all real edges, ignoring noise or other artifacts Good localization the edges detected must be as close as possible to the true edges the detector must return one point only for each true edge point Cues of edge detection Differences in color, intensity, or texture across the boundary Continuity and closure High-level knowledge Source: L. Fei-Fei

Slide 50 2007 Texas Instruments Inc, Gradient Operators The gradient of the image I(x,y) at location (x,y), is the vector: The magnitude of the gradient: The direction of the gradient vector: ( ) ( ) = = y y x I x y x I G G I y x,, [ ] 2 2 G x G y I I + = = ( ) = y x G G y x 1 tan, θ

The Meaning of the Gradient It represents the direction of the strongest variation in intensity Vertical Horizontal Generic Edge Strength: Edge Direction: I θ = G x ( x, y) = 0 I θ = G ( x, y) y = π 2 I = θ 2 2 [ G + G ] G 1 y ( x, y) = tan Gx x y The direction of the edge at location (x,y) is perpendicular to the gradient vector at that point 2007 Texas Instruments Inc, Slide 51

Calculating the Gradient For each pixel the gradient is calculated, based on a 3x3 neighborhood around this pixel. z 1 z 2 z 3 z 4 z 5 z 6 z 7 z 8 z 9 2007 Texas Instruments Inc, Slide 52

The Sobel Edge Detector -1-2 -1-1 0 1 0 0 0-2 0 2 1 2 1-1 0 1 ( z + 2z + z ) ( z + z z ) G y ( z + 2z + z ) ( z + z + z ) G x + 7 8 9 1 2 2 3 3 6 9 1 2 4 7 2007 Texas Instruments Inc, Slide 53

The Prewitt Edge Detector -1-1 -1-1 0 1 0 0 0-1 0 1 1 1 1-1 0 1 ( z + z + z ) ( z + z ) G ( z z z ) ( z z ) y + + + + G x + 7 8 9 1 2 z3 3 6 9 1 4 z7 2007 Texas Instruments Inc, Slide 54

The Roberts Edge Detector 0 0 0 0 0 0 0-1 0 0 0-1 0 0 1 0 1 0 G x G y z 8 z6 z 9 z 5 The Roberts Edge Detector is in fact a 2x2 operator 2007 Texas Instruments Inc, Slide 55

The Canny Method Two Possible Implementations: 1. The image is convolved with a Gaussian filter before gradient evaluation h ( r) = e r 2 2σ 2 r = x 2 + y 2 2. The image is convolved with the gradient of the Gaussian Filter. 2007 Texas Instruments Inc, Slide 56

The Edge Detection Algorithm The gradient is calculated (using any of the four methods described in the previous slides), for each pixel in the picture. If the absolute value exceeds a threshold, the pixel belongs to an edge. The Canny method uses two thresholds, and enables the detection of two edge types: strong and weak edge. If a pixel's magnitude in the gradient image, exceeds the high threshold, then the pixel corresponds to a strong edge. Any pixel connected to a strong edge and having a magnitude greater than the low threshold corresponds to a weak edge. 2007 Texas Instruments Inc, Slide 57

Canny edge detector This is probably the most widely used edge detector in computer vision Theoretical model: step-edges corrupted by additive Gaussian noise Canny has shown that the first derivative of the Gaussian closely approximates the operator that optimizes the product of signal-to-noise ratio and localization J. Canny, A Computational Approach To Edge Detection, IEEE Trans. Pattern Analysis and Machine Intelligence, 8:679-714, 1986. Source: L. Fei-Fei

Note about Matlab s Canny detector Small errors in implementation Gaussian function not properly normalized First filters with a Gaussian, then a difference of Gaussian (equivalent to filtering with a larger Gaussian and taking difference)

Example original image (Lena)

Derivative of Gaussian filter x-direction y-direction

Compute Gradients (DoG) X-Derivative of Gaussian Y-Derivative of Gaussian Gradient Magnitude

Get Orientation at Each Pixel Threshold at minimum level Get orientation theta = atan2(gy, gx)

Non-maximum suppression for each orientation At q, we have a maximum if the value is larger than those at both p and at r. Interpolate to get these values. Source: D. Forsyth

Edge linking Assume the marked point is an edge point. Then we construct the tangent to the edge curve (which is normal to the gradient at that point) and use this to predict the next points (here either r or s). Source: D. Forsyth

Sidebar: Bilinear Interpolation http://en.wikipedia.org/wiki/bilinear_interpolation

Examples from http://en.wikipedia.org/wiki/bicubic_interpolation Sidebar: Interpolation options imx2 = imresize(im, 2, interpolation_type) nearest Copy value from nearest known Very fast but creates blocky edges bilinear Weighted average from four nearest known pixels Fast and reasonable results bicubic (default) Non-linear smoothing over larger area (4x4) Slower, visually appealing, may create negative pixel values

Before Non-max Suppression

After non-max suppression

Before Non-max Suppression

After non-max suppression

Hysteresis thresholding Threshold at low/high levels to get weak/strong edge pixels Do connected components, starting from strong edge pixels

Hysteresis thresholding Check that maximum value of gradient value is sufficiently large drop-outs? use hysteresis use a high threshold to start edge curves and a low threshold to continue them. Source: S. Seitz

Final Canny Edges

Canny edge detector 1. Filter image with x, y derivatives of Gaussian 2. Find magnitude and orientation of gradient 3. Non-maximum suppression: Thin multi-pixel wide ridges down to single pixel width 4. Thresholding and linking (hysteresis): Define two thresholds: low and high Use the high threshold to start edge curves and the low threshold to continue them MATLAB: edge(image, canny ) Source: D. Lowe, L. Fei-Fei

Effect of σ (Gaussian kernel spread/size) original Canny with Canny with The choice of σ depends on desired behavior large σ detects large scale edges small σ detects fine features Source: S. Seitz