Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dr. Engr. Sami ur Rahman Assistant Professor Department of Computer Science University of Malakand Visualization in Medicine Lecture: Convolution.

Similar presentations


Presentation on theme: "Dr. Engr. Sami ur Rahman Assistant Professor Department of Computer Science University of Malakand Visualization in Medicine Lecture: Convolution."— Presentation transcript:

1 Dr. Engr. Sami ur Rahman Assistant Professor Department of Computer Science University of Malakand Visualization in Medicine Lecture: Convolution

2 Overview  Function  Signal  Impulse Function  Impulse Function Decomposition  Impulse Response  Convolution  Convolution 1D  Implementing 1D Convolution  Convolution 2D  Implementing 2D Convolution  Image Filter University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 2

3 Function  A function is a relation between a set of inputs and a set of permissible outputs with the property that each input is related to exactly one output.  A function f takes an input x, and returns an output f(x) University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 3 Source: Wikipedia

4 Signal Signal: A function that conveys information about the behaviour or attributes of some phenomenon. University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 4 Discrete-time signal created from a continuous signal by sampling

5 Impulse Function (δ function)  The Impulse function (δ function) is a generalized function that is zero everywhere except at zero.  The impulse function, δ[n] is 1 at n=0, and zeros at n ≠ 0. University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 5

6 Impulse Function Decomposition 0 1 2 3 2 3 1 2 3 1 2 3 1 A signal can be decomposed as a weighted sum of impulse function Weighted sum of impulse functions

7 Impulse Function Decomposition  A signal can be decomposed as a weighted sum of impulse function  The signal, x[n] can be represented by adding the shifted and scaled impulse functions University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 7

8 Impulse Function Decomposition University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 8 In general, a signal can be written as sum of scaled and shifted delta functions.

9 Impulse Response  Impulse response is the output of a system resulting from an impulse function as input. Impulse response is denoted as h[n].  Impulse response of time shifted impulse function University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 9 System 0 1 2 3 2 11 2 1 *= 2 System= any signal * impulse function

10 Impulse Response: Scaling factor  If the system is linear, a scaled in input signal causes an identical scaling in the output signal. University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 10 System

11 Additive Property of Impulse Response  If the input has 3 components then the output is simply This is called additive property of linear system. University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 11 System

12 Additive Property of Impulse Response The response resulting from several inputs can be computed as the sum of the responses each input acting alone. University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 12 System

13 Additive Property of Impulse Response (cont) University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 13 We see that if the input signal is then the output will be To summarize, a signal is decomposed into a set of impulses and the output signal can be computed by adding the scaled and shifted impulse responses.

14 Convolution University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 14

15 Convolution Convolution is the most important and fundamental concept in signal processing and analysis. By using convolution, we can construct the output of system for any arbitrary input signal, if we know the impulse response of system. University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 15

16 Convolution General concept of convolution: A signal is decomposed into a set of impulses and the output signal can be computed by adding the scaled and shifted impulse responses University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 16

17 Convolution: An Important Fact The only thing we need to know about the system's characteristics is the impulse response of the system, h[n]. If we know a system's impulse response, then we can easily find out how the system reacts for any input signal. University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 17

18 Convolution The mathematical definition of convolution x[n] is input signal h[n] is impulse response y[n] is output * denotes convolution Notice: The terms of x[k] are multiplied by the terms of a time- shifted h[n] and add them up University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 18

19 Convolution in 1D  Example of convolution for 1 dimensional signal.  x[n] = { 3, 4, 5 } h[n] = { 2, 1 }  x[n] has only non-zero values at n=0,1,2, and impulse response, h[n] is not zero at n=0,1. University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 19 x[n] = { 3, 4, 5 } h[n] = { 2, 1 }

20 Convolution in 1D University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 20 Wikipedia

21 University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 21 0 1 2 4 3 5 0 1 2 1 2 1 0 1 2 4 3 5 2 1 x[n] = { 3, 4, 5 } h[n] = { 2, 1 } Inverse of h[n]

22 Next time 2D Convolution University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 22

23  Let's look more closely the each output. In order to see a pattern clearly, the order of addition is swapped. The last term comes first and the first term goes to the last. And, all zero terms are ignored. University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 23 y[0] = x[0]·h[0] y[1] = x[1]·h[0] + x[0]·h[1] y[2] = x[2]·h[0] + x[1]·h[1] y[3] = x[3]·h[0] + x[2]·h[1]

24 University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 24 developer.apple.com

25 Sources University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 25  http://www.songho.ca/dsp/convolution/convolution.html http://www.songho.ca/dsp/convolution/convolution.html

26 Impulse Function Decomposition University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 26 0 1 2 3 2 3 1 2 3 1 2 3 1

27 Impulse Function Decomposition  A signal can be decomposed as a weighted sum of impulse function  Example University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 27

28 University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 28 0 1 2 4 3 5 0 1 2 1 2 1 0 1 2 4 3 5 2 1 4 3 5 2 1 4 3 5 2 1 4 3 5 2 1 2 1 4 3 5 6111450

29 University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 29 0 1 2 4 3 5 0 1 2 1 2 1 0 1 2 4 3 5 2 1

30 Convolution in 1D  One thing to note before we move on: Try to figure out yourself how this system behaves, by only looking at the impulse response of the system. When the impulse signal is entered the system, the output of the system looks like amplifier and echoing. At the time is 0, the intensity was increased (amplified) by double and gradually decreased while the time is passed.  From the equation of convolution, the output signal y[n] will be.  Let's compute manually each value of y[0], y[1], y[2], y[3],... University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 30

31 Convolution in 1D University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 31

32  Notice that y[0] has only one component, x[0]h[0], and others are omitted, because others are all zeros at k ≠ 0. In other words, x[1]h[-1] = x[2]h[-2] = 0. The above equations also omit the terms if they are obviously zeros. If n is larger than and equal to 4, y[n] will be zeros. So we stop here to compute y[n]and adding these 4 signals (y[0], y[1], y[2], y[3]) produces the output signal y[n] = {6, 11, 14, 5}. University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 32


Download ppt "Dr. Engr. Sami ur Rahman Assistant Professor Department of Computer Science University of Malakand Visualization in Medicine Lecture: Convolution."

Similar presentations


Ads by Google