Image and Multidimensional Signal Processing Colorado School of Mines

advertisement

Colorado School of Mines

Image and Multidimensional Signal

Processing

Professor William Hoff

Dept of Electrical Engineering &Computer Science

Colorado School of Mines

Image Restoration

Colorado School of Mines Image and Multidimensional Signal Processing

Image Restoration

• Goal is to restore or reconstruct the original image that has been degraded

• We have some a priori knowledge of the degradation process

• Unlike image enhancement, image restoration is largely an objective process ( e.g.

, we optimize a goodness criterion), rather than a subjective process

• We model the degradation by a process H , then add random noise

Colorado School of Mines g ( x , y )

 h ( x , y )

 f ( x , y )

 

( x , y )

G ( u , v )

H ( u , v ) F ( u , v )

N ( u , v )

Image and Multidimensional Signal Processing

3

Noise Models

• Characterized by their probability density function

(pdf)

– Gaussian (most common)

– Rayleigh (non negative)

• models noise in radar range and velocity images

– Erlang or gamma, exponential

(non negative)

• models noise in laser images

– Uniform

• models quantization noise

– Salt and pepper (impulse)

• models malfunctioning pixels or timing errors

Colorado School of Mines Image and Multidimensional Signal Processing

4

Estimation of Noise Parameters

• Often you can estimate parameters from our knowledge of the sensor characteristics

• Otherwise, you can take images of a “flat” surface and look at the histogram

Colorado School of Mines Image and Multidimensional Signal Processing

5

Noisy Images

Colorado School of Mines Image and Multidimensional Signal Processing

6

Noisy Images

Colorado School of Mines

See Matlab’s “imnoise” function

Image and Multidimensional Signal Processing

7

Noise-Only Degradation

• First consider just additive noise g ( x , y )

 f ( x , y )

 

( x , y )

• The noise is unknown, so subtracting it from g(x,y) is not a realistic option

• In fact, enhancement and restoration are basically the same in this particular case

Original image

Colorado School of Mines Image and Multidimensional Signal Processing

8

Mean Filters

• Arithmetic mean

– the standard “box” filter f

ˆ

( x , y )

1 mn

( s , t

)

S g xy

( s , t )

• Geometric mean

– tends to lose less image detail

ˆ f ( x , y )

( s , t )

S xy g ( s , t

1

)

 mn

Colorado School of Mines Image and Multidimensional Signal Processing

Compare results of filtering

10 10 10

10 10 10

10 10 1

9

Colorado School of Mines Image and Multidimensional Signal Processing

10

Order-Statistics Filters

• Rank (order) the values within window

• Median filter

– choose the middle value

– unaffected by a large fraction of

“outliers” (up to 50%!)

• Alpha-trimmed mean filter

– delete the d/2 lowest and d/2 highest values

– average the remaining values

– similar to mean filter, but unaffected by “outliers” image region image region sorted values low high median sorted values lowest d/2 values average highest d/2 values

11

Colorado School of Mines Image and Multidimensional Signal Processing

Colorado School of Mines Image and Multidimensional Signal Processing

12

Colorado School of Mines Image and Multidimensional Signal Processing

13

Adaptive Mean Filter

• Don’t blur image near boundaries

• How do you know if you are near a boundary?

– The local variance, s

L

2 , is large compared to the estimated noise variance, s

2 f

ˆ

( x , y )

 g ( x , y )

 s

2 s

2

L

 g ( x , y )

 m

L

• Inside a region (away from boundaries): s

2

L

 s

2

, so f

ˆ

( x , y )

 m

L

(i.e., the local mean)

• Near boundaries s

L

2  s

2

, so f

ˆ

( x , y )

 g ( x , y )

See Matlab’s wiener2

14

Colorado School of Mines Image and Multidimensional Signal Processing

Colorado School of Mines Image and Multidimensional Signal Processing

15

Closeup of (b) and (d)

Colorado School of Mines Image and Multidimensional Signal Processing

16

Anisotropic Diffusion

• An iterative algorithm to smooth regions while preserving, and enhancing, the contrast at sharp intensity gradients

• Not in our book, but may be helpful for some applications

• Diffusion (heat) equation:

I

 t

  2

( , , ), where D is a constant from http://en.wikipedia.org/wiki/Heat_equation

Colorado School of Mines Image and Multidimensional Signal Processing

Problem – don’t want to diffuse across image boundaries. Can detect boundary by magnitude of gradient

17

General Anisotropic Diffusion

• Let D(x,y) vary with position (“conduction coefficient”)

I t

  

D ( x ,

• Ideally, D =0 at boundaries y

I

 t

0

)

I ( x , y , t )

I.e., no change to the image

• Ideally, D =1 inside boundaries

I

 t

  2

I ( x , y , t )

I.e., the diffusion equation

• Let

D ( x , y )

 g where g is a monotonically decreasing function

Perona and Malik,

“Scale Space and Edge

Detection Using

Anisotropic Diffusion”,

IEEE Trans Pattern Anal.

& Mach. Intell., July

1990, pp 629-639.

18

Colorado School of Mines Image and Multidimensional Signal Processing

Examples

from http://rsb.info.nih.gov/ij/plugins/anisotropic-diffusion-2d.html

Colorado School of Mines Image and Multidimensional Signal Processing

19

Matlab

