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

Similar documents
Digital Image Processing

Image Enhancement in spatial domain. Digital Image Processing GW Chapter 3 from Section (pag 110) Part 2: Filtering in spatial domain

Prof. Feng Liu. Winter /10/2019

Digital Image Processing

Table of contents. Vision industrielle 2002/2003. Local and semi-local smoothing. Linear noise filtering: example. Convolution: introduction

Image Filtering in Spatial domain. Computer Vision Jia-Bin Huang, Virginia Tech

Digital Image Processing. Digital Image Fundamentals II 12 th June, 2017

Image preprocessing in spatial domain

EE482: Digital Signal Processing Applications

Image acquisition. Midterm Review. Digitization, line of image. Digitization, whole image. Geometric transformations. Interpolation 10/26/2016

Filtering in the spatial domain (Spatial Filtering)

More image filtering , , Computational Photography Fall 2017, Lecture 4

Image Filtering. Median Filtering

Prof. Vidya Manian Dept. of Electrical and Comptuer Engineering

Achim J. Lilienthal Mobile Robotics and Olfaction Lab, AASS, Örebro University

Motivation: Image denoising. How can we reduce noise in a photograph?

Prof. Feng Liu. Spring /12/2017

Practical Image and Video Processing Using MATLAB

Vision Review: Image Processing. Course web page:

Announcements. Image Processing. What s an image? Images as functions. Image processing. What s a digital image?

Chapter 3. Study and Analysis of Different Noise Reduction Filters

An Efficient Noise Removing Technique Using Mdbut Filter in Images

Non Linear Image Enhancement

Image Enhancement. DD2423 Image Analysis and Computer Vision. Computational Vision and Active Perception School of Computer Science and Communication

Fixing the Gaussian Blur : the Bilateral Filter

Motivation: Image denoising. How can we reduce noise in a photograph?

IMAGE PROCESSING: AREA OPERATIONS (FILTERING)

Robert Collins CSE486, Penn State. Lecture 3: Linear Operators

CS534 Introduction to Computer Vision. Linear Filters. Ahmed Elgammal Dept. of Computer Science Rutgers University

An Adaptive Kernel-Growing Median Filter for High Noise Images. Jacob Laurel. Birmingham, AL, USA. Birmingham, AL, USA

>>> from numpy import random as r >>> I = r.rand(256,256);

Image Processing for feature extraction

Image Denoising using Filters with Varying Window Sizes: A Study

Image filtering, image operations. Jana Kosecka

Templates and Image Pyramids

10. Noise modeling and digital image filtering

Image analysis. CS/CME/BIOPHYS/BMI 279 Fall 2015 Ron Dror

CoE4TN4 Image Processing. Chapter 3: Intensity Transformation and Spatial Filtering

PERFORMANCE ANALYSIS OF LINEAR AND NON LINEAR FILTERS FOR IMAGE DE NOISING

A Novel Multi-diagonal Matrix Filter for Binary Image Denoising

Templates and Image Pyramids

Computing for Engineers in Python

CS6670: Computer Vision Noah Snavely. Administrivia. Administrivia. Reading. Last time: Convolution. Last time: Cross correlation 9/8/2009

Fourier Transform. Any signal can be expressed as a linear combination of a bunch of sine gratings of different frequency Amplitude Phase

Filip Malmberg 1TD396 fall 2018 Today s lecture

Sensors and Sensing Cameras and Camera Calibration

Midterm Review. Image Processing CSE 166 Lecture 10

Matlab (see Homework 1: Intro to Matlab) Linear Filters (Reading: 7.1, ) Correlation. Convolution. Linear Filtering (warm-up slide) R ij

Midterm is on Thursday!

Image processing for gesture recognition: from theory to practice. Michela Goffredo University Roma TRE

DIGITAL IMAGE DE-NOISING FILTERS A COMPREHENSIVE STUDY

Part I Feature Extraction (1) Image Enhancement. CSc I6716 Spring Local, meaningful, detectable parts of the image.

A Spatial Mean and Median Filter For Noise Removal in Digital Images

Image Filtering. Reading Today s Lecture. Reading for Next Time. What would be the result? Some Questions from Last Lecture

CS/ECE 545 (Digital Image Processing) Midterm Review

