You are on page 1of 39

Todays Lecture : Convolution and Correlation

Impulse response Convolution in linear time-invariant systems Properties of linear time-invariant systems Convolution in images: the Gaussian lters Break Implementation of linear time-invariant systems Correlation of discrete-time signals Correlation in images Local image enhancement

image

and

signal

processing

itu

copenhagen

Method for Analysis of a Discrete-Time Linear Time-Invariant (LTI) System

Any input signal can be decomposed into the weighted sum of unit sample sequences. Analyze the linear, time-invariant (LTI) system by its response to a unit sample signal system impulse response h(n). The LTI system output for an arbitrary input signal is the convolution sum between the input signal and the system impulse response h(n).

image

and

signal

processing

itu

copenhagen

Decompose a Discrete-Time Signal x(n) Into a Sum of Impulses


Select elementary signal: time shifted impulses xk (n) = (n k). Multiply x(n) and (n k): x(n) (n k) = x(k) (n k).

image

and

signal

processing

itu

copenhagen

Decompose a Discrete-Time Signal x(n) Into a Sum of Impulses

The value of x(n) at position k can be obtained from x(n) (n k). In order to obtain the entire signal x(n) we simply sum the product sequences for all possible k:

x(n) =
k=

x(k) (n k).

image

and

signal

processing

itu

copenhagen

The Convolution Sum


Dene the response of a Linear, Time Invariant (LTI) system to the unit sample signal (n): h(n) [ (n)] Now use the arbitrary input signal represented as a sum of impulses

x(n) =
k=

x(k) (n k).

The LTI system output signal y (n) from the input signal x(n) is y (n) = [x(n)]. Use the x(n) sum and the linearity condition of the LTI system

y (n) = [
k= image and

x(k) (n k))] =
k= processing

x(k)h(n k).

signal

itu

copenhagen

The Convolution Sum Continued

Thus, the relaxed Linear, Time Invariant (LTI) system is completely characterized by a single function h(n), which is the systems response to the unit sample signal (n).

The LTI systems response to any input signal x(n) is the convolution sum

y (n) =
k=

x(k)h(n k) = x h.

image

and

signal

processing

itu

copenhagen

A Closer Look at the Convolution at Time n0


Compute the LTI system output at time n = n0,

y (n0) =
k=

x(k)h(n0 k).

From this we observe that: The input signal x(k) and the impulse response h(n0 k) are both functions of k. The signals x(k) and h(no k) are multiplied together to form a new signal. The output signal y (n0) is the sum of the elements of this product signal.
image and signal processing itu copenhagen 7

The Four Steps in Convolution


Computing the convolution between x(k) and h(k) to obtain the output signal value y (n0), at time n = n0, involves the following four steps 1. Folding Fold h(k) about k = 0 to obtain h(k). 2. Shifting Shift h(k) by n0 to obtain h(n0 k). 3. Multiplying Multiply x(k) by h(n0 k) to obtain vn0 x(n)h(n0 k). 4. Summing Sum all the values of the product signal vn0 (k) to obtain the system output value y (n0) at time n = n0. The complete system output signal y (n) for < n < is computed by repeating Step 2, 3 and 4 for all time instants n.
image and signal processing itu copenhagen 8

Convolution Example 2.3.2

image

and

signal

processing

itu

copenhagen

Properties of Convolution
Commutative x(n) h(n) = h(n) x(n) y (n) =
k= x(k )h(n k )

k= x(n k )h(k )

It does not matter which of the two signals that is folded and shifted. Associative [x(n) h1(n)] h2(n) = x(n) [h1(n) h2(n)] The input can be convolved with rst one than the other impulse response, or the impulse responses can be convolved with each other rst. Distributive x(n) [h1(n) + h2(n)] = x(n) h1(n) + x(n) h2(n) If two LTI systems with impulse responses h1(n) and h2(n) are excited by the same input, the sum of the responses is identical to that of a LTI system with impulse response h(n) = h1(n) + h2(n).
image and signal processing itu copenhagen 10

Causality of Linear Time-Invariant Systems


The output signal of a causal LTI system at time n0 does only depend of the values of x(n) for n n0. What does that mean for the systems impulse response h(n)?

y (n0) =
k=

h(k)x(n0 k)
1

=
k=0

h(k)x(n0 k) +
k=

h(k)x(n0 k)

= (h(0)x(n0) + h(1)x(n0 1) + h(2)x(n0 2) + ) + (h(1)x(n0 + 1) + h(2)x(n0 + 2) + h(3)x(n0 + 3) + ). Now, if y (n0) is only dependent of past and present inputs then h(n) = 0 f or n < 0. Thus the impulse response h(n) is 0 for n < 0. Nothing happens before the input signal is applied.
image and signal processing itu copenhagen 11

Causality of Linear Time-Invariant Systems

Now use a causal input x(n) to a LTI system h(n), then the limits in the convolution sum is further restricted:
n

y (n) =
k=0 n

h(k)x(n k) x(k)h(n k).


