Spatial Filtering Dr. Amnach Khawne.

Slides:



Advertisements
Similar presentations
Linear Filtering – Part I Selim Aksoy Department of Computer Engineering Bilkent University
Advertisements

Spatial Filtering (Chapter 3)
Image Processing Lecture 4
Chapter 3 Image Enhancement in the Spatial Domain.
ECE 472/572 - Digital Image Processing Lecture 7 - Image Restoration - Noise Models 10/04/11.
Digital Image Processing Chapter 5: Image Restoration.
Image Enhancement Digital Image Processing Instructor: Dr. Cheng-Chien LiuCheng-Chien Liu Department of Earth Sciences National Cheng Kung University Last.
E.G.M. PetrakisFiltering1 Linear Systems Many image processing (filtering) operations are modeled as a linear system Linear System δ(x,y) h(x,y)
Digital Image Processing In The Name Of God Digital Image Processing Lecture3: Image enhancement M. Ghelich Oghli By: M. Ghelich Oghli
5. 1 Model of Image degradation and restoration
1 © 2010 Cengage Learning Engineering. All Rights Reserved. 1 Introduction to Digital Image Processing with MATLAB ® Asia Edition McAndrew ‧ Wang ‧ Tseng.
Digital Image Processing
Digital Image Processing Chapter 5: Image Restoration.
1 Image Filtering Readings: Ch 5: 5.4, 5.5, 5.6,5.7.3, 5.8 (This lecture does not follow the book.) Images by Pawan SinhaPawan Sinha formal terminology.
Image Analysis Preprocessing Arithmetic and Logic Operations Spatial Filters Image Quantization.
Linear filtering.
DIGITAL IMAGE PROCESSING Instructors: Dr J. Shanbehzadeh M.Gholizadeh M.Gholizadeh
Chapter 5 Image Restoration. Preview Goal: improve an image in some predefined sense. Image enhancement: subjective process Image restoration: objective.
Basic Image Processing January 26, 30 and February 1.
Chapter 3 (cont).  In this section several basic concepts are introduced underlying the use of spatial filters for image processing.  Mainly spatial.
Digital Image Processing Lecture 4 Image Restoration and Reconstruction Second Semester Azad University Islamshar Branch
Machine Vision ENT 273 Image Filters Hema C.R. Lecture 5.
1 Chapter 8: Image Restoration 8.1 Introduction Image restoration concerns the removal or reduction of degradations that have occurred during the acquisition.
Chapter 5 Image Restoration.
Image Restoration and Reconstruction (Noise Removal)
Digital Image Processing Image Enhancement Part IV.
DIGITAL IMAGE PROCESSING Instructors: Dr J. Shanbehzadeh M.Gholizadeh M.Gholizadeh
Chapter 5 Neighborhood Processing
Digital Image Processing
Chapter 3: Image Restoration Introduction. Image restoration methods are used to improve the appearance of an image by applying a restoration process.
Digital Image Processing Lecture 5: Neighborhood Processing: Spatial Filtering Prof. Charlene Tsai.
Image processing Fourth lecture Image Restoration Image Restoration: Image restoration methods are used to improve the appearance of an image.
انجمن دانشجویان ایران – مرجع دانلود کتاب ، نمونه سوال و جزوات درسی
Image Restoration Chapter 5.
Digital Image Processing Lecture 10: Image Restoration March 28, 2005 Prof. Charlene Tsai.
Chapter 5: Neighborhood Processing
Linear filtering. Motivation: Noise reduction Given a camera and a still scene, how can you reduce noise? Take lots of images and average them! What’s.
Lecture 5 Mask/Filter Transformation 1.The concept of mask/filters 2.Mathematical model of filtering Correlation, convolution 3.Smoother filters 4.Filter.
Machine Vision ENT 273 Image Filters Hema C.R. Lecture 5.
Image Restoration Fasih ur Rehman. –Goal of restoration: improve image quality –Is an objective process compared to image enhancement –Restoration attempts.
Digital Image Processing Lecture 10: Image Restoration
8-1 Chapter 8: Image Restoration Image enhancement: Overlook degradation processes, deal with images intuitively Image restoration: Known degradation processes;
Spatial Filtering (Applying filters directly on Image) By Engr. Muhammad Saqib.
Ch5 Image Restoration CS446 Instructor: Nada ALZaben.
Image Subtraction Mask mode radiography h(x,y) is the mask.
Intelligent Vision Systems ENT 496 Image Filtering and Enhancement Hema C.R. Lecture 4.
Chapter 5: Neighborhood Processing 5.1 Introduction
Digital Image Processing Lecture 5: Neighborhood Processing: Spatial Filtering March 9, 2004 Prof. Charlene Tsai.
Chapter 5 Image Restoration.
Image Restoration: Noise Models By Dr. Rajeev Srivastava.
Linear filtering. Motivation: Image denoising How can we reduce noise in a photograph?
1 © 2010 Cengage Learning Engineering. All Rights Reserved. 1 Introduction to Digital Image Processing with MATLAB ® Asia Edition McAndrew ‧ Wang ‧ Tseng.
Image Restoration. Image restoration vs. image enhancement Enhancement:  largely a subjective process  Priori knowledge about the degradation is not.
Lecture 22 Image Restoration. Image restoration Image restoration is the process of recovering the original scene from the observed scene which is degraded.
6/10/20161 Digital Image Processing Lecture 09: Image Restoration-I Naveed Ejaz.
Lecture 10 Chapter 5: Image Restoration. Image restoration Image restoration is the process of recovering the original scene from the observed scene which.
Digital Image Processing
Image Subtraction Mask mode radiography h(x,y) is the mask.
Digital Image Processing Lecture 10: Image Restoration
IMAGE PROCESSING IMAGE RESTORATION AND NOISE REDUCTION
Image Pre-Processing in the Spatial and Frequent Domain
Digital Image Processing
Digital Image Processing
DIGITAL IMAGE PROCESSING
Image Analysis Image Restoration.
- photometric aspects of image formation gray level images
Image Restoration - Focus on Noise
Basic Image Processing
Digital Image Processing Week IV
Image Filtering Readings: Ch 5: 5. 4, 5. 5, 5. 6, , 5
Presentation transcript:

