 Hello and welcome to lecture number 2. We have titled this lecture as the zoom in and zoom out features from wavelet transform. And we are going to continue where we left in the first lecture. We saw in the last lecture that wavelet transform essentially decomposes signal into two separate series. A single series to represent the approximations that would lead us to scaling function also popularly known as the father function. And the double series to represent the details that would lead us to the wavelet function or the mother wavelet. Then we also looked at the fact as to what is the speciality of wavelet transform. And we realized that scaling translation and dilation they together are the hallmarks of wavelet transform. And together they lead us to multi resolution analysis or popularly also known as MRA. We also saw the nested subsets and we wanted to move up the ladder. We saw one peculiar way in which multi resolution analysis can be implemented. And it is a two band filter bank structure. And then we focused only on the analysis part of it. And then we realized that this kind of structure would help us move down the ladder. And then we post this question if at all I want to move up the ladder. If at all I want to go on adding up the details then what kind of framework will help me achieve that will help me do that. And in this particular lecture we are going to achieve the same we are going to first of all define the framework. Once we are done with defining the framework will then move on and solve one problem make our hands dirty to really understand the nitty gritties of the entire procedure. So, let us start that process we have realized that the whole MRA multi resolution analysis is in a way based on the underlying nested subsets. And we can really bring out the essence of this through two mathematical equations. First the equation of scaling function which can be written as phi of t to be equal to summation over k h of k phi of twice t minus k. And to normalize this let us add this factor of square root of 2. Now, this equation is very very special if I take this factor down then we can clearly understand that this is indeed phi of 1 t and 1 essentially indicates 2 to the power 0. And then I can say this belongs to subspace v 0. Similarly, I can also take this factor down and then we will realize that this is phi of twice t minus k. And this essentially means 2 to the power 1 and this belongs to v of 1. So, this feeling of nested subsets is very nicely captured in this beautiful scaling function scaling equation. This holds true for the other type of function as well which is the wavelet function. So, we can write down wavelet function like this psi of t again some door k values g of k phi of twice t minus k. And I can once again sense that this is simply psi of 1 t 2 to the power 0. And then I can say this function belongs to w 0 subspace. And this function once again belongs to v of 1 because I have phi of twice t minus k and 2 to the power 1. So, this still belongs to v of 1. And by looking at these two mathematical equations, now we can once again sense the same equation that we wrote towards the end of last lecture that v of j would indeed be equal to v of j minus 1 orthogonally added with w of j minus 1. And this once again leads us to the beautiful ladder that we have been talking about. Once we realize that v of j and w of j together can take me to v of j plus 1. And if I have w of j plus 1 then together they can take me to v of j plus 2 and this continues. And so once again we can write down the same nested subsets v of minus 2 v of minus 1 v of 0 and this would continue. And last time we pose this question that if I start my analysis, let us say in v of 0 then how I can move in the upward direction. So, that I will keep adding up different details and by virtue of doing that I can go really close to the actual signal or the actual function under consideration for analysis. How to achieve that? Now, let us write down the framework for the same. Let us say I have some function and I have the corresponding projections of that function. So, how this entire assembly will help me move in the upward direction? Let us say I have function and I am representing that function. So, that it belongs to some subspace v of j and I can do this with a scale value of 1 upon 2 to the power of z. Obviously, in order to be able to span this v of j subspace I will require the basis function and since we are talking about v of j spaces obviously the basis function is going to be phi of t. So, the basis function that we will make use of to span these spaces will be this for all different values of k. Here k is the translational parameter and 2 to the power j by 2 this is the normalizing factor. This is for normalization and because of this normalizing factor my orthogonal basis will get converted into orthonormal basis. Now, I can very well write down f j of x in terms of the basis function and the formula would be summation over k because k is my translational factor alpha j k 2 to the power j by 2 phi 2 to the power j x minus k and we can very well calculate alpha values like this. We have purposely taken the function to be a function of variable x just to point out that this is just some variable it need not be always f of t or x of t. So, we are looking at f dot to make it more generic. So, this is how we can span v j subspaces and correspondingly find out the approximation values which are the alpha values. Let us also write down the framework for w subspaces and let us say same function. Now, I am going to call that function of g of j of x it belongs to subspace w j and will make use of same scale which is 1 upon 2 to the power j and in order to be able to span these subspaces I will require the basis which will be now psi and k is once again the translation factor translation parameters. So, to say and I can write down similar equations once again g j of x be equal to summation over k beta j k 2 to the power j by 2 psi j x minus k. And we can very well calculate the these beta values with the similar formula. So, this is how we can calculate beta values and since we are talking about w subspaces these beta values will give us the details which are very much required to actually move from one subspace to another subspace. Now, using this framework how can we actually move up the ladder that is the next question and in order to be able to answer this question let us solve one simple problem. Let us take a sample signal a sample function and we will apply the framework that we have designed to that signal to really understand how we can actually move from one subspace to another keep on adding the details and really move in upward direction in order to be able to then achieve l 2 r norm. Let us take a simple signal let us say f of x is defined as x for values of x between 0 and 3 and let us say it is 0 elsewhere. We can also think of keeping this interval open by omitting this and if we plot this signal it would look like this. So, I have my x axis this is my f of x let us say this is a simple looking signal and we want to analyze this signal using the framework that we have written down. Let us write down the objectives that we really want to achieve we will first of all find out f 0 of x which belongs to v 0. Then we will find out g 0 of x which belongs to w 0 and then we will add these two orthogonally to produce f 1 of x which would belong to v of 1 and this is definitely moving up the ladder from v 0 and w 0 we are able to generate v 1 correspondingly we can also find out g 1 that belongs to w 1 and add v 1 with w 1 to produce v 2 and so on. So, it is very important to understand the process first and so we can restrict our exercise to this and at the end of it what we really want to prove is v 0 plus w 0 gives us v 1 this is what we really want to achieve. So, we have this objective in our mind. Now, let us begin with the first task and that first task is we want to find out f 0 of x which belongs to v 0 that essentially indicates j value is 0. The scale over here is going to be 1 upon 2 to the power j which is 1 upon 2 to the power 0 which is 1 this essentially indicates that my window of analysis is of length 1 and then this is my basis function that I will make use of and if I plug in j is equal to 0 then this would reduce to this will go to 1 and I will be left with x minus k. So, this is my basis function that I am going to make use of in order to be able to find out projection of f on v 0. So, let us do that recall the formula and I can very well write f 0 of x will be equal to summation over k. Now, if you remember our signal the signal exists between 0 and 3 and now my analysis window is of length 1. So, as a result of that I will have to translate my basis function twice. So, the first window of analysis will be from 0 to 1 then 1 to 2 and then 2 to 3 and I will have to carry out the analysis in 3 different steps. So, my summation of k will run from 0 to 2 then I have alpha j k j is 0. So, I would write alpha 0 k 2 to the power j by 2 goes to 1 and then we have already calculated that this will be x minus k. So, it boils down to calculating the values of alpha let us begin with the first value when k is equal to 0. So, let us focus on alpha 0 0 it will be integration from minus infinity to plus infinity f 0 of x into 2 to the power j by 2 and now we will plug in j is equal to 0 and k is also equal to 0. We also understand that the moment you say k is equal to 0 we are talking about phi of x that is the version which is not translated. We will have to here define which phi of x and which psi of x we are going to make use of and this is one another beautiful property of wavelet transform as per as Fourier transform is concern or Z transform is concern the basis is fixed. However, the beauty associated with wavelet transform is you have choice you can not only select the scaling function and the wavelet function from whatever is available if you are smart enough you can also think of designing your own scaling function and wavelet function. We are going to take up this particular topic in the next lecture. However, for the time being let us restrict to har scaling function and wavelet function. So, as far as har scaling and wavelet functions are concerned we typically know how they actually look. So, we will use har scaling and wavelet function and in case of har we know since you are using x phi of x looks like this and we also know psi of x looks like this. So, we will make use of these 2 functions to actually solve the problem at our hand. So, this integration bounds limits are now restricted from 0 to 1 and between 0 and 1 we know the nature of our signal f of x it is going to be x between 0 and 3. So, between 0 and 1 it will be x. So, I can very well write x over here 2 to the power j by 2 this will go to 1 I do not really have to worry about it. Now, between 0 and 1 when k is equal to 0 I am talking about phi of x because this 2 to the power j is also going to go to 1 and between 0 and 1 this function is going to take a value of 1 and as a result of that I can plug 1 for all of this and then d of x and this will be x square by 2 that leads us to half. So, alpha 0 0 is half correspondingly let us try and find out the other values of alpha. Let us calculate alpha 0 1 now my integration would range from 1 to 2 between 1 and 2 my f of x is once again x 2 to the power j by 2 is going to go to 1 and I have phi of x minus 1 d x. Now, how this function looks if my phi of x looks like this then obviously this is how my phi of x minus 1 would look. So, it will have value of 1 between 1 and 2 as simple as that. So, I can very well plug 1 over here and this will be x square by 2 for limits 1 and 2 and this boils down to. So, alpha 0 1 comes out to be 3 by 2 and then correspondingly we can calculate alpha 0 2 which will be equal to integration between 2 and 3 x phi of x minus 2 would be 1 between 2 and 3 into d x and this would come out to be phi by 2. What does this indicate? These alpha values are nothing else, but the approximate values of this function that we started off with. We have already seen that f 0 of x is going to be a projection of function in subspace v 0 and the formula is this and so it goes without saying that I can now very well write f 0 of x in terms of all the alpha values that we have calculated and I can write f 0 of x is equal to half into phi of x plus 3 by 2 into phi of x minus 1 plus phi by 2 into phi of x minus 2. So, this is how I can very well find out the projections of signal f in subspace v of 0 and if we try and plot it, it will look like this. So, this is my alpha 0 0, this is my alpha 0 1 and this is my alpha 0 3. So, these are neat approximations of the underlying signal. Now, the next task and the next task is to find out the projections of signal in w 0 and we have already written down that we are going to call these projections as g 0 of x that would belong to w 0. The scale will be once again 1 as j is equal to 0 and the basis function will be will once again make use of the Haar wavelet function and since j is equal to 0, this will reduce to a very simple form k is once again the translation parameter and now I can write down that g 0 of x will be summation for k values from 0 to 2 and then beta j 0 k values into psi of x minus k and the next important task is to find out all the beta values and since these are the projections in w 0 subspace, these beta values will now give the details associated with the signal. So, let us calculate the beta values now. Using the formula, we can very well say beta 0 0 that means j is equal to 0 and k is also equal to 0 integration from minus infinity to plus infinity g 0 of x into now k is 0. So, we are talking about psi of x and how this function actually looks we have already seen the nature. We are going to make use of Haar psi of x and so it is of this particular nature and as a result of that in order to be able to solve this integration we will have to split it into two parts. So, for k value of 0, the integration would exist only between 0 and 1 g 0 of x is x again and then we have psi of x into d x and due to the very nature of psi of x, we will split this integration into two parts from 0 to half x into now between 0 and half psi of x takes the value of 1 and between half and 1 it takes the value of minus 1. So, we will plug in these values x into 1 into d x and then plus between half and 1 x into minus 1 into d x and this will result into x square by 2 between 0 and half minus I will bring this minus sign out x square by 2 between half and 1 and thus beta 0 0 result into 1 by 8 minus 1 by 2 plus 1 by 8 this would result into minus 1 by 4. So, this is the first beta factor that we have obtained beta 0 0. Let us work on the next one that is beta 0 1 j is 0 and k is equal to 1 and the integration is going to last between 1 and 2 g 0 of x will be x again into psi of x minus 1 into d x and how would this look? We know if psi of x looks like this and psi of x minus 1 will be the translated version of the same this will exist between 1 and 2. So, this is how psi of x minus 1 is going to look and will split the integration again between 1 and 3 by 2 x into 1 into d x minus between 3 by 2 to 2 x into 1 into d x. We can solve this and confirm that this comes out to be minus 1 by 4 as well. Correspondingly, we can also calculate beta 0 2 j is 0 k is equal to 2 and I will leave it to the viewers to verify that beta 0 2 also comes out to be minus 1 by 4. So, all the 3 beta values they have the same value of minus 1 by 4 and what does it indicate? So, we will try and analyze what it actually depicts, but before that once we have calculated all the beta values now it is time to write down g 0 of x in terms of its corresponding beta values because then I can very well write this will be beta 0 0 psi of x plus beta 0 1 psi of x minus 1 plus beta 0 2 psi of x minus 2 and we can think of plotting this g 0 of x on top of the original signal and what projection it would have in v 0 that we have already plotted. So, the green lines they indicate the corresponding representation or projection of signal f of x in v 0. Now, we will draw its corresponding projection in w 0 and it is going to look like this because all my beta values are negative the first half is going to be negative and this will be of value minus 1 by 4 and this is of value plus 1 by 4. So, these are the projections in w 0 subspace and these are my projections in v 0 subspace. Now, if you recall our objective we wanted to orthogonally add our findings in v 0 and w 0 to then achieve the projection in v of 1. So, let us see if we can really do that now if I want to find out the projections of the same signal in v 1 I can write down f 1 of x which belongs to v 1. Now, you can clearly see and sense that j is equal to 1 and we are actually moving up the ladder. So, my scale is now going to change the scale is going to be now 1 upon 2 to the power j which will be equal to half. So, the scale will get reduced to half and what kind of basis function will have to make use of 2 to the power j by 2 and then phi 2 to the power j x minus k k still remains the translation parameter and since j is equal to 1 in our case this would reduce to square root of 2 into phi twice x minus k. So, this will be the basis function that will make use of correspondingly I can also write down that my f 1 of x will run over different values of k and how many values of k our original signal lasted from 0 to 3. Now, my window of analysis is half and so I will obviously need 6 different windows in order to be able to span the entire thing and so my k value is now going to run from k is equal to 0 to 5. I will have to calculate alpha 1 comma k because I am in v 1 subspace. So, j is equal to 1 and then square root of 2 into phi of twice x minus k. So, this is how my f 1 of x the projection of my original signal on subspace v 1 is going to look and what we really are interested in at this point in time is to really see if I can really match all the alpha values that I will obtain numerically to the alpha values that I can obtain by adding the alpha values in v 0 with beta values in w 0. And if I can match up these values then I would say oh this is definitely working and I can really move up the ladder. So, let us calculate the alpha 1 k values and let us begin with alpha 1 0 when k is equal to 0 and we know the formula minus infinity to plus infinity and then you have f 1 of x into 2 to the power j by 2 phi of and we are discussing a very special case when j is equal to 1 and k is equal to 0. So, obviously I am talking about the first interval that would last from 0 to half between 0 and half f 1 of x will be equal to x 2 to the power j by 2 would go to square root of 2 and then I am talking about phi of twice x k is 0. Now, between 0 and half what value phi of twice x is going to take? We already know that if my phi of x looks like this then phi of twice x is going to be the Schringt version of it and let us not worry about the area under the curve at this point in time. Let us worry about the nature and if we can actually preserve the entire energy or not. So, if this is how my phi of twice x is going to look then between 0 and half phi of twice x is going to take a value of 1 and then I can bring out square root of 2 outside and this will be integration from 0 to half x into 1 into dx and so this will be equal to square root of 2 into x square by 2 between 0 and half and this will lead us to square root of 2 into 1 upon 8 and probably I can write down a convenient form of the same and I can say this will be 1 upon 4 square root of 2 essentially the same thing. So, this is how my alpha 1 0 is going to look. Now, let us try and tally this alpha value with the geometrical representation that we have over here. Now, in order to be able to calculate alpha 1 0 what we will have to do is to concentrate on the portion between 0 and half and correspondingly I add the alpha 0 0 with beta 0 0 well alpha 0 0 value is known and beta 0 0 value is also known. So, what we are saying is I can calculate alpha 1 0 which will be equal to alpha 0 0 minus. So, I am talking about only the first half of alpha 0 0 plus beta 0 0 minus that is what we are saying and we already know these values. So, as far as alpha 0 0 minus is concerned it is half and as far as beta 0 0 is concerned it is minus 1 by 4. So, this will eventually lead us to 1 by 4 the value that we are getting after solving this integration is 1 by 4 square root of 2, but we do not really have to worry about this square root of 2 because this is going to get cancelled out. You remember we have already done the normalization of our basis functions and. So, our basis is not just orthogonal it is also orthonormal and as a result of that when I am going to plug in this alpha 1 0 in the formula for f 1 of x this square root of 2 is going to get cancelled out and then this will match up with the value that we have obtained graphically. Let us see that formula what I am saying is I can very well write down f 1 of x to be equal to summation for k is equal to 0 to 5 and then alpha 1 k values square root of 2 into phi of twice x minus k. So, if you consider the first term in this summation when k is equal to 0 that is going to be alpha 1 0 into square root of 2 into phi of twice x and alpha 1 0 that we have calculated is 1 over 4 square root of 2 into square root of 2 into phi of twice x. Obviously, we have the rest of the series, but I am just focusing on the first element and. So, this square root of 2 will get cancelled with this square root of 2 and will be left with 1 by 4 and this definitely matches with what we have solved graphically. This is indeed 1 by 4 likewise we can go on finding out the rest of the values of alpha and convince that it indeed matches up. The alpha values in v 1 would look like this 1 by 4, alpha 1 1 will be 3 by 4, alpha 1 2 will be 5 by 4, alpha 1 3 will be 7 by 4, alpha 1 4 will be 9 by 4 and alpha 1 5 will be 11 by 4 and if we want to plot these values again on the same graph. Now, it is going to be interesting because I am starting with 1 by 4, 3 by 4, 5 by 4, 7 by 4, 9 by 4 and 11 by 4 and you will agree that. So, these are my projections in v 1 and it is very easy to see that the approximations that are obtained in v 1 are much better compared to the approximations those were obtained in v 0. We are able to add some details in v 0 from w 0 and then finally achieve the projection in v 1. So, this is the mechanism using which we can not only think of moving up the ladder, but we can also think of making the choice of the scale we can think of also making the choice of the translation parameter and then specifically zoom on to a particular point in my signal or function which is of greater importance to really find out something interesting to convince more on this point. We are going to see another example, we are going to build one function this function is very specifically designed. We are going to understand the beauty associated with this function and then we will see what kind of things it will have when we will try and analyze this function using the wavelet toolbox in MATLAB. So, if you look at this slide will try and find out a hidden jump discontinuity from a particular function. Let us consider this function g of t and looks very interesting because we can very clearly see that at half there is a clear discontinuity. Please carefully notice that t is only less than half and then over here it is less than or equal to half. So, at half there is a clear discontinuity that we can notice. However, such kind of discontinuities are easier to detect we will complicate the matters slightly. What we will do is we will integrate that signal g of t and by virtue of doing the integration we know that integration essentially is a low pass filtering operation and we will smooth out that signal. So, the discontinuity is now not very much visible. However, there is still a cusp jump at t is equal to 0.5 and now by virtue of integrating the original signal g of t this is how the new signal h of t would look. We will complicate the matters further more and we will integrate h of t as well. We will integrate h of t and finally, we will generate f of t and now this function f of t appears absolutely smooth to our eye and we may not be able to perceive the discontinuity at point t is equal to half. We will pose this challenging problem to our wavelet tool box in MATLAB and we will see if the tool box will be able to really find out this discontinuity at t is equal to 0.5. So, this is a simple MATLAB program that is written. This is how we have declared the time stamps t 0 is equal to 0, t 1 is half and we know this is the point where there is discontinuity and t 2 is equal to 1. The level of analysis that has been selected is 9 and this is selected out of trial and error and honestly speaking there is no thumb rule that says to what level one should go and after doing analysis to what level one should stop. However, there is a slight mention of this in the book written by Ingrid Dobas which says that if you lose more than 70 percent of the total energy in your signal then you should actually stop doing further analysis. Based on that we have selected the level to be 9 and this is how the original signal t would look. You can clearly see that for a given time stamps the original signal g would look like this. It was t only when t was less than t 1 and t 1 is 0.5. It was t minus 1 between all the values of t which are greater than t 1. So, between t 1 and t 2 0.5 and 1 and correspondingly we have generated signals h and f. Just a gentle reminder that g original signal had a discontinuity at 0.5. We did the integration of that into h and again integrated h to finally get f. So, first of all let us plot these signals and let us see the nature of these signals and as expected this is my original signal. We can clearly see the discontinuity at 0.5. Then this is the cusp discontinuity after doing the integration and after doing the integration of this signal that is double integration of the first signal there is no visible discontinuity at 0.5. So, this is fairly difficult signal now. Let us save this signal. So, I am going to save f and let us save this signal as test underscore s i g and now we can clearly see that there is a mat file called as test underscore s i g dot mat. We will invoke the wavelet toolbox in mat lab and we will select the 1 d wavelet. We will load the signal that we have generated which is test underscore signal. So, this is how the signal actually looks and now I have freedom of selecting any of these wavelet mothers. Let us say we select dobash 3 for a level of 9 and we want to carry out the analysis and you will see a strange thing. At d 1 you can clearly see that we are able to detect the discontinuity at 0.5 and as we start losing out the information the crispness of the detection of the discontinuity eventually goes away. Since we have done the entire analysis using Har wavelets, let us also work out that exercise. So, I am going to select dobash 1 which is nothing but the first member of dobash family and it is Har. And if we do this analysis again then now you can clearly see that we are once again able to detect the discontinuity, but with lesser efficiency. So, there is point in selecting the mother wavelet. However, what is striking about this wavelet analysis is even though we smooth out the function by doing double integration and now to the naked eye I cannot sense the discontinuity, wavelet transform can still find out such underlying discontinuities. And hence it makes lot of sense to invoke the zoom in and zoom out properties of wavelet transform. With this we will conclude this lecture and we will continue working on how we can go about generating the scaling function coefficients and wavelet function coefficients in the next lecture. Thank you.