Finding the Edges (Sobel Operator) - Computerphile

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
An image filter is something that takes an image proaches it in some way and outputs an image in response So last time we talked about Kernel convolution And I did Gaussian Blur and mean Blur as a couple of examples of a sort of thing you can convey over an image today We're going to talk a little bit about a different type of Kernel convolution that is the edge detection The process will be using in this video is still Kernel convolution like we used in the last video So if you haven't seen that video you might want to go back just to sort of make sure you absolutely know what's going on Edge Detection is simply a case of trying to find the regions in an image where we have a sharp change in intensity or a Sharp change in color a high value indicates a steep change and a low value indicates a shallow change A Very common operator for doing this is a sobel operator what it is is an approximation to a derivative of an image So there's its separate in the y and the x directions so if we look at the x direction then The gradient of an image in the x direction is equal to this operator here This is our Kernel 3 by 3 which is nice and small, so it's quite quick So we have minus numbers on the left hand side and positive numbers on the right hand side and we're sort of Preserving a little bit the center pixels because we've got these two values here Which is slightly higher waited for these ones? So what we're doing here Essentially is trying to find out the amount of difference between this region of our image and this region of our image here by simply taking one away from the other so we'll pass this just like before will pass this over every pixel of our image and It will give us a response for this location here Bearing in mind of pixels around it so because you've got zero down the middle It's not going to do anything up and down It's just looking yet to see if there is a if you like a vertical line with that view yeah This is symmetrical if vertically okay, so it's not going to do anything to do with Edges But orientated horizontally in the image, so if you've got a bit of image say, but looks a bit like this Let's draw a bit of image. These are my pixels They will not all the same size in the last video we use an image that had 50 in these values and a hundred over here So it was an edge right if this is our image right here is an edge Fairly obviously we can see that, but a computer can't, so if we put our sobel operator here Then what we essentially doing is doing 100 times 1 plus 100 x 2 plus 100 1 plus 50 x minus 1 plus 50 x minus 2 plus 50 x minus one and get gives us an output of 200 which is Reasonable ok and you can imagine if all of these values [are] the same, so if they were all 50 throughout Then you just get 0 so this will provide a big response Where one side is bright or dark of any other side and yes? It's orientated light- left or left [is] right, but we'll get rid of that later at the actual Direction And we'll just so so the if you like the sign of the output it doesn't matter no for this. It doesn't ok now This is only half the battle right so we've only calculated the x direction we want to calculate the y direction You know people already managed to guess what the kernel for this is so g of y? Ok and it's minus 1 minus 2 minus 1 1 to 100 there we go ok so exactly the same But you have all tension ok so this will produce a response of 0 on this edge Because this row is the same as this rope so big in a cancel each other out in normal photographs This is never going to come up. There's going to be something going on right? It's that's interesting Which direction it is we don't know the output of either of these filters? Individually could be negative if one side is much bigger than the other Ok so what we're going to get if we put tourneys into an image. Let's imagine We stretch those negative and positive values to between or 255 and just out put it into a grayscale image Then what we'll have is an image of it's mostly gray with black on one side of each Edge and white on the other side Depending on the orientation of the Edge and the same for the y But what we really want to do is take both of those values and turn them into one How big is this Edge? So when you say about the black and the white that's because you get in a plus and a minus. Yes Yes so if you take if you take let's say a value of minus 1 to plus 1 and you scale if naught to 255 and all the minus values are going to be the blacks and all the positive values of in a bid the whites up above 128 so at the moment what we have is a set of values that represents How strong our gradient is vertically in how strong it is horizontally and what we really want is the total of those things? Ok so just like with a stand and kind of hypotenuse of a triangle We can basically square both these values add them together and square root it and that will give you the general magnitude So I'll write that down and then remove more sending so we've got a value of a gradient in the x-Direction and We've got a value of the gradient in the [y] [direction] and the total gradient the magnitude of a gradient is given by the square root of G x squared plus g y squared ok you'll see but what this does by squaring a man n Square Routine and we also remove a sign have you got an eye on the spot on numberphile? Is this is this why we're doing equation though? What don't put me on there because my maths is it looks good at but it falls down quick So you can see is from if we're squaring them at square rooting them then that removes the sign? So this magnitude is now positive all the time ok and a value of zero will be an absolutely consistent color so this is this is a Function to get rid of the sign and show the time yeah and now if the gradient in the x direction is big But a gradient in the y direction is small, you'll get to moderately large gradient if the gradient both directions is big You'll get a pretty large gradient And so it will basically be how big is the edge at this location? Ok and it will be a black and white image if we scale it up Another interesting thing is because we know the signed Gradient in the x and the y directions we can calculate the angle of the of the edge as well so the orientation of the edge is given by inverse tan Arc tan of Gui over g x so essentially if you take the gradient result from your gy and a great result from of Gx You divide them and then you calculate the inverse tan of that It will give you a value in Radians or degrees that says what orientation in the image is That particular pixel and that can be really useful for finding structures or finding objects and things like that It's unusual for so bell if ever to be run on color ok this is a grayscale operator So obviously you'll need to convert your image. If it's in color to greyscale first so that we're talking just about change in intensity Also sobel is very very it's not with her could you run it on color out of interest? you could Will it give you a wacky output it would get well you'd have three values of Edge Detection for the different color channels on what? entire short that would mean So but yes, you're suppose you could I don't tend to so The other thing is that so bills very It's been be noisy. Okay. We're using a small Kernel and images change a lot so you're going to see a [lot] of edges where it's not actually really an edge in our sense of the word another thing would be if you had a camera with a Fairly high iso settings you had a lot of Grainy noise that's going to produce the thought of Low-level Edge over everything which is not all we want so it's very common to use a gaussian Blur first Over sober , before sobel edge detector just to get rid of the low the high frequency stuff and keep the low frequency big Walls That we're looking for you would do color to greyscale conversion, then you would use a gaussian filter To blow it a small one not too big and then you would use a sober Edge detector And that will produce your nice black and white image where big white bright edges and dark everything else Written some quite cool code which has got loads of comments in so everyone who? Even if you don't code, you should better follow it along There'll be people who complain this in C-sharp. I don't care about those people okay, if you want we can record a nice Why I see Sharp rocks, rant, and you can provide no mushy
Info
Channel: Computerphile
Views: 459,993
Rating: undefined out of 5
Keywords: computers, computerphile, computer, science, computer science, Sobel Operator, university of nottingham, dr mike pound
Id: uihBwtPIBxM
Channel Id: undefined
Length: 7min 46sec (466 seconds)
Published: Wed Nov 04 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.