Spatial Filtering Dr. Amnach Khawne

OUTLINE Type of noise Noise Model Neighborhood Processing Spatial domain operation or filtering – Linear filtering – Non-linear filtering – Adaptive filtering

Noise We may define noise to be any degradation in the image signal. Cleaning an image corrupted by noise is thus an important area of image restoration. We can consider a noisy image to be modelled as follows: where f(x, y) is the original image pixel, (x, y) is the noise term and g(x, y) is the resulting noisy pixel

Understanding Sources of Noise in Digital Images  Noise is the result of errors in the image acquisition process that result in pixel values that do not reflect the true intensities of the real scene. There are several ways that noise can be introduced into an image, depending on how the image is created. Source: http://www.mathworks.com/help/images/removing-noise-from-images.html

Understanding Sources of Noise in Digital Images (con’t) For example of introduced noise: If the image is scanned from a photograph made on film, the film grain is a source of noise. Noise can also be the result of damage to the film, or be introduced by the scanner itself. If the image is acquired directly in a digital format, the mechanism for gathering the data (such as a CCD detector) can introduce noise. Electronic transmission of image data can introduce noise.

Measure of the sensitivity of a (digital or film) imaging system The signal-to-noise ratio (SNR) is used in imaging as a physical measure of the sensitivity of a (digital or film) imaging system. Industry standards measure SNR in decibels (dB)  SNR = 10log10[var(image)/var(noise)] Source: http://en.wikipedia.org/wiki/Signal-to-noise_ratio_(imaging)

Noise Models There are many different models for the image noise term η(x, y): Gaussian Most common model Rayleigh Erlang Exponential Uniform Impulse Salt and pepper noise Images taken from Gonzalez & Woods, Digital Image Processing (2002) Gaussian Rayleigh Erlang Exponential Uniform Impulse Souce: Lawrence Rabiner

Impulse (Salt and pepper noise)

Impulse (Salt and pepper noise)

Types of noise Salt and pepper noise Gaussian noise Speckle noise Periodic noise Speckle noise Periodic noise

Noise Distributions in the Real World • Gaussian noise occurs in imaging sensors operating at low light levels • Salt-and-pepper noise arises in faulty switching devices • Rayleigh noise arises in range imaging • Exponential and Erlang noise occur in laser imaging Souce: Lawrence Rabiner

Gaussian noise Gaussian noise occurs in imaging sensors operating at low light levels z represents gray level,  is the mean of average value of z;  is its standard deviation

