image processing chapter 5

33
Image Image Processing Processing Image Restoration 06/09/22 1

Upload: saeavana

Post on 10-Apr-2015

992 views

Category:

Documents


8 download

TRANSCRIPT

Page 1: Image Processing Chapter 5

Image Image ProcessingProcessing

Image Restoration

04/11/23

1

Page 2: Image Processing Chapter 5

Contents

Speckle noise.

Gaussian noise.

Salt & pepper noise.

Cleaning Gaussian noise

Image Restoration

04/11/23

2

Periodic noise.

Cleaning salt and pepper noise

Cleaning Periodic noise

Page 3: Image Processing Chapter 5

Image Restoration

Image restoration concerns the removal or reduction of degradations which have occurred during the acquisition of the image

Such degradations may include noise, which are errors in the pixel values, or optical effects such as out of focus blurring, or blurring due to camera motion.

04/11/23

3

Page 4: Image Processing Chapter 5

Image Restoration cont.

Assume we have an image of f(x,y) and a spatial

filter h(x,y) if h(x,y) consists of a single line of ones,

the result of the convolution will be a motion blur in

the direction of the line. Thus we may write

g(x,y) =f(x,y)*h(x,Y)

We may use additive function to generate noise

g(x,y) =f(x,y)*h(x,y)+n(x,y)

If we know h,n we may acquire the original image

f(x,y)= (g(x,y)-n(x,y))/h(x,y)

Page 5: Image Processing Chapter 5

Noise

We may define noise to be any degradation in the

image signal, caused by external disturbance. If an

image is being sent electronically from one place to

another, via satellite or wireless transmission, or

through networked cable, we may expect errors to

occur in the image signal

Cleaning an image corrupted by noise is thus an

important area of image restoration.

Page 6: Image Processing Chapter 5

Salt and Pepper noise

Its appearance is randomly scattered white or

black pixles over the image

tw=imread('twins.tif');

t=rgb2gray(tw);

To add noise, we use the Matlab function imnoise which takes a

number of different parameters.

To add salt and pepper noise

t_sp=imnoise(t,'salt & pepper'); or

imnoise(t,'salt & pepper',0.2);

would produce an image with 20% of its pixels corrupted by salt

and pepper noise

Page 7: Image Processing Chapter 5

Salt and Pepper noise-Cont

Original image With added salt & pepper noise

Page 8: Image Processing Chapter 5

Gaussian noise-Cont.

Gaussian noise is an idealized form of white noise . We can observe white noise by watching a television which is slightly mistuned to a particular channel.

If the image is represented as I. and the Gaussian noise by

N , then we can model a noisy image by simply adding the two: I+N