Sampling and Reconstruction

This content has been downloaded from IOPscience. Please scroll down to see the full text.

CSC 320 H1S CSC320 Exam Study Guide (Last updated: April 2, 2015) Winter 2015

Analysis of the SUSAN Structure-Preserving Noise-Reduction Algorithm

On the evaluation of edge preserving smoothing filter

IMAGE ENHANCEMENT IN SPATIAL DOMAIN

I. INTRODUCTION II. EXISTING AND PROPOSED WORK

Image Denoising Using Statistical and Non Statistical Method

Filters. Materials from Prof. Klaus Mueller

Performance Analysis of Average and Median Filters for De noising Of Digital Images.

Introduction. Computer Vision. CSc I6716 Fall Part I. Image Enhancement. Zhigang Zhu, City College of New York

Interpolation of CFA Color Images with Hybrid Image Denoising

CEE598 - Visual Sensing for Civil Infrastructure Eng. & Mgmt.

Numerical Derivatives See also T&V, Appendix A.2 Gradient = vector of partial derivatives of image I(x,y) = [di(x,y)/dx, di(x,y)/dy]

Image Enhancement in the Spatial Domain Low and High Pass Filtering

Computer Vision, Lecture 3

CS 4501: Introduction to Computer Vision. Filtering and Edge Detection

Computer Vision Lecture 3

CSE 564: Visualization. Image Operations. Motivation. Provide the user (scientist, t doctor, ) with some means to: Global operations:

Image Enhancement using Histogram Equalization and Spatial Filtering

Performance Comparison of Mean, Median and Wiener Filter in MRI Image De-noising

>>> from numpy import random as r >>> I = r.rand(256,256);

Overview. Neighborhood Filters. Dithering

Image Enhancement contd. An example of low pass filters is:

Image Processing Computer Graphics I Lecture 20. Display Color Models Filters Dithering Image Compression

AN EFFICIENT ALGORITHM FOR THE REMOVAL OF IMPULSE NOISE IN IMAGES USING BLACKFIN PROCESSOR

Digital Image Processing. Lecture 5 (Enhancement) Bu-Ali Sina University Computer Engineering Dep. Fall 2009

Literature Survey On Image Filtering Techniques Jesna Varghese M.Tech, CSE Department, Calicut University, India

Images and Filters. EE/CSE 576 Linda Shapiro

Understanding Digital Signal Processing

A Comparative Analysis of Noise Reduction Filters in MRI Images

The Use of Non-Local Means to Reduce Image Noise

ACM Fast Image Convolutions. by: Wojciech Jarosz

Chapter 3 Image Enhancement in the Spatial Domain. Chapter 3 Image Enhancement in the Spatial Domain

Guided Image Filtering for Image Enhancement

Image Enhancement II: Neighborhood Operations

Motion illusion, rotating snakes

Enhancement. Degradation model H and noise must be known/predicted first before restoration. Noise model Degradation Model

Very High Resolution Satellite Images Filtering

Image Processing. Adam Finkelstein Princeton University COS 426, Spring 2019

Image analysis. CS/CME/BioE/Biophys/BMI 279 Oct. 31 and Nov. 2, 2017 Ron Dror

Performance Evaluation of Various Denoising Filters for Medical Image P.Deepa 1 and M.Suganthi 2

CSE 564: Scientific Visualization

Chapter 2 Image Enhancement in the Spatial Domain

Image Processing by Bilateral Filtering Method

Transcription:

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

Overview Correlation and convolution Linear filtering Smoothing, kernels, models Detection Derivatives Nonlinear filtering Median filtering Bilateral filtering Neighborhood statistics and nonlocal filtering 2

Cross Correlation Operation on image neighborhood and small mask, filter, stencil, kernel Linear operations within a moving window Input image 100 130 104 99 87 95 103 150 50 36 150 104 20 47 205 77 Filter 0.0 0.1 0.0 0.1 0.6 0.1 0.0 0.1 0.0 Output image 3

Cross Correlation Operation on image neighborhood and small mask, filter, stencil, kernel Linear operations within a moving window Input image 100 130 104 99 87 95 103 150 50 36 150 104 20 47 205 77 Filter 0.0 0.1 0.0 0.1 0.6 0.1 0.0 0.1 0.0 Output image 4