k=0

= Notice that

the upper limit is growing with time, and the output y (n) of a causal system, in response to a causal input, is causal.

image

and

signal

processing

itu

copenhagen

12

Stability of Linear Time-Invariant Systems

A system is BIBO (bounded input, bounded output) stable if and only if its output signal y (n) is bounded for every bounded input x(n). A linear time-invariant system is stable if its impulse response is absolutely summable

|h(k)| <
k=

image

and

signal

processing

itu

copenhagen

13

Systems with Finite-Duration and Innite-Duration Impulse Responses


FIR system: Finite Impulse Response system such that h(n) = 0 for n < 0 and n M.
M 1

y (n) =
k=0

h(k)x(n k)

The system acts as a window, that views the most recent M input signal samples in forming the output. The FIR system has a nite memory length of M samples. IIR system: Innite Impulse Response system.

y (n) =
k=0

h(k)x(n k)

The output uses the present and all past input samples, and thus it has an innite memory.
image and signal processing itu copenhagen 14

Discrete 2D (Spatial) Convolution

1 M 1 N 1 f (m, n)h(x m, y n) f (x, y ) h(x, y ) = N M m=0 n=0 which is equivalent to our original denition of discrete 2D ltering. The only dierence is a ipping of the lter h about the origin.
a b

g (x, y ) =
s=a t=b

w(s, t)f (x + s, y + t)

This is a direct extension from the 1D convolution.

image

and

signal

processing

itu

copenhagen

15

Properties of convolutions
Besides the commutative, distributive and associative properties, f g = gf f (g + h) = f g + f h f (g h) = (f g ) h

the convolution result is limited and dierentiable if one operand is. In this case we have D(f g ) = Df g = f Dg where D denotes dierentiation.

image

and

signal

processing

itu

copenhagen

16

Gaussian Filter and Its Derivatives


This means we can get a smoothed dierentiated image by convolving the image with the derivative of a Gaussian function. Important lters: G(x, ) = 1
1 (2 ) 2 2 x2 e 2

x Gx(x, ) = 2 G(x, ) 1 x2 Gxx(x, ) = ( 2 + 4 )G(x, ) 3x x3 Gxxx(x, ) = ( 4 6 )G(x, ) ...

image

and

signal

processing

itu

copenhagen

17

Gaussian Filters

From left to right: Original image, smoothed image by convolution with a Gaussian, blurred derivative in x-direction, burred derivative in y-direction.

image

and

signal

processing

itu

copenhagen

18

Recursive Discrete-Time Systems


The output of a LTI system can be described explicitly in terms of present and past values of the input. However past output values can also be used in the description.
1 n The cumulative average of a signal is y (n) = n+1 k=0 x(k ). The computation of y (n) requires storage for samples x(k), 0 k n.

However we can use the previous output y (n 1): 1 (n + 1)y (n) = n k=0 x(k ) + x(n) = ny (n 1) + x(n).
n y (n 1) + 1 x(n). Hence y (n) = n+1 n+1

The recursive system requires only one memory location.

image

and

signal

processing

itu

copenhagen

19

LTI Systems Described by Dierence Equations

Systems described by constant-coecient linear dierence equations are a subclass of the recursive and nonrecursive systems. The general form is
N M

y (n) =
k=1

ak y (n k) +
k=0

bk x(n k)

Recursive systems described by linear constant-coecient dierence equations are linear and time invariant.

image

and

signal

processing

itu

copenhagen

20

Implementation of Linear Time-Invariant Systems.


First order LTI system y (n) = a1y (n 1) + b0x(n) + b1x(n 1). Viewed as two LTI systems in cascade FIR (Finite Impulse Response): v (n) = b0x(n) + b1x(n 1) and IIR (Innite Impulse Response): y (n) = a1y (n 1) + v (n). We can interchange the order of two LTI lters without aecting the overall system response (direct form II). w(n) = a1w(n 1) + x(n) y (n) = b0w(n) + b1w(n 1)
image and signal processing itu copenhagen 21

General Linear Time-Invariant Recursive System.

y (n) =
k=1

ak y (n k) +
k=0

bk x(n k)

This can be written as a recursive system


N

w(n) =
k=1

ak w(n k) + x(n)

followed by a nonrecursive system (direct form II)


M

y (n) =
k=0

bk w(n k)

image

and

signal

processing

itu

copenhagen

22

Direct Form II Structure.

image

and

signal

processing

itu

copenhagen

23

Direct Form II Structure.

The Direct Form II Structure requires:

The number of multiplications: M + N + 1. The number of delays: max(M, N ).

The Direct Form II structure requires a minimum number of delays for the realization of the system, and is denoted a canonic form.

image

and

signal

processing

itu

copenhagen

24

Recursive and Nonrecursive Realizations of FIR Systems


A FIR system is described by
N M

y (n) =
k=1

ak y (n k) +
k=0

bk x(n k).