t_spk=imnoise(t, ‘Gaussian ');

Page 9: Image Processing Chapter 5

Speckle noise

Whereas Gaussian noise can be modeled by random values added to an image . speckle noise can be modeled by random values multiplied by pixel values hence it is also called multiplicative noise.

t_spk=imnoise(t,'speckle');

peckle noise is implemented as

I(1+N)

Page 10: Image Processing Chapter 5

Speckle noise-Cont.

Gaussian noise Speckle noise

Page 11: Image Processing Chapter 5

Periodic noise

The function imnoise does not have a periodic option,

but it is quite easy to create our own, by adding a

periodic matrix

>> s=size(t);

>> [x,y]=meshgrid(1:s(1),1:s(2));

>> p=sin(x/3+y/5)+1;

>> t_pn=(im2double(t)+p/2)/2;

Page 12: Image Processing Chapter 5

Periodic noise-Cont.

Periodic noise

Page 13: Image Processing Chapter 5

Cleaning salt and pepper noise

Low pass filter So we might try filtering with an average filter: a3=fspecial('average'); t_sp_a3=filter2(a3,t_sp);

Page 14: Image Processing Chapter 5

Median filtering

Median filtering seems almost tailor-made for

removal of salt and pepper noise.

The median of a set is the middle value when they

are sorted

Thus the median will in general replace a noisy value

with one closer to its surroundings

A median filter is an example of a non-linear

spatial filter

Page 15: Image Processing Chapter 5

Median filtering-Cont.

In Matlab, median filtering is implemented by the medfilt2 function

t_sp_m3=medfilt2(t_sp) ;

Median filtering

Page 16: Image Processing Chapter 5

Rank-order filtering

Median filtering is a special case of a more general process called rank-order filtering Rather than take the median of a set, we order the set and take the n_th th value, for some predetermined value of n

ordfilt2(t_sp,3,[0 1 0;1 1 1;0 1 0]);

Page 17: Image Processing Chapter 5

Rank-order filtering-Cont.

Applying the median filter can in general be a slow operation: each pixel requires the sorting of at least nine values .The use of cleaning salt and

pepper noise by treating noisy pixels known as outliers.

This leads to the following approach for noise cleaning.

1. Choose a threshold value D2. For a given pixel, compare its value P with the

mean M of the values of its eight neighbors3. If(P-M)>D then classify the pixel as noisy,

otherwise not4. If the pixel is noisy, replace its value with M

otherwise leave its value unchanged.

Page 18: Image Processing Chapter 5

Rank-order filtering-Cont.

Page 19: Image Processing Chapter 5

Rank-order filtering-Cont.

D=.2 D=.4

Page 20: Image Processing Chapter 5

Cleaning Gaussian noise

It may sometimes happen that instead of just one image corrupted with Gaussian noise, we have many different copies of it. An example is satellite imaging; if a satellite passes over the same spot many times, we will obtain many different images of the same place Simple approach to cleaning Gaussian noise is to simply take the average of all the images .To see why this works, suppose we have 100 copies of our image, each with noise then the Ith noisy image will be:M+NIM is the matrix of original values and NI a matrix of normally distributed random values with mean 0

We can define the mean M´ of these images by the usual add and divide method

Page 21: Image Processing Chapter 5

Cleaning Gaussian noise-Cont.

Page 22: Image Processing Chapter 5

Removal of periodic noise

Periodic noise may occur if the imaging equipment is subject to electronic disturbance of a repeating nature.

We can easily create periodic noise by overlaying an image with a trigonometric function:

Page 23: Image Processing Chapter 5

>> [x,y]=meshgrid(1:256,1:256);>> p=1+sin(x+y/1.5);>> cm = imread('cameraman.tif');>> tp=(double(cm)/128+p)/4;>> imshow(tp)>>fcm = fftshift(fft(tp));>>figure,imshow(fcm)

Where cm is cameraman image.

Removal of periodic noise-Cont

Page 24: Image Processing Chapter 5

The second line simply creates a sine function, and adjusts its output to be in the range 0-2.

The third line first adjusts the cameraman image to be in the same range; adds the sine function to it, and divides by 4 to produce a matrix of type double with all elements in the range 0.0 – 1.0.

Removal of periodic noise-Cont

Page 25: Image Processing Chapter 5

This can be viewed directly with imshow, and it is shown in gure 6.1(a). We can produce its shifted DFT and this is shown in gure 6.1(b). The extra two spikes away from the centre correspond to the noise just added.

The extra two spikes away from the centre correspond to the noise just added.

Removal of periodic noise-Cont

Page 26: Image Processing Chapter 5

Removal of periodic noise-Cont

Page 27: Image Processing Chapter 5

There are two methods we can use to eliminate the spikes :

1. Band reject filtering.

2. Notch filtering.

Removal of periodic noise-Cont

Page 28: Image Processing Chapter 5

Band reject filteringWe create a filter consisting of ones with a ring

of zeroes; the zeroes lying at a radius of 49 from the centre:>> z=sqrt((x-129).^2+(y-129).^2);>> br=(z < 47 | z > 51);

where z is the matrix consisting of distances from the origin. This particular ring will have a thickness large enough to cover the spikes. Then as before, we multiply this by the transform:>> tbr=fcm.*br;>> figure,imshow(tbr,[])

Removal of periodic noise-Cont

Page 29: Image Processing Chapter 5

and this is shown in figure 6.2(a).The result is that the spikes have

been blocked out by this filter.Taking the inverse transform

produces the image shown in gure 6.2(b).

Note that not all the noise has gone, but a significant amount has, especially in the centre of the image.

Removal of periodic noise-Cont

Page 30: Image Processing Chapter 5

Removal of periodic noise-Cont

Page 31: Image Processing Chapter 5

Notch filteringWith a notch Filter, we simply make

the rows and columns of the spikes zero:

>> tf(156,:)=0;>> tf(102,:)=0;>> tf(:,170)=0;>> tf(:,88)=0;

and the result is shown in gure 6.3(a).The image after inversion is shown in

gure 6.3(b).

Removal of periodic noise-Cont

Page 32: Image Processing Chapter 5

Removal of periodic noise-Cont

Page 33: Image Processing Chapter 5

LOGOAny questions