Gaussian noise Gaussian noise is an idealized form of white noise, which is caused by random fluctuations in the signal. We can observe white noise by watching a television which is slightly mistuned to a particular channel. Gaussian noise is white noise which is normally distributed. I = imread('eight.tif'); I1=imnoise(I,‘gaussian'); imshow(I1)

Reasons for Salt and Pepper Noise By memory cell failure. By malfunctioning of camera’s sensor cells. By synchronization errors in image digitizing or transmission. The PDF of (bipolar) impulse noise is given by

Impulse noise (Salt and pepper noise) The salt and pepper noise is generally caused by mulfunction of the camera’s sensor cells, by memory cell failure or by synchronization errors in the image digitizing or transmission and also called impulse noise, shot noise, or binary noise. This degradation can be caused by sharp, sudden disturbances in the image signal. Its appearance is randomly scattered white or black (or both) pixels over the image. I = imread('eight.tif'); I1=imnoise(I,'salt & pepper'); imshow(I1) The amount of noise added defaults to 10% The value is set between 0 and 1 indicating the fraction of pixels to be corrupted

Speckle noise I = imread('eight.tif'); I1=imnoise(I,'speckle'); Gaussian noise can be modeled by random values added to an image; speckle noise (or more simply just speckle) can be modeled by random values multiplied by pixel values, hence it is also called multiplicative noise. Speckle noise is a major problem in some radar applications I = imread('eight.tif'); I1=imnoise(I,'speckle'); imshow(I1)

Periodic noise If the image signal is subject to a periodic, rather than a random disturbance, we might obtain an image corrupted by periodic noise. The function imnoise does not have a periodic option >>I = imread('eight.tif'); >> s=size(I); >> [x,y]=meshgrid(1:s(1),1:s(2)); >> p=sin(x/3+y/5)+1; >>p1=p’; >> I1=(im2double(I)+p1/2)/2; >> imshow(I1)

MATLAB Noise Generation • A = rand(M, N) – generates M x N array of uniformly distributed numbers in interval (0, 1) • A = randn(M, N) – generates M x N array of Gaussian distributed numbers with zero mean and unit variance • g = imnoise(f, type, parameters) – adds M x N array of noise of various types (e.g., ‘gaussian’, ‘salt & pepper’, ‘speckle’, ‘poisson’) to an existing image, f • R = imnoise2(type, M, N, a, b) – generates M x N array of noise of types (‘uniform’,’gaussian’,’salt &pepper’,’lognormal’,’rayleigh’,’exponential’,’erlang’) – no scaling of noise array to (0, 1) interval – ‘salt & pepper’ noise has three values – 0 for pepper noise, 1 for salt noise, and 0,5 for no noise

Kernel Generation h = fspecial(type) h = fspecial(type, parameters) 'average' averaging filter 'gaussian' Gaussian lowpass filter H = fspecial('average',HSIZE) returns an averaging filter H of size. The default HSIZE is [3 3]. h = fspecial('gaussian', hsize, sigma) returns a rotationally symmetric Gaussian lowpass filter. The default value for hsize is [3 3]; the default value for sigma is 0.5.

Neighborhood Processing

Neighborhood Processing Neighborhood processing may be considered as an extension of point processing, where a function is applied to a neighborhood of each pixel. The idea is to move a mask: a rectangle (usually with sides of odd length) or other shape over the given image.

a filter The combination of mask and function is called a filter

neighborhood operation Local neighborhood and kernel (mask) The most common neighborhood operation is to multiply each of the pixels in the neighborhood by a weight and add them together The local weights are sometimes called a mask or kernel

spatial filtering is spatial convolution MASK

2D convolution ที่มา :http://www.songho.ca/dsp/convolution/convolution.html

Notation

Excercise A = rand(3); B = rand(4); C = conv2(A,B,'same') A convolution B

Annoying details What is the size of the output? MATLAB: conv2(f, g,shape) 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 full same valid g g g g f f g f g g g g g g g Source: S. Marschner

Notation

Applied filter on image Source; http://www.cs.uregina.ca/Links/class-info/425-nova/Lab3/

http://www.cs.uregina.ca/Links/class-info/425-nova/Lab3/

Edges of the image Ignore the edges. Pad with zeros. This means all pixels except for the edges, and results in an output image which is smaller than the original. If the mask is very large, a significant amount of information may be lost by this method. return an output image of the same size as the original, but may have the effect of introducing unwanted artifacts (for example, edges) around the image.

Image Noise Reduction Linear Non-linear Neighborhood operators Convolution Smoothing Filters called “Low-Pass” Filters blurring effect “pre-processing” removal of small details before object extraction noise reduction removal of noise in an image Non-linear Low-pass filter

Image Noise Reduction by Filter Filter refers to accepting (passing) or rejecting certain frequency components. Filter

    How do we clean up noise ? speckle noise Gaussian noise Salt and pepper noise Gaussian noise Salt and pepper noise, Gaussian noise and speckle noise can all be cleaned by using spatial filtering techniques. “Periodic noise, however, requires image transforms for best results”  Periodic noise

Filtering in MATLAB The filter2 function does the job of linear filterating for us; its use is filter2(filter,image,shape) 1 3 2

Linear filter

Cleaning Gaussian noise Average filtering To cleaning Gaussian noise is to simply take the average the mean of all the images. suppose we have 100 copies of our image, I, each with noise, iN(0,)

Average filtering Averaging tends to blur an image Average filter or Smoothing Filters or “Low-Pass” Filters Kernel original Using a 3x3 filter

Excercise >> I = imread('tire.tif'); >> ker = fspecial('average',3); >> Out = filter2(ker,I); >> figure;imshow(Out/255) >> ker = fspecial('average',9); >> ker = fspecial('average',15); original Using a 3x3 filter Using a 9x9 filter Using a 15x15 filter

Average filter Average filter 5x5

Use M(x,y) to compute values for mask. Gaussian Filter

Gaussian mask template generation function template=gaussian_template(winsize,sigma) centre=floor(winsize/2)+1; %we'll normalise by the total sum sum=0; template=[]; %so work out the coefficients and the running total for i=1:winsize for j=1:winsize template(j,i)=exp(-(((j-centre)*(j-centre))+((i-centre)* (i-centre)))/(2*sigma*sigma)); sum=sum+template(j,i); end %and then normalise template=template/sum; Source:Feature Extraction &Image Processing for Computer Vision , Authers: Mark S. Nixon and Alberto S. Aguado

Gaussian filter Gaussian filter 5x5 Kernel 5x5

Order Statistics Filters (Non-linear filter)

Cleaning salt and pepper noise Median filtering seems almost tailor-made for removal of impulse or salt and pepper noise

Cleaning salt and pepper noise Median filter Noisy image

Adaptive median filter ● Adaptive median filter changes size of Sxy (the size of the neighborhood) during operation. ● Notation Zmin = minimum gray level value in Sxy Zmax = maximum gray level value in Sxy Zmed = median of gray levels in Sxy Zxy = gray level at coordinates (x, y) Smax = maximum allowed size of Sxy Source : PENG Lei 

Adaptive median filter (algorithm) Level A: A1 = Zmed - Zmin           A2 = Zmed - Zmax           if A1 > 0 AND A2 < 0, go to level B else increase the window size if window size < Smax, repeat level A else output Zxy Level B: B1 = Zxy - Zmin B2 = Zxy - Zmax if B1 > 0 AND B2 < 0, output Zxy else output Zmed Source : PENG Lei 

Level A: IF Zmin < Zmed < Zmax, then • Zmed is not an impulse Explanation        Level A: IF Zmin < Zmed < Zmax, then                • Zmed is not an impulse                (1) go to level B to test if Zxy is an impulse ...                ELSE                • Zmed is an impulse                (1) the size of the window is increased and                (2) level A is repeated until ...                   (a) Zmed is not an impulse and go to level B or                   (b) Smax reached: output is Zxy Level B: IF Zmin < Zxy < Zmax, then                • Zxy is not an impulse                (1) output is Zxy (distortion reduced)                • either Zxy = Zmin or Zxy = Zmax                (2) output is Zmed (standard median filter)                • Zmed is not an impulse (from level A) Source : PENG Lei 

Adaptive Median Filter I = imread('eight.tif'); g = imnoise(I, 'salt%pepper',0.25); J = imnoise(I,'salt & pepper', 0.25); K = medfilt2(J,[7 7],'symmetric'); imshow(J) figure; imshow(K) L = adpmedian(J, 7); figure; imshow(L) Median filter I+noise Adaptive median filter