A nonrecursive system has ak = 0 and the impulse response is the lter coecients bk . A FIR system can always be realized both recursively and nonrecursively. FIR and IIR are general characteristics of a LTI system, recursive and nonrecursive are structures for implementation of the system.

image

and

signal

processing

itu

copenhagen

25

Correlation of Discrete-Time Signals


Distance from radar to target: x(n): Sampled version of the signal transmitted by the radar. y (n): Sampled version of the signal reected by the target (f.inst. airplane, ship) and received by the radar. Now assume the received signal y (n) is a delayed version of x(n) y (n) = x(n D) is an attenuation and D is the delay in samples out and home. How can we determine the distance to the target? Use correlation between the transmitted signal x(n) and the received signal y (n)!
image and signal processing itu copenhagen 26

Correlation of Discrete-Time Signals

The cross correlation between the nite energy signals x(n) and y (n)

rxy (k) =
n=

x(n)y (n k)

k = 0, 1, 2, . . .

or equivalently y (n)

rxy (k) =
n=

x(n + k)y (n)

k = 0, 1, 2, . . .

image

and

signal

processing

itu

copenhagen

27

Correlation of Discrete-Time Signals III

What happens if the order of x(n) and y (n) is reversed?

ryx(k) =
n=

y (n)x(n k) x(n k)y (n)


n=

= =

x(m)y (m + k)
m=

= rxy (k)

image

and

signal

processing

itu

copenhagen

28

Correlation

Cross correlation of x(n) and y (n): rxy (k) =

n= x(k )y (n k ).

Shifting into y (n k). Multiplying x(n) and y (n k). Summing of product terms.

image

and

signal

processing

itu

copenhagen

29

Energy and Power of a Signal

The energy of a signal x(n) is dened as

E
n=

|x(n)|2

The average power of a signal is


N 1 P lim |x(n)|2 x 2N + 1 n=N

image

and

signal

processing

itu

copenhagen

30

Autocorrelation

Correlation of a signal x(n) with itself.

rxx(k) =
n=

x(n)x(n k)

The signal energy is the autocorrelation for k = 0.

rxx(0) =
n=

x2(n)

image

and

signal

processing

itu

copenhagen

31

Properties of Auto- and Crosscorrelation


How are rxx(k), rxy (k) and ryy (k) related? Look at the energy E (k) in the signal ax(n) + by (n k)

E (k) = =

(ax(n) + by (n k))2 x2(n) + b2


n=

n= a2 n=

y 2 (n k ) +

2ab
n=

x(n)y (n k)

= a2rxx(0) + b2ryy (0) + 2abrxy (k) Now use that E (k) 0 k = 0, 1, 2, . . . a2rxx(0) + b2ryy (0) + 2abrxy (k) 0 and dividing by b2, which is assumed = 0 gives a a rxx(0)( )2 + 2rxy (k)( ) + ryy (0) 0 b b
image and signal processing itu copenhagen 32

Properties of Auto- and Cross-Correlation


E (k) is quadratic and nonnegative in a b with coecients rxx (0), 2rxy (k ), and ryy (0) a 2 a rxx(0) + 2rxy (k)( ) + ryy (0) 0. b b The discriminant D = (2rxy (k))2 4rxx(0)ryy (0) = 4(rxy (k) rxx(0)ryy (0)) 0. Condition on crosscorrelation |rxy (k)| rxx(0)ryy (0) = ExEy .

Condition on autocorrelation for y (n) = x(n) |rxy (k)| rxx(0) = Ex

image

and

signal

processing

itu

copenhagen

33

Example of Autocorrelation

image

and

signal

processing

itu

copenhagen

34

Autocorrelation of Periodic Signals.

The autocorrelation of a periodic signal (power signal) is periodic.


M 1 x(n)x(n k) rxx(k) = lim x 2M + 1 n=M

Assume that x(n) is periodic with period P , then


M 1 rxx(k + P ) = lim x(n)x(n k P ). x 2M + 1 n=M

Because x(n k P ) = x(n k) rxx(k + P ) = rxx(k)

image

and

signal

processing

itu

copenhagen

35

Periodicity in Sunspot Numbers.

image

and

signal

processing

itu

copenhagen

36

Spatial Correlation

Correlation can be used to nd matches of a subimage w(x, y ) in an image f (x, y ): c(x, y ) =


s t

f (s, t)w(x + s, y + t)

The summation is taken over the region where the images overlap. Compare it to ltering:
a b

g (x, y ) =
s=a t=b

w(s, t)f (x + s, y + t)

image

and

signal

processing

itu

copenhagen

37

Local Enhancement by Histogram Equalization


For each pixel, compute histogram in the neighborhood and obtain histogram equalization. Map the gray level of the center pixel.

image

and

signal

processing

itu

copenhagen

38

Use of Histogram Statistics for Image Enhancement


Find the local mean and variance of the gray levels in a neighborhood. Enhance areas where the local mean and variance diers a lot from the global estimates.

image

and

signal

processing

itu

copenhagen

39

You might also like