Hello, and welcome back. I want to give you an example of a very particular and important application of partial differential equations and variation of formulations in image processing. And this will put together, some of the concepts that we have just learned, in a very, very simple fashion. So, what we are going to do is we're going to do histogram modification with partial differential equations. We know how to do histogram modification. We have learned that a few weeks ago. Now I'm going to show you how to do that with partial differential equations. The basic idea is, as we always do with partial differential equations. We want to deform the image towards a certain goal. In particular now, we want to change the contrast. We want to deform the image in such a way that improves the contrast, and we can start thinking about how to do that if we understand partial differential equations. We want to stretch the grey values of the image. Now, how we are going to do that? In this particular case, we're going back into histogram modification. We know how to do that. We learned that. It's just a simple map that we learned a few weeks ago. So here is how you do it with a partial differential equation, as an illustration. Here is the partial differential equation. You're going to deform the image, according to its own pixel value at the given pixel, minus the number of pixels that are great than u. So, you have an image, you're sitting at a certain pixel, and say How am I going to change these pixels? Very simple. You look at your own value, you look at how many values are above you, and you deform yourself according to that, to the difference between both of them. Now why is this doing the histogram modification? Very simple. Remember what we talked. Normally you deform the image equal to your goal. Now, when you get to steady state, these becomes 0. So the image becomes equal the pixel value at, of the image, becomes equal to the number of pixel values, above your own value. And this is exactly, if you go back to your notes on histogram modification, this is exactly histogram equalization. So this is a very interesting way to achieve histogram equalization. Instead of doing a look-up table, as we learned, we just slowly deform the image towards it. Now, you may ask yourself, why do I have to implement a partial differential equation that is computationally more expensive than just doing that look-up table? There's a couple of reasons. One, pedagogically, I'm giving you these as an example of a partial differential equation acheiving something that, we want to achieve like, exactly the condition for histogram equalization. Now, there is another reason. You might stop, this deformation, at any moment. In histogram equalization, you do the math. There is no intermediate solution. If that was too much contrast, then you're in trouble. There is no way, either, no way back either. The original image, or that. Here you can start stretching your histogram. Start moving towards histogram equalization. But you can stop before you finish that, if you are already satisfied with the result. Or even if that result is better than going all the way to histogram equalization. So those are examples of why you might want to do a partial differential equation instead of a lookup table. Now, of course. In the same way that you can do partial ? equations you can try to do this contrast enhancement by solving a variational problem. And here is an example of such a variational problem. Again the art here is for you to start putting terms in the variational problem that will help you to achieve your goal. So here is one term. Remember, what we try is to optimize for this, it's basically to minimize or to maximize, in this case, to minimize this energy. So this is a term that normally you put it in this kind of things, and here I'm assuming the image is between 0 and 1. It has been normalized, so the pixel values are between 0 and 1. You say, you know, I want the image to be nice. I don't want it just to be too far away from the average grey values, and that you achieve by this. On the other hand, you want contrast. So here is the contrast. You don't want the pixel values all to be together. If I don't have this term If I remove this term, the solution of this is a constant value equal to half. All the pixels values are in the middle all together. That's not what I wanted. I want them to be nicely distributed, as expressed here, but I also wanted contrast. And note that we have a minus sign here, and, because I want to encourage Fix the values to get far away. Now, I don't want them to go crazy far away, and that's why you add other types of terms. Now, we have integrals here, which is, where do I count these? Do I count it all around the image? Now, this is also part of your gain? You can say, hey, I'm going to just ask for these contrasts in certain regions of the image. So, you can do the integral only for certain regions of the image. Or you can say, I'm going to ask for this contrast only for certain. Ranges of pixel values. So you can actually become very creative in, designing, this variation of formulation, this same for this direct pd's. Something that you couldn't do when you had to look up table. It was like 1 to 1, from here to here, There's nothing in between. Here, it gives you a lot of flexibility to become very, very creative. So let's see some results of this. Here we have two examples. Contrast enhancement here. Now the interesting thing here, you might notice that basically, this is kind of localized. Every region, kind of move by itself, and there no mixing of the region, and these were achieved by playing with those eastern bound, boundaries, with those integration boundaries, sorry. And making sure that things that have similar pixel values, or in this case is exactly the same piece of values, kind of moves together. So, here's an example of an artificial image to illustrate how these variational formulations can give you contrasting enhansements that preserve the shapes of the image. And here is another example of a natural image. I hope you can appreciate that through the video, that this is a very dark image, and here you have much vivid colors, a much nicer looking image. And this 2 examples are acheived with these PDEs, or variations and formulations. Those are two different, and one gives you some capabilities, the other gives you another capabilities, and playing with the integral limits and playing with the terms inside the integrals, you can start achieving the kind of application that you want for this type of contrast enhancement. So I hope you enjoyed this example. It illustrates both the concept of PD's, that we can almost achieve any condition that we want if we run the PD to steady state, and also it illustrates how we can design variational formulation For an extremely important application that is Contrast Enhancement. Thank you very much. Looking forward to seeing you in the future videos.