• Function anisodiff http://www.csse.uwa.edu.au/~pk/research/matlabfns/

• Try

I = imread('ckt-board.tif');

I2 = imnoise(I, 'gaussian', 0, 0.02);

Iresult = anisodiff(I2, 30, 30, 0.25, 1);

Iteration 30

% Arguments:

% im - input image

% niter - # of iterations.

% kappa - conduction coeff 20-100 ?

% lambda - max of .25 for stability

% option –

% 1 Perona Malik diffusion eqn No 1

% 2 Perona Malik diffusion eqn No 2

Iteration 1

Colorado School of Mines Image and Multidimensional Signal Processing

20

Restoring Spatial Degradation

• Consider a degradation process H g ( x , y )

H

 f ( x , y )

 

( x , y )

• H is linear if

H

 af

1

( x , y )

 bf

2

( x , y )

 aH

 f

1

( x , y )

 bH

 f

2

( x , y )

• H is position invariant if

H

 f ( x

 a , y

 b )

 g ( x

 a , y

 b )

Colorado School of Mines Image and Multidimensional Signal Processing

21

Linear Position-Invariance

• If H is linear shift invariant, then the application of H to f is given by g ( x , y )

   

  f ( a , b ) h ( x

 a , y

 b ) da db

(this is the convolution of f and h )

• Here, h(x,y) is the impulse response of H h ( x , y )

H

( x , y )

22

Colorado School of Mines Image and Multidimensional Signal Processing

Image Restoration

• Linear degradation

– The model is G(u,v) = H(u,v) F(u,v) + N(u,v)

– If we know the degradation function H(u,v) , we can undo its effects

• How can we estimate the degradation function?

– Estimate by image observation

• Take a small area of the image, G s s

(u,v) / F s

(u,v)

(u,v)

• If we know what the non-degraded image F s

– H s

(u,v) = G

(u,v) is supposed to be,

– Estimate by experimentation

• Using the same imaging system, take another picture G(u,v) of a bright dot (ie., an impulse)

• This is the model of the degradation (within a scale factor)

– H(u,v) = G(u,v)

– Estimate by modeling

• Can analytically derive the form of the degradation

• Examples: Motion blur, atmospheric blur

23

Colorado School of Mines Image and Multidimensional Signal Processing

Example – Atmospheric Blur

H ( u , v )

 e

 k

 u

2  v

2

5

/ 6

Gaussian

Atmospheric

Colorado School of Mines Image and Multidimensional Signal Processing

24

Example – Atmospheric Blur

Colorado School of Mines Image and Multidimensional Signal Processing

25

Example – Motion Blur

• Motion blur g ( x , y )

• For linear motion over time T

– x

0

(t) = a t/T

– y

0

(t) = b t/T

0

T f

 x

 x

0

( t ), y

 y

0

( t )

 dt

H ( u , v )

( ua

T

 vb ) sin

 

( ua

 vb )

 e

 j

( ua

 vb )

Colorado School of Mines Image and Multidimensional Signal Processing

26

Inverse Filtering

• The simplest approach to undoing the degradation is

F

ˆ

( u , v )

G ( u , v )

H ( u , v )

• Problem – we also enhance the noise

F

ˆ

( u , v )

F ( u , v )

N ( u , v )

H ( u , v )

• To avoid dividing by zero where H(u,v) is small (usually at high frequencies), we can limit analysis to the lower frequencies

Colorado School of Mines Image and Multidimensional Signal Processing

27

Inverse Filtering – Effect of Noise

Colorado School of Mines Image and Multidimensional Signal Processing

28

Matlab

• Read image f = im2double(imread('cameraman.tif'));

• Blur and add noise h = fspecial('gaussian',15,2);

Blurred = imfilter(f,h,'circular'); noise = 0.001*randn(size(f)); g = Blurred + noise; figure, imshow(g, []);

• Take Fourier transform of g

G = fftshift(fft2(g)); figure, imshow(log(abs(G)),[]);

• Take Fourier transform of h h = ifftshift(fspecial('gaussian',size(f),2)); figure, imshow(h,[]);

H = fftshift(fft2(h)); figure, imshow(log(abs(H)),[]);

Colorado School of Mines Image and Multidimensional Signal Processing

29

Matlab example (continued)

• Do: F(u,v) = G(u,v)/H(u,v) only near (u,v) = (0,0)

• Convert back to spatial domain

Colorado School of Mines Image and Multidimensional Signal Processing

30

Matlab example (continued)

• Do: F(u,v) = G(u,v)/H(u,v) only near (u,v) = (0,0)

R = 70;

F = zeros(size(f)); for u=1:size(f,2)

for v=1:size(f,1)

if (u-size(f,2)/2)^2 + (v-size(f,1)/2)^2 <= R^2

F(v,u) = G(v,u) / H(v,u);

end

end end

• Convert back to spatial domain fRestored = real(ifft2(ifftshift(F)));

Colorado School of Mines Image and Multidimensional Signal Processing

31

Summary / Questions

• We model image degradation as a linear, position invariant process followed by additive noise.

• What are some types of noise models?

• Restoration:

– Random-noise reduction is best carried out in the spatial domain using convolution masks.

– Correcting periodic noise and undoing the effect of blur is best carried out in the frequency domain.

32

Colorado School of Mines Image and Multidimensional Signal Processing

Download