Cross Correlation Operation on image neighborhood and small mask, filter, stencil, kernel Linear operations within a moving window Input image 100 130 104 99 87 95 103 150 50 36 150 104 20 47 205 77 Filter 0.0 0.1 0.0 0.1 0.6 0.1 0.0 0.1 0.0 Output image 5

Cross Correlation Operation on image neighborhood and small mask, filter, stencil, kernel Linear operations within a moving window Input image 100 130 104 99 87 95 103 150 50 36 150 104 20 47 205 77 Filter 0.0 0.1 0.0 0.1 0.6 0.1 0.0 0.1 0.0 Output image 0.0*87 + 0.1*95 + 0.0*103 + 0.1*50 + 0.6*36 + 0.1*150 + 0.0*20 + 0.1*47 + 0.0*205 = 55.8 6

Cross Correlation Operation on image neighborhood and small mask, filter, stencil, kernel Linear operations within a moving window Input image 100 130 104 99 87 95 103 150 50 36 150 104 20 47 205 77 Filter 0.0 0.1 0.0 0.1 0.6 0.1 0.0 0.1 0.0 Output image. 55.8... 0.0*87 + 0.1*95 + 0.0*103 + 0.1*50 + 0.6*36 + 0.1*150 + 0.0*20 + 0.1*47 + 0.0*205 = 55.8 7

Cross Correlation Operation on image neighborhood and small mask, filter, stencil, kernel Linear operations within a moving window Input image 100 130 104 99 87 95 103 150 50 36 150 104 20 47 205 77 Filter 0.0 0.1 0.0 0.1 0.6 0.1 0.0 0.1 0.0 Output image. 55.8... 0.0*87 + 0.1*95 + 0.0*103 + 0.1*50 + 0.6*36 + 0.1*150 + 0.0*20 + 0.1*47 + 0.0*205 = 55.8 8

Cross Correlation Operation on image neighborhood and small mask, filter, stencil, kernel Linear operations within a moving window Input image 100 130 104 99 87 95 103 150 50 36 150 104 20 47 205 77 Filter 0.0 0.1 0.0 0.1 0.6 0.1 0.0 0.1 0.0 Output image. 55.8... 9

Cross Correlation Operation on image neighborhood and small mask, filter, stencil, kernel Linear operations within a moving window Input image 100 130 104 99 87 95 103 150 50 36 150 104 20 47 205 77 Filter 0.0 0.1 0.0 0.1 0.6 0.1 0.0 0.1 0.0 Output image 10

Cross Correlation Operation on image neighborhood and small mask, filter, stencil, kernel Linear operations within a moving window Input image 100 130 104 99 87 95 103 150 50 36 150 104 20 47 205 77 Filter 0.0 0.1 0.0 0.1 0.6 0.1 0.0 0.1 0.0 Output image 11

Cross Correlation Operation on image neighborhood and small mask, filter, stencil, kernel Linear operations within a moving window Input image 100 130 104 99 87 95 103 150 50 36 150 104 20 47 205 77 Filter 0.0 0.1 0.0 0.1 0.6 0.1 0.0 0.1 0.0 Output image 0.0*95 + 0.1*103 + 0.0*150 + 0.1*36 + 0.6*150 + 0.1*104 + 0.0*47 + 0.1*205 + 0.0*77 = 134.8 12

Cross Correlation Operation on image neighborhood and small mask, filter, stencil, kernel Linear operations within a moving window Input image 100 130 104 99 87 95 103 150 50 36 150 104 20 47 205 77 Filter 0.0 0.1 0.0 0.1 0.6 0.1 0.0 0.1 0.0 Output image.. 134.8.. 0.0*95 + 0.1*103 + 0.0*150 + 0.1*36 + 0.6*150 + 0.1*104 + 0.0*47 + 0.1*205 + 0.0*77 = 134.8 13

Cross Correlation 1D 2D 14

Correlation: Technical Details How to filter boundary?????????? 15

Correlation: Technical Details Boundary conditions Boundary not filtered (keep it 0) Pad image with amount (a,b) Constant value or repeat edge values Cyclical boundary conditions Wrap or mirroring 16

