Let's see if we can use the histograms then, to basically, estimate a noise. We need to estimate both the shape of the noise, basically the function of the noise. Its Gaussian is uniform, its salt and pepper. And once we estimate that, we need to estimate actually the parameters of that. So, we're going to use the same image that we have seen before. This very simple image. And let's assume for a moment that you manage to go into a region that has only, in the original image, only one type of pixel value. So, one gray value for all the pixels there in the original image. And we see that illustrated here. If we manage to do that, then we go and plot the histogram. The distribution of pixel values for that region. For example, this would be the distribution of the pixel values. Now, when we see these, basically we can immediately guess what kind of noise is here. So, I'm going to ask you, what type of noise was added to this region that would give us this histogram check?" It's very easy to see that basically, this is a Gaussian noise. We are now experts. So, the moment we see the, this, we immediately recognize it. Now, that we know that it's Gaussian, basically we need to estimate the average and the variance and that's very easily done by just computing it from the pixel values. Maybe it was really noise, as here, that was added. If that's the case, we once again use the histogram distribution to basically decide and compute the average and the variance. And with that, we can try to invert it as we're going to discuss in a few minutes. Here, again, we're complete experts now in noise. So, it's very clear that was basically uniform noise added to that region. And once again, we can variously estimate, basically, the region of the noise, where the uniform noise was added. And what's actually the value that was added or the probability of those values. Now, what happens if we don't know it, know, don't know the type of noise? Then, it's very easy. Let's assume that this is the distribution that we observe. So, we can go and try. We try Gaussian and we fit the best possible Gaussian to this distribution. We tried [UNKNOWN] we try gamma, we try uniform. We, we basically go and fit using standard tools for function fitting. We basically fit the best of each one of the distributions. And the one that produces the smallest error, that's the one that we pick. Maybe that was in the original distribution of the noise but hopefully, that's a good enough approximation for that noise. So, this is the way that we can estimate noise if we find a region that has basically uniform original pixel values. If not, we're going to have to work a bit more. So, first of all, people try to do that with relatively small regions. If you have a small region, you have a larger probability that you are picking uniform regions. The problem with small regions is you don't have enough pixel values to estimate your averages and your standard deviations or your balances. For example if I pick a region with only one pixel, I won't be able to estimate any statistics on the noise from from that pixel. If you pick too large of a region, you have the risk that you're basically getting into very distinct pixel values in the original image, two or more. And then, what will happen here? We already know. We actually are going to have histograms that look like this. Basically, have two peaks. If that happens, then there are techniques to try to detect that there is more than one peak in the histogram. And if that happens, basically either you make the region smaller, or you separate the histogram, and then you do an estimate for each one of the regions independently. The other thing to be very careful is that you might need to do this type of estimates in every region in the image. Because nothing guarantees unless you know that in advance the noise is the uniform noise, is the same all around. If it's the same all around, then you can just go and pick a number of regions in the image, do your estimates for example, average all the estimates. So, you compute the mean and standard deviation of variants for each one of the regions. And then you say, hey, my noise is this distribution. But I'm going to average all the means that I computed, I'm going to average all the variances I computed, and that's going to be my estimate. So, these are the standard ways of computing the noise from your image. Now, why is this very useful? As we say in the very beginning, our model here, and I'm going to remove for a second the deterioration part of the image. I'm going to assume there is just noise. We say f of x,y is basically my original image and the noise was added. Now, once I estimate the parameters of my noise and the type of my noise with experience, for example, I know what kinds of filters work well for different types of noise. For example, for Gaussian filtering, we already saw the average filter, basically the mean filter and also the non-local means. That if we manage to cut your regions, that if there uniform or similar across the image, then averaging is great. If I have a pixel distribution, let's say, around zero, averaging would basically almost get rid of, of that noise. The same for uniform noise. So, depending on the noise type, we basically can use different filters. Salt and pepper noise. Medium filter is a great filter for salt and pepper noise. We know that salt and pepper are kind of isolated. We actually saw an example in the previous week. They are isolated points and, basically, when we compute the medium, we just basically eliminate those isolated points and end up replacing them by the pixel values around them. So, knowing the type of noise help us to basically design and decide which type of filters, which types of operations, are we going to do to be able to recover the original image from the basically decorated from the noisy image. We're going to see in a few weeks, when we go to more advanced techniques, that also knowing the type of noise can basically enter the design of the algorithm in a completely different fashion. For example, if we are going to basically know that we are dealing with Gaussian noise, remember, we're tying to get an estimate, F, that is very similar, or as similar as possible to the original one. If we know that the noise is Gaussian, we're also going to basically constrain the, this is g, I apologize for that, this is g. So, for a Gaussian noise, the error between these two has to behave as Gaussian noise, okay? So, this is my estimate, my denoise image. This is my noisy image, what I observe, this should be as close as possible to the original image. Let's assume it's identical to the original image. Then, the difference between these two should have a Gaussian distribution. So, I expect my noise to have a Gaussian distribution, and we are going to see that we can impose that by basically imposing some properties on the mean square error, basically the error squared, or the difference between my observe and my estimated image. Now, if my, basically, noise was estimated to be uniform, then I'm going to have to impose here a different error. For example, we are going to see that if the nose, the noise, sorry, is exponential, what we are going to try to do is my estimate minus my observation, but without this square. That's why we're going to try to measure and make sure that that basically behaves in the way I expect from an exponential noise. So, once again, the key concept is if you know denoise, then you know that your estimate minus your observation has to behave like that noise. So, if I, no, my noise is uniform and I compute my estimate and my estimate. minus the observation gives me a Gaussian distribution, I say, okay, I made two possibile mistakes here, Either I estimated wrong my noise or I basically did the wrong denoising because I didn't get back what I assume was the type of noise. And this is how you basically you put back your noise estimates into your design of image restoration techniques. Once again, something that we didn't see in image enhancement but we actually can see an image restoration. We push it back to design off the filter or to basically select parameters of the filter. Of course, if I have more noise, more salt and pepper noise, I might need to decide on the size of my medium filter window in a different fashion than if I have less noise. So, this is how you basically, once again, put, put back that information into the design. We have talked a lot about this, but remember, the original model have here the h function, the degradation function. So, let's just spend, in the next video, sometime discussing it. Thank you very much.