 A warm welcome to the 44th session on the subject of wavelets and multirate digital signal processing. In this session, we continue what we have been doing over the past few sessions namely looking at student efforts and presenting tutorials or expositions on the topics already taught or discussed. This is with the aim of understanding those topics better by actually working out some examples and in that spirit we take today the two band filter bank in depth. So, the session today would be devoted to a tutorial on the two band filter bank that we have studied in such depth. Now, let me recall for you the basic structure of the two band filter bank and let us also recall what it is that we ask for from the different components in the two band filter bank. What we shall be doing in this session is to study it in the time domain and the frequency domain, but with examples. So, our aim is to present a tutorial today. We are going to work out together some examples where we given sequences and we see what comes out at different points in the filter bank. You will recall that somewhere earlier on in this series of lectures we had of course analyzed the two band filter bank in depth. We had also presented examples cursorily in some sense we had said we had in brief at a superficial level we had exposed the student to how the two band filter bank works and we had also put forth some exercises to be done, but then that is not the same thing as working out a tutorial example in total and that is what we intend to do today to work out a couple of tutorial examples on the two band filter bank in total. So, with that background let us recall the main structure or the prototype structure of a two band filter bank once again recall that we have an analysis section and a synthesis section. We shall denote the analysis section filters by h 0 z and h 1 z these are followed by down samples this is the analysis section. Now we shall intentionally break the filter bank into two parts the analysis and the synthesis section. So, this is the point x the point of input we shall call this point y 1 we shall call this point y 2 this point y 3 and this point y 4 and you will recall that this is essentially intended to be a low pass filter with a cutoff of pi by 2 and this is intended to be a high pass filter again with a cutoff of pi by 2. So, let us now go to the synthesis section in the synthesis section we take over from the points y 3 and y 4 up sample by 2 and subject it to the action of two filters followed by a summation and we shall show the output coming here. We call this point y 5 this point y 6 this point y 7 this point y 8 and the output y o or y out and you will recall that g 0 intends to be an ideal low pass filter again with a cutoff of pi by 2 g 1 intends to be an ideal high pass filter again with a cutoff of pi by 2. Now, this is the synthesis section and the names are suggestive the synthesis section re-synthesizes the output from the inputs. So, we have had two branches two outputs come here and there is a re-synthesis at the point y 0 here. In contrast the analysis section analyzes or breaks down the word analysis means to break down. So, the analysis section analyzes or breaks down the input into two branches or two components which we ultimately call y 3 and y 4. Now, it is very important to understand that there is of course, an impossible situation here we are never able to reach the ideal low pass or the ideal high pass filter there are some fundamental things which prevent us from doing that. Even so we recall it is possible to build perfect reconstruction structures. For example, if we take the hard two band perfect reconstruction filter bank what we have there is a set of filters h 0 h 1 g 0 g 1. In fact, all of them essentially with an impulse response of length 2 which can create a perfect reconstruction situation that means the output y 0 is essentially the same as the input except possibly for a constant multiplier and a shift. So, what we shall do is to review again the hard filter bank by applying a finite length sequence at the input. So, let us study the output at every point to understand this better. Now, what we shall do is first to look at a finite length input sequence and then we shall periodize that same sequence that means we shall extend that sequence repeated periodically to get a periodic sequence that is called periodization. And we shall study what happens when the periodic sequence is applied at the input of the hard two band filter bank. So, let us come down to the hard two band filter bank in particular you will recall that h 0 z in the hard two band filter bank is essentially 1 plus z inverse h 1 z can be taken to be minus 1 plus z inverse of course, there are variants possible, but we shall choose this for the moment g 0 z is again taken to be 1 plus z inverse and g 1 z can be taken to be 1 minus z inverse. And of course, we may also include a factor of half the factor of half can either be on the analysis or the synthesis side. Now, let us take as an example the sequence x n equal to 7 plus x n equal to 7 plus x n 5 minus 4 6 3 and 8 located from 0 onwards as the input to this hard two band filter bank. And what we intend to do is to study the output at every point. And we do this with the intent of understanding fully how each point works, what happens at every point and we are doing this in the time domain at the moment we are doing it in the time domain. Why are we doing this exercise? We must understand why we are doing this exercise in a tutorial. You see we keep saying perfect reconstruction, but it is very important that we understand how perfect reconstruction actually works with sequences as examples. How do the intermediate sequences add and combine to get back the original to within of course, a constant and a delay. This must be fixed in our minds with a couple of examples. So, let us take the sequence as the input and look at what happens at every point on the analysis side and on the synthesis side. So, on the analysis side we have the point y 1. Now, we have x. So, we shall of course, follow the same convention small letter denotes time domain and the corresponding capital letter whether written with or without the argument. So, when we write x z we mean the same thing as when we simply write x capital x and similarly here when we write x in we mean the same thing as when we simply write small x. So, this denotes the frequency domain. So, of course, this really and very accurately denotes the complex frequency domain and by now we are very familiar with what we mean by all these domains. So, we can always replace z by e raised to the power j omega and that would give us the sinusoidal frequency domain. So, this is a little bit about notation. Now, let us look at the outputs at every point first as I said in time. So, you will recall that if h 0 z is 1 plus z inverse as we have taken it to be and the corresponding impulse response is essentially 1 and 1 located at 0. So, you will recall this notation in fact let me explain this notation for the input as well. When we use this notation what we mean is that at n equal to 0 the sequence takes the value 7 and therefore, at 1 it has the value 5 at 2 minus 4 at 3 6 at 4 3 and at 5 8 and the sequence is 0 outside. So, this is a convenient way of writing down finite length sequences and we shall use this notation in the sequel as well. Of course, together with this we must take the impulse response here and then if we wish to find the output at y 1 we need to convolve the input with the impulse response. So, there we go y 1 is essentially x convolved with this impulse response which we shall call h 0. So, I do not need to explicitly write down. So, you know h small h 0 is the impulse response of h the filter whose system function is capital H 0 z. This is small h 0 n and a similar form of notation will be used elsewhere. So, when we convolve x with h 0 which you will see is essentially 7 5 minus 4 6 3 8 convolved with 1 and 1 and then we get well at 0 we would have 7 plus 0 there is a 0 behind at 1 we would have 5 plus 7 at 2 we would have minus 4 plus 5 and this can be continued. So, let me write down the results right away 7 plus 0 is 7 5 plus 7 is 12 minus 4 plus 5 is 1 6 plus minus 4 is 2 3 plus 6 is 9 and 8 plus 3 is 11 followed by 0 plus 8 is 8 and after that we get we continue to get a sequence of zeros. So, as expected the original sequence was of length 6 the impulse response is of length 2 and therefore, the output after this convolution is of length 6 plus 2 minus 1 which is 7 that is what we get here. So, as this is x convolved with h 0 that is the output at the point y 1 as expected of length 7. Now let us take the output at y 2. So, at y 2 of course, we have x convolved with h 1 and we know what h 1 is h capital H 1 z is of course, minus 1 plus z inverse and therefore, small h 1 n is going to be minus 1 at 0 and 1 at 1 and here again when we convolve x with h 1 let me put back x for you for a minute. So, when we convolve x with h 1 at this point we want to take well this and the past. So, minus 1 minus 1 times 7 plus 1 times 0 and that would give us essentially minus 7 at this point it would be minus 5 plus 7 at this point it would be minus 4 into minus 1 which is 4 plus 5 and so on. So, we can construct the whole output accordingly. So, x convolved with h 1 is going to give us minus 7 plus 0 at the point 0 minus 5 plus 7 that is 2 at the point 1 minus of minus 4 which is 4 plus 5 and that is 9 at the point 2 minus 6 minus 4 that is 10 minus 10 minus 3 plus 6 and that is 3 minus 8 plus 3 and that is minus 5 and finally, 0 and then plus 8 that is 8. So, this is the output at y 2 again as expected of length 7. So, this is straight forward now we need to do the next step that is down sampling by 2. So, on down sampling by 2. So, we have y 1 being down sampled by 2 to give us y 3 and I know what y 1 was let me put it flash it back for you for a minute this is how y 1 looked and when you down sample what is at 0 remains at 0 what is at 2 comes to 1 what is at 4 comes to 2 and so on. So, let us put it down. So, y 3 would look like this to essentially be 7 at the point 0 1 at the point 1 9 at the point 2 and 8 at the point 3 and 0 else and similarly, we can put down the output when we down sample by 2 on the lower branch. So, when we down sample y 2 by 2 we get y 4 and y 4 looks like this at y 4 now let me put down y 2 once again to show you. So, when we down sample this point comes to 0 this point would come to 1 this point to 2 and this point to 3. So, we have minus 7 at 0 9 at 1 3 at 2 and 8 at 3 and as expected the result after down sampling here is of length 4 and the result after down sampling here the second one with y 4 is of length 4 2. So, that is quite clear and as expected now let us keep these down sampling outputs before us because now we need to up sample them and then filter them once again. So, we have here the outputs y 3 and y 4 as outputs of the analysis section here. So, we now need to work on the synthesis side. So, the first thing to do is to up sample. So, we first need to up sample y 3 to obtain y 5 and that is easy this is how y 3 looks and therefore, y 5 will look like this 7 and then a 0 1 and then a 0 9 and then a 0 and finally, 8. So, we are back to a length of 7 as before and on a similar note we know what y 6 will look like 2 y 6 is essentially obtained by up sampling y 4. So, we have y 4 here when we up sample this by a factor of 2 we get y 6. So, let us draw y 6 2. So, y 6 would appear like this minus 7 and then a 0 9 and then a 0 3 and then a 0 and finally, 8 as expected again of length 7. Now, we need to subject these to the action of the synthesis low pass and high pass filters. So, of course, we have the upper one that is y 5 which we have here being subjected to the action of the synthesis low pass filter and y 6 here being subjected to the action of the synthesis high pass filter. So, let us do these 2 operations. So, y 5 when subjected to the action of g 0 z would give us y 7 and that is easy to do we know what g 0 z does it is essentially 1 plus z inverse by 2. So, for example, when we subject y 5 to the action of g 0 z at this point we shall get 7 plus 0 by 2 which is 7 by 2 at this point we shall get 0 plus 7 by 2 which is again 7 by 2 at this point we get 1 plus 0 by 2 at this point we get 0 plus 1 by 2. So, that is an interesting situation we what we have essentially is the number repeated with a factor of half. So, y 7 would look like this 7 plus 0 by 2 here 0 plus 7 by 2 there 1 plus 0 by 2 there and 0 plus 1 by 2 there 9 plus 0 by 2 and 0 plus 9 by 2 finally, 8 plus 0 by 2 that is 4 if you like and again 0 plus 8 by 2 which is 4 after which of course, we keep getting a sequence of 0's and similarly of course, we need to evaluate y 8. So, we have y 6 being subjected to the action of g 1 z to obtain y 8 and g 1 z you will recall is 1 minus z inverse divided by 2. So, essentially what it does is to take each sample and subtract the past sample from it in fact, let me write this down in the time domain y 8 n is y 6 n minus y 6 n minus 1 divided by 2 and therefore, I have here this sequence y 6 at this point I shall get minus 7 minus 0 by 2 which is minus 7 by 2 at this point I would get 0 minus minus 7 by 2 minus minus which is 7 by 2 and so on let me complete the working here. So, I have y 8 n is as follows minus 7 minus 0 by 2 followed by 0 minus minus 7 by 2 again 9 minus 0 by 2 and 0 minus 9 by 2 this is 9 3 minus 0 by 2 and 0 minus 3 by 2 8 minus 0 by 2 and 0 minus 8 by 2 simple enough and now let me put them together. So, you will recall this was y 7 this is now y 8 and we can add them point by point to do that let me write them down on the same sheet for convenience. So, I have y 7 here which is essentially 7 by 2 7 by 2 half half 9 by 2 9 by 2 8 by 2 and 8 by 2 in the end followed by y 8 which is minus 7 by 2 7 by 2 9 by 2 minus 9 by 2 3 by 2 minus 3 by 2 8 by 2 minus 9 by 2 minus 9 by 2 minus 9 by 2 minus 9 by 2 and minus 8 by 2 and when we add them we get 7 and minus 7 gives you a 0 7 and 7 by 2 gives you 7 9 and 1 by 2 gives you 5 1 minus 9 that is minus 8 by 2 gives you a minus 4 9 and 3 that is 12 by 2 gives you 6 9 minus 3 6 by 2 gives you 3 and finally 8 by 2 minus 8 by 2 gives you 8 and 8 by 2 minus 8 by 2 gives you 0 and all this is located from 0 onwards. Let me for your reference put down before you the sequence x n as we started with once again here we started with the sequence 7 5 minus 4 6 3 8 starting from n equal to 0 and what we have here is 7 5 minus 4 6 3 8 but starting at n equal to 1 and this is exactly what we mean by perfectly construction. We had the original sequence what has been obtained after addition that means at the output y 0. So, what we have here remember is y 0 essentially what we have at the point y 0 is essentially the original sequence shifted by one step shifted by one sample and with no other change. So, let us make a note of that that is a very important observation. We notice that y 0 n is essentially x of n minus 1. So, you know the division by 2 the factor of half and so on has taken care of the constant relationship. So, you know the output is essentially the same as the input as far as scaling goes a scaling has been taken care of, but the delay could not be taken care of the delay is required and the delay has occurred on account of the requirement of causality. We want the filters to be causal in fact now I would like you to study as an example this particular sequence at different points as we obtain it. How did the requirement of causality create a delay? You are doing some processing at different points in the two band filter bands. Now, if you are not willing to allow some time for the processing by time I mean a delay then it would not be possible to do this processing in real time. So, causality is a requirement when we want to do real time processing when we want to process samples as they come not store all the samples and then process them. Of course, the way we have done it here on paper is as if we have stored the samples and processed. So, we could have done without a delay if we do non causal filtering somewhere either on the analysis side or on the synthesis side or perhaps even both, but if we cannot do non causal processing a delay is inevitable. Anyway, so much so for the case of a periodic sequences I said our next step would be to periodize. So, what we are going to do now is to periodize the input. So, essentially we construct a new input which we shall call x tilde n and that is essentially you know remember x n was of length 6 here. So, what we shall do is to periodically repeat this sequence with the period of at least 6. So, it could be summation k going from minus to plus infinity x n to minus plus k times capital N where capital N is greater than or equal to 6. Now, in fact for simplicity what we shall do is to take capital N equal to 6 and work out what happens at different points and what we shall do then is to write down how this sequence will look for some range. So, we have 7, 5, minus 4, 6, 3, 8, at 0 this is the point 0. Of course, here I cannot think of this is a finite length sequence. Now, it is a periodic sequence. So, at this point you will have 7 back again and then 5 and this would continue here and on this side you would have 8 coming here, 3 coming there and this would continue backwards. Now, what we shall do is to analyze the output only in the range from 0 to 5 only in this range and we are justified in doing that because after all you can see as far as the linear shift invariant part of the processing in the 2 band filter bank is concerned namely with the filters. A periodic sequence of period 6 would result in a periodic sequence of period 6 after filtering. As far as down sampling goes we have intentionally taken a period of 6 and the reason for that is when we down sample a sequence of length 6 we get a sequence of length 3. So, that is convenient. So, let us focus on this range of times and see what happens at different steps. Now, you know really speaking we will have to probably include one more sample because you will recall that there is a delay of one sample in the overall processing. So, we will have to allow for one more sample. So, let us focus with one more sample there and let us straight away write down the outputs at different points. So, the output at y 1 is of course, obtained in this region. So, as I said please do not forget this is an infinite length sequence, but I am only focusing between 7 and 7 here on the output. So, I would get y 1 essentially 7 plus 8 that is 15 5 plus 7 that is 12 minus 4 plus 5 and that is 1 6 minus 4 which is 2 3 plus 6 which is 9 8 plus 3 which is 11 and 7 plus 8 which is 15 back again. So, I am talking about what has happened to this after being subjected to the action of the analysis low pass filter and similarly y 2 y 2 of course, would give me minus 7 plus 8 which is 1 minus 5 plus 7 which is 2 minus of minus 4 which is 4 plus 5 and that is 9 minus 6 minus 4 which is minus 10 minus 3 plus 6 and that is 3 minus 8 plus 3 and that is minus 5 and once again minus 7 plus 8 which gives me back a 1 and there I am and of course, now I can subjected to the action of down sampling. So, I have there. So, you see remember down sampling will bring me to a period of half the original period and that half is meaningful if my original period is a multiple of 2 and here it is there is no problem. So, y 3 is going to bring me to y 1 down sample by 2. So, I have 15 coming here 1 9 and then back to 15. So, now this becomes periodic with period 3 and similarly I have y 4 y 4 gives me 1 9 3 and then back to 1 again with the period of 3. So, much so for y 3 and y 4 now let me look at y 5 and y 6 which is obtained by upsample that is easy. So, y 5 which is essentially y 3 upsample by a factor of 2. So, I put back y 3 for your site and y 4 for your site. So, when I upsample y 3 by 2 I would get 15 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 and then 15 and I am back to a period of 6. So, I expected when I upsample I would have a periodicity of period 6 and so much so for y 6 2 I have 1 0 9 0 3 0 and then 1 back again. Now, I need to look at y 7 you see when I construct y 7 and y 8 I must now be a little careful. I need to realize that there is a repetitive behavior here. So, you know you have 15 0 1 0 9 0 15 and then the 0 1 continues here and this way too. So, if I wish to focus my attention only in this part then I must of course, look only at the outputs here because you know if I wish to find out what is going to happen here then I have to take into account the sample there. So, may be it is better that I focus my attention only on the outputs here. So, to obtain y 7 I would essentially take y 5 and subject it to the action of the filter. Now, what was the filter? The filter was essentially this plus this by 2 and it would be this minus this by 2. So, let us write that down. Now, you know as I said let us write it down only for the clear part of the interval. So, here I would not write the output here I will just leave it blank I will write it from here onwards. So, I will just leave it blank and then I have 0 plus 15 by 2. So, I have 15 by 2 there then I have a 1 plus 0 by 2 and then a 0 plus 1 by 2 and so on. So, 1 plus 0 by 2 and a 0 plus 1 by 2 9 plus 0 by 2 and then a 0 plus 9 by 2 15 plus 0 by 2 and then back again similarly y 8 y 8 of course, would begin once again from here. So, I would have 0 minus 1 by 2 which is minus 1 by 2 here 9 minus 0 by 2 and so on. So, I have well I would not write it at this point, but I will write 0 minus 1 by 2 and 9 minus 0 by 2 0 minus 9 by 2 3 minus 0 by 2 0 minus 3 by 2 and finally 1 minus 0 by 2 and now it is easy to add. So, when I add I get very simply well unknown here, but here we have 15 minus 1 that is 14 by 2 and that gives me a 7 9 and 1 10 by 2 which gives me a 5 1 minus 9 that is minus 8 by 2 and that is a minus 4 9 and 3 12 by 2 which is a 6 9 minus 3 and that is 6 by 2 which is a 3 and finally 15 and 1 16 by 2 which is 8 and back we are again to the sequence as expected delayed by one position. So, here I focused my attention on those 7 samples and we notice that we did get back the input we had started with this input periodically repeated with a period of 6 we do get back the same input periodically repeated. So, if you really did the calculations carefully you would see 8 appears here and of course this sequence would essentially be placed behind repeated periodically with every period of 6 and also repeated in the forward direction with a period of 6. So, what we have done here is to illustrate how this two band filter bank works with the sequence when it is initially taken to be a periodic and then when it is taken to be periodized and the intent behind this tutorial example was to show you how to implement the wavelet transform. So, there are two ways of doing it if you have a finite length sequence you could either implement the wavelet transform by keeping the sequence as it is a periodic in nature and therefore, obtaining the finite length outputs at each point in time at each point on the filter bank in time and then of course, processing it as it is or one could periodize it and one would obtain the same sequence in the interval of interest. Of course, you know you may want to look at this from a slightly different point of view when you realize that this is periodic with the same period of 6 you could think of this being circularly shifted. So, you know the 8 would also appear here. So, it is as if the sequence has got shifted forward by one place and what is spilling out has been brought back here this is called a circular shift. So, when we periodize the sequence and when we subjected to the action of this two band filter bank what we are going to get is an output which is of course, periodic with the same period, but in each period there is a circular shift by the delay that is incurred. Now, we must keep this in mind when we implement the Haar filter bank on a computer. It is very important that we understand this circular shift which is a consequence of the delay in the filter bank carefully during implementation. So, much so then for the time domain interpretation or time domain tutorial. Now, let us look at the frequency domain behavior of the Haar filter bank as an example. So, to make a frequency domain study nothing works as well as to take a sinusoidally sampled I mean essentially a sampled sinusoid as an input. So, the input now would be a sampled sinusoid. So, let us take that sampled sinusoid to be x n is cos pi by 4 n to begin with you know cos pi by 4 n lies only in the lower band. So, this is rather simple let us take cos pi by 4 n plus cos 3 pi by 4 n to begin with and let us study what happens at every point. Now, of course, what we are going to do now is to look at the output after each filter. So, what I intend to do now is to put before you the steps as to how we should go about analyzing this in frequency and as has been the practice in previous tutorials to leave it to you to complete the rest of the calculations. So, rather than do the whole example for you I would like to guide you through the steps and then leave it to you to complete the steps and the steps are as follows. You see what happens when we subject a sinusoid to a filter when we subject a sinusoid to a filter of course, it undergoes a change of magnitude and a change of phase. So, sinusoid of course, this is a sampled sinusoid when it is subjected to the action of a discrete filter there is a change of magnitude same frequency of sinusoid, but magnitude and phase changes. So, in this example if we take this sinusoid as the input what we would have to do is to look at the analysis filters which if you recall are essentially 1 plus z inverse and 1 minus or minus 1 plus z inverse whose frequency responses are respectively 1 plus e raised to the power minus j omega and minus 1 plus e raised to the power minus j omega. I shall straight away write down the magnitude and phase change. So, the magnitude change here is essentially of the form 2 cos omega and you can similarly work out the phase change by rewriting this as e raised to the power minus j omega by 2 times e raised to the power j omega by 2 plus e raised to the power minus j omega by 2 which gives you a phase change of minus omega by 2. So, phase change in the analysis low pass filter is essentially minus omega by 2 I would similarly expect that you work out the phase change for the high pass side of the analysis filter bank and the magnitude change we have done that before. So, remember when we take a sinusoid as the input we keep getting sinusoids after filtering, but what happens after down sampling now recall the frequency domain behavior of that. Now what we shall do is to again put before you just the expression for the down sampling. So, in down sampling if we have x e raised to the power j omega here what we get here is half x e raised to the power j omega by 2 plus x e raised to the power j omega by 2 plus minus pi. So, essentially an aliases created. So, two things happen the sinusoidal frequency is changed by a factor of half and there is another frequency added an alias frequency obtained by shifting the original frequency by pi either forward or behind it does not matter there is a periodicity of period 2 pi. And similarly, if we look at the up sampler we have x e raised to the power j omega being given here up sampled to produce x e raised to the power j 2 omega. Now remember in up sampling two things happen this is deceptive it looks as if there is just one frequency created no there are two frequencies created you know when you contract the frequency axis by a factor of 2 as this expression suggests. The periodic repetitions around 2 pi now repeat around pi. So, each frequency brings an image frequency into the region 0 to pi. So, what I have done is to give you the basic steps in doing a frequency domain analysis this is an exercise a tutorial exercise for U S students you know what happens when you subjected to the action of the synthesis filters and then one could add it. So, it would be very desirable that the student actually works out this example in total to understand the frequency domain perspective too. If we get an opportunity we might actually illustrate this in more detail in one of the subsequent sessions with that then we shall close the tutorial session today. Thank you very much.