Correlation: Technical Details Boundaries Can also modify kernel no longer correlation For analysis Image domains infinite Data compact (goes to zero far away from origin) 17

Correlation: Properties Shift invariant 18

Correlation: Properties Shift invariant Linear Compact notation 19

Filters: Considerations Normalize Sums to one Sums to zero (some cases, see later) Symmetry Left, right, up, down Rotational Special case: auto correlation 20

Examples 1 0 0 0 0 1 0 0 0 0 21

Examples 1 0 0 0 0 1 0 0 0 0 22

Examples 1 0 0 0 0 1 0 0 0 0 1/9 * 1 1 1 1 1 1 1 1 1 23

Examples 1 0 0 0 0 1 0 0 0 0 1/9 * 1 1 1 1 1 1 1 1 1 24

Examples 1 1/9 * 1 1 1 1 1 1 1 1 1 25

Examples 2 1/9 * 1 1 1 1 1 1 1 1 1 1/25 * 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 26

Smoothing and Noise Noisy image 5x5 box filter 27

Noise Analysis Consider an a simple image I() with additive, uncorrelated, zero-mean noise of variance s What is the expected rms error of the corrupted image? If we process the image with a box filter of size 2a+1 what is the expected error of the filtered image? 28

Other Filters Disk Circularly symmetric, jagged in discrete case Gaussians Circularly symmetric, smooth for large enough stdev Must normalize in order to sum to one Derivatives discrete/finite differences Operators 30

Gaussian Kernel 31

Gaussian Kernel Normalization to 1.0 32

Box versus Gaussian 33

Discrete Convolution Java demo: http://www.jhu.edu/signals/convolve/ http://www.jhu.edu/signals/discreteconv2/index.html Continuous Same as cross correlation with kernel transposed around each axis The two operations (correlation and convolution) are the same if the kernel is symmetric about axes reflection of w 34

Convolution: Properties Shift invariant, linear Commutative Associative Others (discussed later): Derivatives, convolution theorem, spectrum 35

Computing Convolution 36

Computing Convolution Compute time MxM mask NxN image 37

Computing Convolution Compute time MxM mask NxN image O(M 2 N 2 ) for loops are nested 4 deep 38

Computing Convolution Compute time MxM mask NxN image O(M 2 N 2 ) Special case: separable for loops are nested 4 deep Two 1D kernels = * O(M 2 N 2 ) O(MN 2 ) 39

Separable Kernels Examples Box/rectangle Bilinear interpolation Combinations of partial derivatives d 2 f/dxdy Gaussian Only filter that is both circularly symmetric and separable Counter examples Disk Cone Pyramid 40

Separability 41

Digital Images: Boundaries are Lines or Discontinuities Example: Characterization of discontinuities? Source: http://web.media.mit.edu/~maov/classes/vision09/lect/09_image_filtering_edge_detection_09.pdf 42

Digital Images: Boundaries are Lines or Discontinuities Example: Characterization of discontinuities? Source: http://web.media.mit.edu/~maov/classes/vision09/lect/09_image_filtering_edge_detection_09.pdf 43

Source: http://web.media.mit.edu/~maov/classes/vision09/lect/09_image_filtering_edge_detection_09.pdf 44

Source: http://web.media.mit.edu/~maov/classes/vision09/lect/09_image_filtering_edge_detection_09.pdf 45

Derivatives: Finite Differences 46

Derivative Example 0 0 0-1 0 1 0 0 0 0-1 0 0 0 0 0 1 0 47

Source: http://web.media.mit.edu/~maov/classes/vision09/lect/09_image_filtering_edge_detection_09.pdf 48

Source: http://web.media.mit.edu/~maov/classes/vision09/lect/09_image_filtering_edge_detection_09.pdf 49

Source: http://web.media.mit.edu/~maov/classes/vision09/lect/09_image_filtering_edge_detection_09.pdf 50

Pattern Matching 51

Pattern Matching/Detection The optimal (highest) response from a filter is the autocorrelation evaluated at position zero A filter responds best when it matches a pattern that looks itself Strategy Detect objects in images by correlation with matched filter 52

Matched Filter Example 53

Matched Filter Example: Correlation of template with image 54

Matched Filter Example: Thresholding of correlation results 55

Matched Filter Example: High correlation template found 56

