90
P. Nirmala devi AP(SLG)/ECE KEC

Wavelet Applications in Image Denoising Using MATLAB

Embed Size (px)

Citation preview

Page 1: Wavelet Applications in Image Denoising Using MATLAB

P. Nirmala devi AP(SLG)/ECE

KEC

Page 2: Wavelet Applications in Image Denoising Using MATLAB

Digital Image Processing is the use of computer algorithms to perform image processing on digital images.

Advantages over analog image processing: - Allows a much wider range of algorithms to be applied to the input data - Avoid problems such as the build-up of noise and signal distortion during processing.

05/02/23KEC/EIE/DIP

Page 3: Wavelet Applications in Image Denoising Using MATLAB

Two principal application areas:

◦ Improvement of pictorial information for human

interpretation

◦ Processing of image data for storage, transmission and representation for autonomous machine perception

05/02/23KEC/EIE/DIP

Page 4: Wavelet Applications in Image Denoising Using MATLAB

◦An digital image may be defined as a

two-dimensional quantity f(x,y) x and y are spatial coordinates and f is intensity or gray level at that

point

05/02/23KEC/EIE/DIP

Page 5: Wavelet Applications in Image Denoising Using MATLAB

Low-level IP Image preprocessing to reduce noise, contrast

enhancement, image sharpening Both inputs and outputs are images

Mid-level IP Segmentation and description The inputs are generally images, but outputs are attributes extracted from those images

(e.g., edges,contours… )High-level IP

Making sense of an ensemble of recognized objects

05/02/23KEC/EIE/DIP

Page 6: Wavelet Applications in Image Denoising Using MATLAB

Goal:◦ To Remove noise◦ To Preserve useful information

Applications:◦ Medical signal/image analysis (ECG, CT, MRI etc.)◦ Data mining ◦ Radio astronomy image analysis

05/02/23KEC/EIE/DIP

Page 7: Wavelet Applications in Image Denoising Using MATLAB

Visually unpleasantBad for compressionBad for analysis

05/02/23KEC/EIE/DIP

Page 8: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

Page 9: Wavelet Applications in Image Denoising Using MATLAB

Images are often contaminated by noise during

i) acquisition ii) storage iii)transmission

Effect: Degradation at the quality of the images

05/02/23KEC/EIE/DIP

Page 10: Wavelet Applications in Image Denoising Using MATLAB

The sources of noise in digital images arise during image acquisition (digitization) and transmission

◦ Imaging sensors can be affected by ambient conditions

◦ Interference can be added to an image during transmission

05/02/23KEC/EIE/DIP

Page 11: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

thermal imaging electrical interference

ultrasound imagingphysical interference

Page 12: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

Simplified assumptions Noise is independent of signal

Noise types Independent of spatial location

Impulse noise Additive white Gaussian noise

Spatially dependent Periodic noise

Page 13: Wavelet Applications in Image Denoising Using MATLAB

Definition: is considered to be any measurement that is not part of the phenomena of interest.

Images are affected by different types of noise:

Gaussian noise

Salt and Pepper noise

Poisson Noise

Speckle Noise

05/02/23KEC/EIE/DIP

Page 14: Wavelet Applications in Image Denoising Using MATLAB

Impulse noise Characterized by some portion of image pixels that are corrupted, leaving the remaining pixels unchanged. (Salt & Pepper Noise) Additive noise A value from a certain distribution is added to each image pixel, for example, a Gaussian distribution. Multiplicative noise The intensity of the noise varies with the signal intensity (e.g., speckle noise).

05/02/23KEC/EIE/DIP

Page 15: Wavelet Applications in Image Denoising Using MATLAB

WjHi

jiXjiY

