Now we’re going to move on to the next step in order to implement our blurring tool, or our blurring filter. So the first thing we need to do is we need to extend this idea of convolution to two dimensions. So, the first modification we did so we looked at convolution at it’s most basic definition where it’s of a continuous variable filtered by another continuous variable, so we discretize it by turning it into a sum, and so we already have discrete signals because we’re working in matlab. Now, when we do two-dimensional convolution notice we now have two dummy variables. So before tau or k, now we have two dummy variables tau 1 and tau 2, or n1 and n2,. And so it’s basically what you would expect when you have one deconvolution you’re going from minus infinity to infinity along the one dimension that’s the independent variable, so you can think of that as time, and in two dimensions we go from minus infinity to infinity for both independent variables so that the x and y, or in other words the two spatial dimensions of the image. So now that we’ve extended our idea of convolution to two dimensions let’s think about how we could implement a blur using a Gaussian. So a Gaussian is basically a spread, right, there’s a middle point and then it spreads out over a radius in a circular fashion. So, my question to you is how can we build a two-dimensional Gaussian image that we can use as a filter on the original image, so that we can do a convolution between those two? So, I’m going to give you a minute to think about that, please pause this video and come back when you have figured it out. Ok, so, I have in fact actually been showing you the solution to this for multiple videos now. So I’ve created a function called my Gaussian, and it takes in two parameters n and Sigma. So n is going to be the size of the square, so the output is going to be an n x n matrix, and Sigma is going to represent the standard deviation of the Gaussian as is convention when we’re talking about Gaussians. So we have the output called H, now I only need the value of two Sigma squared ever in this equation, so I’m just going to calculate 2 sigma squared at the beginning so I don’t have to do that on every iteration of the loop. I’m going to initialize h to be an n x n matrix of all zeros, and then I’m going to use a for loop to assign every value of age. So, I going from 1 to n, and j going from one to n. Now I assign x to equal i minus n/2, and y to equal j minus n/2. Why is that? Because I want the center point of H, so that would be H of n over 2 over 2, to to be the highest point of the Gaussian, and so that’s when x is equal to 0 and y is equal to 0, and the exponent of 0 is 1. So that would be the maximum value of the Gaussian and then every point from there would be smaller, right, so when I is n/2 x=0, when j is n/2 y=0. And the formula for a Gaussian is x squared plus y squared over 2 sigma squared, and then you take the exponent of the negative of that. Ok, so, what does this actually give us? So let’s use the my Gaussian function, say n is a hundred and Sigma is 10. Now let’s imshow the H that I got. Ok, so you can see so remember that white is the maximum value 1, and black is the minimum value zero, and so this is a Gaussian what a Gaussian looks like when you plot it on an image. So what would I do if I wanted to see more white? I could increase Sigma, right? So, let’s say Sigma is 25, imshow H, and so you see the radius of the white part has increased.
Subscribe on YouTube!
Most Popular Courses
-
The Complete Ethical Hacking Course Bundle!
Rated 4.62 out of 5
$780.00Original price was: $780.00.$19.99Current price is: $19.99. -
The Complete Linux Administration Course Bundle!
Rated 4.94 out of 5
$780.00Original price was: $780.00.$19.99Current price is: $19.99. -
26 Course Forever Bundle!
Rated 5.00 out of 5
$2,730.00Original price was: $2,730.00.$39.99Current price is: $39.99. -
The Complete MATLAB 7 Course Bundle!
Rated 4.60 out of 5
$585.00Original price was: $585.00.$29.99Current price is: $29.99. -
The Learn to Code 8 Course Bundle!
Rated 5.00 out of 5
$780.00Original price was: $780.00.$19.99Current price is: $19.99. -
The Complete Python 3 Course: Beginner to Advanced!
Rated 5.00 out of 5
$199.99Original price was: $199.99.$9.99Current price is: $9.99. -
The Ermin Kreponic Course Bundle!
Rated 4.54 out of 5
$1,755.00Original price was: $1,755.00.$39.99Current price is: $39.99. -
The Complete Digital Marketing Course Bundle!
$780.00Original price was: $780.00.$19.99Current price is: $19.99. -
Certified Ethical Hacker Boot Camp!
$195.00Original price was: $195.00.$9.99Current price is: $9.99. -
Linux System Administration for Beginners!
Rated 5.00 out of 5
$199.99Original price was: $199.99.$9.99Current price is: $9.99.