Summary of 9/15 Spatial Filtering Consider neighborhood information Special consideration at boundary????????? 57

Summary of 9/15 Common Filters Box Gaussian Derivative 1/9 * 1 1 1 1 1 1 1 1 1 58

Box versus Gaussian 59

Gaussian Filtering 60

Gaussian Filtering 61

Source: http://web.media.mit.edu/~maov/classes/vision09/lect/09_image_filtering_edge_detection_09.pdf 62

Cross-correlation and Convolution Cross-correlation Convolution 63

Separability Key Concepts = O(M 2 N 2 ) O(MN 2 ) 64

Nonlinear Methods For Median filtering Bilateral filtering Filtering Neighborhood statistics and nonlocal filtering 65

Median Filtering For each neighborhood in image Sliding window Usually odd size (symmetric) 5x5, 7x7, Sort the greyscale values Set the center pixel to the median Important: use Jacobi updates Separate input and output buffers All statistics on the original image old new 66

Median vs Gaussian Original + Gaussian Noise 3x3 Median 3x3 Box 67

Median Filter Issues Boundaries Compute on pixels that fall within window Computational efficiency What is the best algorithm? Properties Removes outliers (replacement noise salt and pepper) Window size controls size of structures Preserves straight edges, but rounds corners and features 68

Replacement Noise Also: shot noise, salt&pepper Replace certain % of pixels with samples from pdf Best filtering strategy: filter to avoid outliers 69

Smoothing of S&P Noise It s not zero mean (locally) Averaging produces local biases 70

Smoothing of S&P Noise It s not zero mean (locally) Averaging produces local biases 71

Median Filtering Median 3x3 Median 5x5 72

Median Filtering Median 3x3 Median 5x5 73

Median Filtering Iterate Median 3x3 2x Median 3x3 74

Median Filtering Image model: piecewise constant (flat) 75

Median Filtering Image model: piecewise constant (flat) Ordering Output 76

Median Filtering Image model: piecewise constant (flat) 77

Median Filtering Image model: piecewise constant (flat) Ordering Output 78

Order Statistics Median is special case of order-statistics filters Instead of weights based on neighborhoods, weights are based on ordering of data Neighborhood Ordering Filter Neighborhood average (box) Median filter Trimmed average (outlier removal) 79

Source: http://web.media.mit.edu/~maov/classes/vision09/lect/09_image_filtering_edge_detection_09.pdf 80

Piecewise Flat Image Models Image piecewise flat -> average only within similar regions Problem: don t know region boundaries 81

Piecewise-Flat Image Models Assign probabilities to other pixels in the image belonging to the same region Two considerations Distance: far away pixels are less likely to be same region Intensity: pixels with different intensities are less likely to be same region 82

Gaussian: Blur Comes from Averaging across Edges input * output * * Same Gaussian kernel everywhere. Source: http://people.csail.mit.edu/sparis/bf_course/slides/03_definition_bf.ppt

Bilateral Filter No Averaging across Edges [Aurich 95, Smith 97, Tomasi 98] input * output * * The kernel shape depends on the image content. Source: http://people.csail.mit.edu/sparis/bf_course/slides/03_definition_bf.ppt

Main Idea Distance (kernel/pdf) Distance (pdf) Prob pixel belongs to same region as i position Prob pixel belongs to same region as i intensity 85

BF Bilateral Filter Definition: an Additional Edge Term Same idea: weighted average of pixels. new q S not new 1 [ I] p G r W s p new p q G I I p q I q normalization factor space weight range weight Source: http://people.csail.mit.edu/sparis/bf_course/slides/03_definition_bf.ppt

Illustration a 1D Image 1D image = line of pixels Better visualized as a plot pixel intensity pixel position Source: http://people.csail.mit.edu/sparis/bf_course/slides/03_definition_bf.ppt