1,1

),(0

255),(

Definition

Each pixel in an image has the probability of p/2 (0<p<1) being contaminated by either a white dot (salt) or a black dot (pepper)

with probability of p/2

with probability of p/2

with probability of 1-p

noisy pixels

clean pixels

X: noise-free image, Y: noisy image

05/02/23KEC/EIE/DIP

Page 16: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128

128 128 255 0 128 128 128 128 128 128 128 128 128 128 0 128 128 128 128 0 128 128 128 128 128 128 128 128 128 128 128 128 0 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 0 128 128 128 128 255 128 128 128 128 128 128 128 128 128 128 128 128 128 255 128 128 128 128 128 128 128 255 128 128

Page 17: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

Noisy image Y

filteringalgorithm

Can we make the denoised image X as closeto the noise-free image X as possible?

^denoisedimage

Page 18: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

225 225 225 226 226 226 226 226 225 225 255 226 226 226 225 226 226 226 225 226 0 226 226 255 255 226 225 0 226 226 226 226 225 255 0 225 226 226 226 255 255 225 224 226 226 0 225 226 226 225 225 226 255 226 226 228 226 226 225 226 226 226 226 226

0 225 225 226 226 226 226 226 225 225 226 226 226 226 226 226 225 226 226 226 226 226 226 226 226 226 225 225 226 226 226 226 225 225 225 225 226 226 226 226 225 225 225 226 226 226 226 226 225 225 225 226 226 226 226 226 226 226 226 226 226 226 226 226

Sorted: [0, 0, 0, 225, 225, 225, 226, 226, 226]

Page 19: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

Noisy image Y denoisedimage

3-by-3 window

Page 20: Wavelet Applications in Image Denoising Using MATLAB

WjHiNjiN

jiNjiXjiY

1,1),,0(~),(

),,(),(),(2

DefinitionEach pixel in an image is disturbed by a Gaussian random variableWith zero mean and variance 2

X: noise-free image, Y: noisy image

05/02/23KEC/EIE/DIP

Page 21: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

Numerical Example 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128

128 128 129 127 129 126 126 128 126 128 128 129 129 128 128 127 128 128 128 129 129 127 127 128 128 129 127 126 129 129 129 128 127 127 128 127 129 127 129 128 129 130 127 129 127 129 130 128 129 128 129 128 128 128 129 129 128 128 130 129 128 127 127 126

Page 22: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

A different type of noise in the coherent imaging of objects caused by errors in data transmission

Speckle noise follows a gamma distribution

Presence of speckle is undesirable damages radiometric resolution affects the tasks of human interpretation and scene

analysis.

Page 23: Wavelet Applications in Image Denoising Using MATLAB

KEC/EIE/DIP

Image Denoising Techniques

Spatial Domain Denoising• Conventional AND Adaptive filtering

•Frequency Domain Denoising• Wiener Filtering

•Wavelet Domain Denoising • Wavelet thresholding: Hard vs. Soft • Wavelet-domain shrinking

05/02/23

Page 24: Wavelet Applications in Image Denoising Using MATLAB

Spatial filters are designed to highlight or suppress specific features in an image, based on their spatial frequency.

Linear Filters - Mean Filters

Non Linear Filters - Median Filters

05/02/23KEC/EIE/DIP

Page 25: Wavelet Applications in Image Denoising Using MATLAB

A common filtering involves moving a 'window' of a few pixels in dimension (e.g. 3x3, 5x5, etc.) over each pixel in the image, applying a mathematical calculation using the pixel values under that window, and replacing the central pixel with the new value.

05/02/23KEC/EIE/DIP

Page 26: Wavelet Applications in Image Denoising Using MATLAB

Image of CHURN FarmDaedalus 1268 ATM

05/02/23KEC/EIE/DIP

Page 27: Wavelet Applications in Image Denoising Using MATLAB

A low-pass filter is designed to emphasise larger, homogeneous areas of similar tone and reduce the smaller detail in an image. Thus, low-pass filters generally serve to smooth the appearance of an image.

05/02/23KEC/EIE/DIP

Page 28: Wavelet Applications in Image Denoising Using MATLAB

A high-pass filter does the opposite, and serves to sharpen the appearance of fine detail in an image.

05/02/23KEC/EIE/DIP

Page 29: Wavelet Applications in Image Denoising Using MATLAB
Page 30: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

Page 31: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

Page 32: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

Page 33: Wavelet Applications in Image Denoising Using MATLAB

Wide windows do not provide good localization at high frequencies.

05/02/23KEC/EIE/DIP

Page 34: Wavelet Applications in Image Denoising Using MATLAB

Use narrower windows at high frequencies.

05/02/23KEC/EIE/DIP

Page 35: Wavelet Applications in Image Denoising Using MATLAB

Narrow windows do not provide good localization at low frequencies.

05/02/23KEC/EIE/DIP

Page 36: Wavelet Applications in Image Denoising Using MATLAB

Use wider windows at low frequencies.

05/02/23KEC/EIE/DIP

Page 37: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

Page 38: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

Page 39: Wavelet Applications in Image Denoising Using MATLAB

Overcomes the preset resolution problem of the STFT by using a variable length window:

◦ Use narrower windows at high frequencies for better time resolution.

◦ Use wider windows at low frequencies for better frequency resolution.

05/02/23KEC/EIE/DIP

Page 40: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

Page 41: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

Page 42: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

Page 43: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

Page 44: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

Page 45: Wavelet Applications in Image Denoising Using MATLAB

There are many different wavelets:

MorletHaar Daubechies

05/02/23KEC/EIE/DIP

Page 46: Wavelet Applications in Image Denoising Using MATLAB

Sparsity: for functions typically found in practice, many of the coefficients in a wavelet representation are either zero or very small.

Linear-time complexity: many wavelet transformations can be accomplished in O(N) time.

05/02/23KEC/EIE/DIP

Page 47: Wavelet Applications in Image Denoising Using MATLAB

• Adaptability: wavelets can be adapted to represent a wide variety of functions (e.g., functions with discontinuities, functions defined on bounded domains etc.).– Well suited to problems involving images, open

or closed curves, and surfaces of just about any variety.

– Can represent functions with discontinuities or corners more efficiently (i.e., some have sharp corners themselves).

05/02/23KEC/EIE/DIP

Page 48: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

Properties of Wavelets (cont’d)

•Multiresolution analysis :

•Multiresolution analysis: representation of a signal (e.g., an images) in more than one resolution/scale.

•Features that might go undetected at one resolution may be easy to spot in another.

Page 49: Wavelet Applications in Image Denoising Using MATLAB

• Noise filtering

• Image compression– Fingerprint compression

• Image fusion

• Recognition

• Image Matching and Retrieval

05/02/23KEC/EIE/DIP

Page 50: Wavelet Applications in Image Denoising Using MATLAB

One Stage Filtering gives Approximations and details:

• The low-frequency content is the mostimportant part in many applications, andgives the signal its identity.This part is called “Approximations”

• The high-frequency gives the ‘flavor’, andis called “Details”

05/02/23KEC/EIE/DIP

Page 51: Wavelet Applications in Image Denoising Using MATLAB

Perceptually flat regions should be flat

Image boundaries should be preserved (neither blurred or sharpened)

Texture details should not be lost

Global contrast should be preserved

No artifacts should be generated

05/02/23KEC/EIE/DIP

Page 52: Wavelet Applications in Image Denoising Using MATLAB

Different sources and type of noises

How strong is the noise?

Locally, it is hard to distinguish◦ Texture vs. noise◦ Object boundary vs. structural noise

05/02/23KEC/EIE/DIP

Page 53: Wavelet Applications in Image Denoising Using MATLAB

We need to distinguish spatially-localized events (edges) from noise components

Wavelet denoising attempts to remove the noise present in the signal while preserving the signal characteristics, regardless of its frequency content.

What are essential features of the data, and what features are “noise”?

To know more about noise components

05/02/23KEC/EIE/DIP

Page 54: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

ForwardTransform

InverseTransform

Denoisingoperation

e.g.,KLTDCTWT

e.g.,Linear Wiener filteringNonlinear Thresholding

Noisysignal

denoisedsignal

Page 55: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

Page 56: Wavelet Applications in Image Denoising Using MATLAB

DWT of the image is calculated

Resultant coefficients are passed through threshold testing

The coefficients < threshold are removed, others shrinked

Resultant coefficients are used for image reconstruction with IWT.

05/02/23KEC/EIE/DIP

Page 57: Wavelet Applications in Image Denoising Using MATLAB

Methods Used

◦Universal Thresholding◦Visu Shrink◦Sure Shrink◦Bayes Shrink

05/02/23KEC/EIE/DIP

Page 58: Wavelet Applications in Image Denoising Using MATLAB

Wavelet thresholding (first proposed by Donoho) is a signal estimation technique that exploits the capabilities of wavelet transform for signal denoising.

It removes noise by killing coefficients that are insignificant relative to some threshold.

Types◦ Universal or Global Thresholding

Hard Soft

◦ SubBand Adaptive Thresholding

05/02/23KEC/EIE/DIP

Page 59: Wavelet Applications in Image Denoising Using MATLAB

TnYTnYTnYTnYTnY

nX|][|0

][][][][

][~

KEC/EIE/DIP

otherwise

TnYifnYnX

0|][|][

][~

DWT IWTThresholdingY X~

Soft thresholding

Hard thresholding

Noisysignal

denoisedsignal

05/02/23

Page 60: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

The hard thresholding operator is defined as

D(U, λ) = U for all |U|> λ

Hard threshold is a “keep or kill” procedure and is more intuitively appealing.

The transfer function of the same is shown here.

The soft thresholding operator is defined as

D(U, λ) = sgn(U)max(0, |U| - λ)

Soft thresholding shrinks coefficients above the threshold in absolute value.

The transfer function of the same is shown here.

Page 61: Wavelet Applications in Image Denoising Using MATLAB

The threshold

(N being the signal length, σ being the noise variance) is well known in wavelet literature as the Universal threshold.

NUNIV ln2

05/02/23KEC/EIE/DIP

Page 62: Wavelet Applications in Image Denoising Using MATLAB

Apply Donoho’s universal threshold,

M is the number of pixels. The threshold is usually high, overly

smoothing.

Mlog2

05/02/23KEC/EIE/DIP

Page 63: Wavelet Applications in Image Denoising Using MATLAB

Subband adaptive, a different threshold is calculated for each detail subband.

Choose the threshold that will minimize the unbiased estimate of the risk:

This optimization is straightforward, order the wavelet coefficients in terms of magnitude and choose the threshold as the wavelet coefficient that minimizes the risk.

05/02/23KEC/EIE/DIP

Page 64: Wavelet Applications in Image Denoising Using MATLAB

Adaptive data-driven thresholding method

Assume that the wavelet coefficients in each subband is distributed as a Generalized Gaussian Distribution (GGD)

Find the threshold that minimized the Bayesian risk.

05/02/23KEC/EIE/DIP

Page 65: Wavelet Applications in Image Denoising Using MATLAB

WAVELET TOOLBOX

05/02/23KEC/EIE/DIP

Page 66: Wavelet Applications in Image Denoising Using MATLAB

Function Name Purpose

dwt2 - Single-level decomposition

[cA, cH,cV,cD] = dwt2(X, 'wname')

Wavedec2 - Multilevel 2-D wavelet decomposition

[C,S] = wavedec2(X, N, 'wname')

05/02/23KEC/EIE/DIP

Page 67: Wavelet Applications in Image Denoising Using MATLAB

[cA1,cH1,cV1,cD1] = dwt2(X,'bior3.7');

This generates the coefficient matrices of the level-one approximation (cA1)

and horizontal, vertical and diagonal details (cH1,cV1,cD1, respectively).

05/02/23KEC/EIE/DIP

Page 68: Wavelet Applications in Image Denoising Using MATLAB

Type: [C,S] = wavedec2(X,2,'bior3.7'); where X is the original image matrix, and 2 is the

level of decomposition. The coefficients of all the components of a

second-level decomposition (that is, the second-level approximation and the first two levels of detail) are returned concatenated into one vector, C. Argument S is a bookkeeping matrix that keeps track of the sizes of each component.

05/02/23KEC/EIE/DIP

Page 69: Wavelet Applications in Image Denoising Using MATLAB

Function Name Purpose

detcoef2 - Extraction of detail coefficients

D = detcoef2(C, S, 'wname', N)[H,V,D] = detcoef2('all', C,S,N)

appcoef2 - Extraction of approximation coefficients

A = appcoef2(C,S,’wname’,N)

05/02/23KEC/EIE/DIP

Page 70: Wavelet Applications in Image Denoising Using MATLAB

To extract the level 2 approximation coefficients from C:

cA2 = appcoef2(C,S,'bior3.7',2);

05/02/23KEC/EIE/DIP

Page 71: Wavelet Applications in Image Denoising Using MATLAB

cH2 = detcoef2('h',C,S,2); cV2 = detcoef2('v',C,S,2); cD2 = detcoef2('d',C,S,2); cH1 = detcoef2('h',C,S,1); cV1 = detcoef2('v',C,S,1); cD1 = detcoef2('d',C,S,1);

[or]

05/02/23KEC/EIE/DIP

Page 72: Wavelet Applications in Image Denoising Using MATLAB

[cH2,cV2,cD2] = detcoef2('all',C,S,2); [cH1,cV1,cD1] = detcoef2('all',C,S,1); where the first argument ('h', 'v', or 'd')

determines the type of detail (horizontal, vertical, diagonal) extracted,

and the last argument determines the level.

05/02/23KEC/EIE/DIP

Page 73: Wavelet Applications in Image Denoising Using MATLAB

Function Name Purpose

ddencmp - Provide default values for denoising and compression[THR,SORH,KEEPAPP,CRIT] = ddencmp(IN1,IN2,X)

wdencmp - Wavelet de-noising and compression

[XC,CXC,LXC,PERF0,PERFL2] = wdencmp('gbl',X,'wname',N,THR,SORH,KEEPAPP)

05/02/23KEC/EIE/DIP

Page 74: Wavelet Applications in Image Denoising Using MATLAB

Function Name Purpose wthcoef2 Wavelet

coefficient thresholding 2-D

NC = wthcoef2('type',C, S, N, T, SORH)

05/02/23KEC/EIE/DIP

Page 75: Wavelet Applications in Image Denoising Using MATLAB

Function Name Purpose

idwt2 - Single-level reconstruction

X = idwt2(cA, cH, cV,cD, 'wname') waverec2 - Full reconstruction

X = waverec2(C,S, 'wname') wrcoef2 - Selective reconstruction

X = wrcoef2('type',C,S,'wname',N)

05/02/23KEC/EIE/DIP

Page 76: Wavelet Applications in Image Denoising Using MATLAB

To find the inverse transform: Xsyn = idwt2(cA1,cH1,cV1,cD1,'bior3.7');

This reconstructs or synthesizes the original image from the coefficients of the level 1 approximation and details.

05/02/23KEC/EIE/DIP

Page 77: Wavelet Applications in Image Denoising Using MATLAB

To reconstruct the level 2 approximation from C:

A2 = wrcoef2('a',C,S,'bior3.7',2);

05/02/23KEC/EIE/DIP

Page 78: Wavelet Applications in Image Denoising Using MATLAB

To reconstruct the level 1 and 2 details from C, type:

H1 = wrcoef2('h',C,S,'bior3.7',1); V1 = wrcoef2('v',C,S,'bior3.7',1); D1 = wrcoef2('d',C,S,'bior3.7',1); H2 = wrcoef2('h',C,S,'bior3.7',2); V2 = wrcoef2('v',C,S,'bior3.7',2); D2 = wrcoef2('d',C,S,'bior3.7',2);

05/02/23KEC/EIE/DIP

Page 79: Wavelet Applications in Image Denoising Using MATLAB

To reconstruct the original image from the wavelet decomposition structure:

X0 = waverec2(C,S,'bior3.7');

This reconstructs or synthesizes the original image from the coefficients C of the multilevel decomposition.

05/02/23KEC/EIE/DIP

Page 80: Wavelet Applications in Image Denoising Using MATLAB

GUI FOR WAVELET ANALYSIS

05/02/23KEC/EIE/DIP

Page 81: Wavelet Applications in Image Denoising Using MATLAB

Starting the 2-D Wavelet Analysis Tool.

From the MATLAB prompt, type: wavemenu

The Wavelet Tool Main Menu appears

05/02/23KEC/EIE/DIP

Page 82: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

Page 83: Wavelet Applications in Image Denoising Using MATLAB

Click the Wavelet 2-D menu item. From the File menu, choose the Load Image option. Load the required Image ANALYZING AN IMAGE Using the Wavelet and Level menus located to

the upper right, determine the wavelet family, the wavelet type, and the number of levels to be used for the analysis.

Click the Analyze button. Click on any decomposition component in the lower

right window.

05/02/23KEC/EIE/DIP

Page 84: Wavelet Applications in Image Denoising Using MATLAB

Click the Visualize button.

Using Tree Mode Features.

Choose Tree from the View Mode menu.

05/02/23KEC/EIE/DIP

Page 85: Wavelet Applications in Image Denoising Using MATLAB

Saving Information to Disk

05/02/23KEC/EIE/DIP

Page 86: Wavelet Applications in Image Denoising Using MATLAB

05/02/23KEC/EIE/DIP

Page 87: Wavelet Applications in Image Denoising Using MATLAB

From the Select thresholding method menu, choose any item.

Set the thresholding mode.

Use the Sparsity slider to adjust the threshold value

Click the De-noise button.

05/02/23KEC/EIE/DIP

Page 88: Wavelet Applications in Image Denoising Using MATLAB

◦Determination of a global optimal threshold

◦Spatially adjusting threshold based on local statistics

Challenges with wavelet thresholding

05/02/23KEC/EIE/DIP

Page 89: Wavelet Applications in Image Denoising Using MATLAB

It’s possible to remove the noise with little loss of details.

The idea of wavelet denoising based on the assumption that the amplitude, rather than the location, of the spectra of the signal to be as different as possible for that of noise.

05/02/23KEC/EIE/DIP

Page 90: Wavelet Applications in Image Denoising Using MATLAB

THANK YOU

05/02/23KEC/EIE/DIP