Gaussian Blur and Bilateral Filter Gaussian blur p q GB I] G p q [ p q S space I q space Source: http://people.csail.mit.edu/sparis/bf_course/slides/03_definition_bf.ppt

Gaussian Blur and Bilateral Filter Gaussian blur p q GB [ I] p G q S p q space I q space Bilateral filter [Aurich 95, Smith 97, Tomasi 98] q p range BF 1 [ I ] p G W s r p q S space normalization p q G I I p range q I q space Source: http://people.csail.mit.edu/sparis/bf_course/slides/03_definition_bf.ppt

Bilateral Filter Neighborhood sliding window Weight contribution of neighbors according to: normalization: all weights add up to 1 G is a Gaussian (or lowpass), as is H, N is neighborhood, Often use G(r ij ) where r ij is distance between pixels Update must be normalized for the samples used in this (particular) summation Spatial Gaussian with extra weighting for intensity Weighted average in neighborhood with downgrading of intensity outliers Tomasi, Manduchi: http://en.wikipedia.org/wiki/bilateral_filter http://homepages.inf.ed.ac.uk/rbf/cvonline/local_copies/manduchi1/bilateral_filtering.html 90

Bilateral Filter Replaces the pixel value at x with an average of similar and nearby pixel values. When the bilateral filter is centered, say, on a pixel on the bright side of the boundary, the similarity function s assumes values close to one for pixels on the same side, and values close to zero for pixels on the dark side. The similarity function is shown in figure 1(b) for a 23x23 filter support centered two pixels to the right of the step in figure 1(a). 91

Bilateral Filtering Replaces the pixel value at x with an average of similar and nearby pixel values. Gaussian Blurring Bilateral 92

Bilateral Filtering Gaussian Blurring Bilateral 93

Nonlocal Averaging Recent algorithm NL-means, Baudes et al., 2005 UINTA, Awate & Whitaker, 2005 Different model No need for piecewise-flat Images consist of some set of pixels with similar neighborhoods average several of those Scattered around General area of a pixel All around Idea Average sets of pixels with similar neighborhoods 94

UINTA: Unsupervised Information-Theoretic Adaptive Filtering : Excellent Introduction and Additional Readings (Suyash P. Awate) http://www.cs.utah.edu /~suyash/pubs/uinta/ Suyash P. Awate, Ross T. Whitaker Unsupervised, Information-Theoretic, Adaptive Image Filtering with Applications to Image Restoration IEEE Trans. Pattern Analysis & Machine Intelligence (TPAMI) 2006, Vol. 28, Num. 3, pp. 364-376 95

Nonlocal Averaging Strategy: Average pixels to alleviate noise Combine pixels with similar neighborhoods Formulation n i,j vector of pixels values, indexed by j, from neighborhood around pixel i vector = 96

Nonlocal Averaging Formulation Distance between neighborhoods Kernel weights based on distances w i, k K ( di, k ) e d 2 i, k 2 2 Pixel values of k neighborhoods: f k 97

Averaging Pixels Based on Weights For each pixel, i, choose a set of pixel locations k: k = 1,., M Average them together based on neighborhood weights (prop. to intensity pattern difference) g i 1 M M w k 1 i, k k 1 w i, k f k 98

Nonlocal Averaging 99

Some Details Window sizes: good range is 5x5- >11x11 How to choose samples: Random samples from around the image UINTA, Awate&Whitaker Block around pixel (bigger than window, e.g. 51x51) NL-means Iterate UNITA: smaller updates and iterate 100

NL-Means Algorithm For each pixel, p Loop over set of pixels nearby Compare the neighorhoods of those pixels to the neighborhood of p and construct a set of weights Replace the value of p with a weighted combination of values of other pixels Repeat but 1 iteration is pretty good 101

Results Noisy image (range 0.0-1.0) Bilateral filter (3.0, 0.1) 102

Results Bilateral filter (3.0, 0.1) NL means (7, 31, 1.0) 103

Results Bilateral filter (3.0, 0.1) NL means (7, 31, 1.0) 104

Less Noisy Example 105

Less Noisy Example 106

Results Original Noisy Filtered 107

Checkerboard With Noise Original Noisy Filtered 108

Quality of Denoising, joint entropy, and RMS- error vs. number of iterations 109

MRI Head 110

MRI Head 111

Fingerprint 112

Fingerprint 113

Results Original Noisy Filtered 114

Results Original Noisy Filtered 115

Results Original Noisy Filtered 116

Fractal Original Noisy Filtered 117

Piecewise Constant Several 10s of Iterations Tends to obliterate rare events (e.g. corners) 118

Texture, Structure 119

120