DIP Lecture 10: Edge detection

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay so today I want to talk about detection in a little bit more detail right so so far we've kind of danced around this idea we talked about it a little bit for sure so in addition to kind of like this low-level image processing something we're talking about so far things like geometric operations changing the shape of the image or history operations changing the colors of all pixels of an image not unless we're talking about a little more on the road image understanding right so if I take an image how can I kind of try to see what's going on an image in the same way that a human would right and so this is kind of like the first step going through the low-level stuff to the median level stuff we've talked about before and so we talked about certain spatial 2d filters that do edge detection so these should be familiar from our previous lectures and our homeworks right so we talked about the Sobel operators so these guys are going to detect edges that are going in the horizontal and vertical directions respectively and we also talked about you know in what homework you you started thinking about what would we do if we wanted to design a Sobel like operator to detect edges of different angles right so we talked about for example what you might have done would be something like this right where maybe we wanted to detect edges that are going at a 45 degree angle you know we could kind of make it a filter like this and you can imagine that you could make filters that are larger to detect edges at finer angles right so if I gave you a five by five filter maybe I could detect angles that were like at thirty or sixty degrees like that we're gonna talk about that a little bit here so I want to come back to first of all what is the you know underlying motivation for why filters like this work okay and so that means that we can think about what is an edge in an image right so if I have an ideal edge right that means that I have some sort of a transition from one intensity together intensity so if this is kind of say looking at edges in the x-direction and this is intensity we have this kind of ideal step - okay in practice we may not have edges that are quite like that and sue might have a looks like a ramp edge where maybe I have one intensity and then I kind of slowly ramp up to the other intensity okay and so we can think about okay well what would the derivative of this function look like right so in here if we take the first derivative well like we know from signals the first derivative of the step function is just a double right here since this guy is more slow this has basically got a slope of zero here sort of zero here it's a little some positive constant here so this beam first row of this guy's gonna look something like this and so this suggests that places where the first derivative is really large can be used to detect the presence of edges right we've kind of already started to think about that concept bool but we're going to velop that more a little bit today the second derivative right so I mean here we haven't really defined what the derivative of a delta function is we could think about the second derivative over on the right-hand side so here if I was to look for places where the first derivative was large what I would get would be basically a you know a whole series of responses right across this ramp edge right whereas really what I want to do is I want to isolate the middle point of that edge for example and so the second derivative could help me do that the second derivative this guy again I'm going to have a delta function like this and Delta function like that right so I'm going to have a place where there's a big positive number and a big negative number and what I could do is I could look for basically the middle point of where the sign changes right and so kind of the intuition is that you know the first derivative of what I could do is look for big absolute values and the second derivative I could look for sign changes in the second derivative which are also sometimes called zero crossings okay so those are both different ways of looking at the problem and there are some issues right with taking derivatives and images so one issue is that in practice edges are not going to look like this in real life right in real life maybe I'll have something that is not an actual ramp but is more like something that is kind of like a noisy you know increase from one grade level to the every level okay so the problem with taking if I call this FX the problem taking derivatives is that taking the derivative is going amplify the noise so the Apple the noise is going to suddenly become a lot more or when I take the derivative so if I take for example here I'm going to have a low value in general a low value in general here and I'm gonna have an increasing derivative some I drew it was probably looks something like this and if I were to take another derivative I would have even more noise so maybe I would have something looks like looks like this right I have a positive derivative this way it flattens out that's where the zero crossing is and then I have a negative derivative this way okay so the key issue I'm trying ulster here is that noise is amplified and that can sometimes make it harder to find the places where the first derivative is big or places where the second derivative crosses the 0 axis zero and so one solution is to kind of low-pass filter the image first to avoid the noise right and in some sense that's exactly what these servo filters are doing right because if I think about this guy right this guy looks like a filter that looks like it's a difference operator in one direction and a smoothing operator in the other direction so really what the so go filter is doing is taking the difference in one way to find the edges in this direction and smoothing the image in this way to a guru snores and since we know that these two operators you know smoothing and the well since these are both like successive linear operators I can apply them in any order so I can think about that says smoothing the image first and then find Direction finding edges in the other direction as it quotes just a more simple edge operator so let me say though more precisely so really what I want to emphasize today is the edge detection is related fundamentally to derivatives okay so edge detection is fundamentally related to the gradient of an image which is nothing more than the x and y derivatives right so sometimes if you remember calculus you will see this notation like the dull or the derivative of F or the gradient of F which is the same thing as you know putting the derivatives of a function inside a vector and then sometimes they make all this like G X dy and so there are different ways of approximating these derivatives right and so the easiest one is to say okay the difference in the X Direction is like saying okay I'm going to take a little step in X keep Y the same and subtract from where I am now and the derivative is why they're actually going to be the same kind of thing this is only one such approximation the derivative that is a handy one okay and the idea is that just like with a function this 2d vector points in the direction of the highest rate of change of the function that's what we that's what we read about derivatives in calculus was that they showed us where was the function changing the most and so if I were to think about an image and thinking about where is the gradient it would look something like this so I could say okay my image may have an edge that goes from dark to light like this and if I were to Center my left on this pixel and I were to ask okay so where does the derivative point well the gradient is going to point basically so if I have dark values going light values then the gradient will point in the direction perpendicular to the edge right because it's saying that if I start here which direction should I go to change my intensity the fastest right and naturally to do is step across the edge so basically the gradient points perpendicular to the edge and the edge direction is more like this okay now like we said often we want to look at for example the magnitude of the first derivative right so what is the nines of the first derivative it is the length of that vector right so I can read it like this and the angle of the gradient should tell us something about the angle of the edge and so the angle which I'm going to call alpha here is basically the inverse tangent of this vector and so let's take a look at you know what that gives us for a given interview okay so here in matlab i have image that's good okay so this image has lots of edges in it and I'm gonna turn into a grayscale image okay so the first thing I can do is I can make some simple gradient operators right and so I could say okay my gradient operator in the x-direction is going to say take a look at the difference between me and my neighbor in one direction and the so here I'm going to kind of be thinking about I guess Cartesian coordinates X being the usual the usual direction of X and then Y I'm going to make the opposite and that I can filter my image with these guys or which order this goes make sure this is the right size no I hit the wrong way because I want the image to be filtered to have the same size as the original okay and then my Gy is gonna be the filter of the sky and now I should be able to for example look at the gradient and so here what I'm going to do is going to look at the magnitude the gradient and let's see what that looks like so you're kind of hard to see so what I'm going to do is I'm going to make a different color map see if that helps okay so here I'm going to see is the original image and the edges and so kind of I'm going to move this over a little bit so kind of what we're looking at is that blue means not much edge action and then as I increase you know up your red that's where the strong edges are and you can see that you know most of the image is blue meaning there's not a lot of adjectives 'ti but if I were to zoom in on places where there are strong left-to-right lines I should see some action right so for example if i zoom in here this is where I start to get some pixels that are in the yellows and greens and reds right and so if I want to threshold this image to say okay show me all the edges that are greater than say 80 I would hope to see something that was a little bit more edgy so I could say something like even show the places where the gradient of X is greater than 80 so here you know it's not that exciting maybe I should turn down my threshold a little bit showing places where that's greater than 40 in this thing so here I start to kind of pick out some edges it's kind of hard to I think because my image is bigger than this screen and kind of subsampling so better to kind of zoom in on this here you can see I'm starting to pick up some of these edges along the left-hand side so one things we're going to talk about in the next lecture actually has to do with you know how would I connect these edges up together say I want to find the outline of this box we'll talk about in the next lecture things like edge linking to be able to draw boundaries around things so hold that thought until we get to the next lecture and the same way I should be able to do the gradient of Y so if I were to look at the gray into Y just looking at the absolute value of it and color going up jumped again so now this guy should basically see if I can make this a little better and bill handle okay so this guy should basically have strong edges where there are you know a lot of up-and-down activity and again you can start to see that in these regions right a little bit here for example so this point you probably asking yourself well these edges to stand out a little bit more right and that's a good point so what can we do to make this look a little better well one thing is that my edge operator is pretty crude right so what if instead of using the simple you know 1-1 operators I used what if I use a better edge operator so here instead I'm going to say okay what if my HX is so let's recall what I had instead of using this what I'm going to use is my Sobel operator and then my hy is going to be just that thing transpose and now I'm going to rebuild my gradients and now I'm going to look at these guys again let's put these looks like my side okay clearly I did something wrong there it was okay so what happened there I guess because I didn't do the absolute value like this yes better okay I feel better about this so let me do another guy here okay so now that happened stronger exit edges in life that's right so fired one for example down over here I would see that you know there's a little bit more you know clear activity for example telling me there's a left to right there's a vertical edge right and the same way here this guy is more strongly picking up this up-and-down edge horizontal edge right so it's a little more hopeful if i refresh on this guy I would get what I wanted and the same way I've been kind of implicitly using this apps right so abs is basically the same thing as well let's make this magnitude now actually so maybe I should do is say my magnitude map is going to be the square root of the gradient index integrating my and my angle is going to be the arctangent of the GX over Gy and I'm going to multiply that by 180 over PI to get degrees and so now if I were to look at the magnitude this should basically give me places where both the x and y edges are high and if I were to do the angle okay so here kind of what I'm looking at is on the left hand side is the magnitude of the edge of AB okay this is basically gonna have you know values whenever there is some sort of edge activity going on right here I can typically see if things are basically outlining the key objects that I care about and you know there's a bunch of crud over here that is maybe a little bit we'll talk about how we can fix that stuff you know incoming lectures here what we have is the orientation of the edge okay a little bit harder to interpret it looks pretty noisy par the reason is that in places where there isn't any edge activity that angle is not going to really mean anything so it's almost gonna be like just a random number in places where you're just looking at you know a flat flat region so stuff like this doesn't really matter but here you can see that this is the angle and so when I'm at zero I should have a greenish edge right which is what I'm seeing for all these strong edge pixels over here right like so curious where I got all these green guys when I met a strong horizontal edge I should either get kind of a red or a blue because of the way this color bar wraps around so I can see that that's what's going on here and then I could also see like an imagined I could pick out edge orientations like here this edge of the triangle is all showing me these about 30 degree number and similarly on this other side of triangle I'm sorry all these guys are also roughly at the negative 3 degrees right so if I wanted to I could say make a edge operator picks out only those things so for example what I could say is the following so give me an image such that the absolute value of the angle minus 30 is less than ten degrees so I want things that are close to 10 degrees I'm sorry those things are close to three degrees and I want places where the magnitude is greater than say one let's see what that number gives us yeah okay clearly I didn't do what I wanted so what'd I do wrong maybe my maybe my magnitude what is my scale of my time here oh that's pretty big okay so then my my threshold here is pretty it doesn't really look like what I want let's try be a little bit less aggressive some things where this worked at home why isn't it work here yeah okay so what's going around here so I want my a to be within a certain value yeah I think that was especially worked in my opinion so what am I doing around here let's try and treat this around yeah the absolute value is oh so easy yes I want this right absolute value of a minus three listen okay let's write this from scratch I want the absolute value of the difference between a and thirty to be less than two parentheses around that and I want the magnitude to be greater Hey all right this is any better right so here I can see that I picked out those entrances right so I wanted to make a preferential edge operator that was only detecting edges a certain angle I could do that and if I used if I use plus thirty instead I should get the other side of the triangle yep okay right so you could imagine making preferential edge operators say okay I only care about edges at a certain angle and so even though I built all this stuff by myself because I'm a MATLAB bastard you could also use these built-in functions there's a function called in gradient XY that gives you the X&Y gradients and you can see here that it I believe by default is going to use the Sobel operator it's just like I did for some extra smoothing right but it gives you some additional operators if you want to use those instead and there's also a command called M gradient that gives you the magnitude and direction of the edges straight out right seriously uses our tangent whatever yourself you can use these built-in functions okay okay so let me stop and ask any questions about that's pretty straightforward okay so I think what to conclude by just said in MATLAB is that you know we can do things like we find places where the magnitude I guess since M is already the magnitude we can say that I want this to be greater than some threshold this will tell me only strong edge pixels or I could say I want to find places where the angle the absolute value of this is within some threshold and the magnitude is greater than some other threshold that's why I just did to find those edges and so that kind of thing you can do with these you know gradient operators so I want to mention a couple other edge detecting operators that are commonly used in larger so so cool is very common so that's that's the most often used one but there a couple other ones to know about so one is called the laplacian of gaussian which is also known as the Mar hildreth detector after the guys also known as the Mexican hat filter and so the idea is that you know sometimes we want is a edge detector so one of the issues the soul detector right is that only really applies to finding edges that are on the same scale as these pixels right so for example you know here I'm only looking at a 3x3 pixel neighborhood to make my edge of decision right whereas oftentimes what I want to do is I want to find okay maybe I care about really broad hi Alice what's right word like really strong edges that are for example like the edge between this monitor and the wall right that no matter how much I blurred the image I would still see that edge coming through versus edges like the little checks on my shirt that are like more like pixel level details right so if I boarded the image I wouldn't see those checks anymore so it's kind of this idea of scale dependent and that's what the laplacian of gaussian function will help us out with so the idea is an edge effector that can be tuned two edges of different skills and so the idea is that you know large operators which burst by the kind of big spatial masks so big operators correspond to very large scale or you know big and blurry edges whereas small operators will respond to fine scale you know okay and so the definition of the Gaussian Gaussian is literally what it sounds like so basically if I have a Gaussian filter which we talked about last time also right so a Gaussian filter would be something like this where I say okay I've got a Gaussian and this Sigma controls how why my Gaussian is I have Sigma is small this thing is really pointy of Sigma's big it's really spread out right and so again well we're kind of getting out with the so block Reuters was that sometimes it's a go here to smooth the image before we find edges and the same way here what we're doing is we're smoothing the image of some scale and then my laplacian operator finds edges of the image after the smoothing right so if I were to take the double derivative like this right the definition of that would just be well I can take these derivatives calculus I'm not going to actually do the derivatives for you here but I will tell you what the answer is it turns out to be the Gaussian multiplied it by another function so the result of this is that I get a function that looks like the following so for some reason I don't know why we always look at the negative of this function I guess does it makes more sense so it turns out that I have a function that looks kind of like this and as you'll see for a second if I rotate this around it looks like a sombrero just by the call to Mexican town so the idea is that the characteristic of it is that it's big in the middle it dips down to be you know it's slightly negative on the size then it goes to zero on the outside and the width of this guy here is two square root Sigma and the idea is that depending on how I choose my Sigma it depends on how spread out this sombrero peak yes okay and so if you look at this in 2d so MATLAB allows us to make such a function I mean I could make it by myself but I mean if I look at F special which I think you may have used which I think you may have used to define a galaxy in the first place so besides Gaussian one of them is law laplacian of gaussian right and so here what I can ask for is a positive Gaussian i specify the filter size i specify the sigma and so just to make it really clear let's look at a really big filter let's look at like a 101 by 101 filter with variance of let's say 10 okay so I'm gonna think about this as a surface but let's just look at this receipt all right and I'm gonna plot the negative of this just because it's conventional and I'm gonna make a nice ok so here you can see that this is why they call it the Mexican hat filter because you know it's big in the middle and it dips down like a sombrero a little bit right and then it levels out at zero okay hello Kate from the top I've got big values in the middle slightly negative values in this ring and then zeroes out and then depending on what my Sigma is I can make this filter sharper or broader and so for example if I was to use a different Sigma so say I was to use a smaller Sigma then this would be a much narrower Mexican hat right if I used a bigger Sigma I would get that much broader neck nice it can happen so let's say like this here the Mexican hat is so broad that you don't even really see the dipping down to zero part of it inside this range right so so probably almost too too big to be useful okay and so again what is the theory the theory is that we are is the Gaussian part smooth the image down to a certain scale right so if I apply a big variance of the Gaussian the image is gonna get really fuzzy right and then the laplacian finds the edges at that scale right and since this is the second derivative operator we look for the zero crossings of the little posse of Gaussian to look for zero crossings since it's like a second derivative right so kind of when we think about this is that my gradient image is life you know I can need to think about it like the laplacian of gaussian operator applied to the image or I could think about it as the laplacian of gaussian operator applied to an image right because everything is linear I can move around these convolutions without penalty right so here this is like saying okay first I screw the image then I find the edges right that's that's really what's happening and so like I showed you MATLAB has this F special hello G function built into it okay and so let's see I guess I should have thought about this before I came here but let's let's see what we get when I filter the image with certain hello G's right so let's start with my my small L og and then make a slightly bigger alergy I'm not sure what we're gonna see here so I have no guarantees this is gonna look great but let's see so what I can do is I can filter my image with the small guy first and then the big guy and now what I'm going to do is I'm going to find well let's just take a look at what these what these things look like so okay so kind of what you're seeing here is that you know the left-hand side is filtering with the small-scale elegy the right-hand side is filtering with the large-scale elegy right again either I guess I should think about the color map is here so basically let's just put a color bar on one of these guys these are gonna basically go from positive to negative values right and so anything that is kind of far away from green means so kind of I'm looking for is places where there is a zero crossing from blue to red right and so here you can see that this guy is picking up lower detail edges like the rings around the eyes of this mailbox or the store bell right so here you know these are going to be nice strong responses here whereas as I filter this more I'm going to get bigger scale edges like you know the difference between I think it probably better examples like the the things on this nose right so here these guys here are all being picked up as important edges at a small scale after I've lowered the image those little holes on the speaker have been blurred away those will get picked up in the higher-dimensional you have higher size LG but things like this big mouth in the mailbox that are going to be significant at any blur scale are going to show up you know more and more so kind of you're gonna get responses to strong edges at you know multiple scales right so for example here these edges are really only significant at the small scale these edges around the mouth are significant at the small scales the medium scales and large scales right so in some sense what we want to do is and this is a little bit outside of the topic of this lecture what we might like to do is to say okay at what scale is this edge most important right so that gives us a sense of you know where are the biggest edges that kind of notion of scale space maximization we could talk about that a little more maybe after exam two that's more of a computer vision why would I want to get though is that you know here I'm finding lots of little low detail edges and here I'm finding only the highest edges and the low D colleges and this guy are smooth though and so this would be useful for example if you really cared about understanding okay I don't care about all the big picky you know texture in my shirt I only care about finding the big edges of the objects in the world right I don't want to get confused by small scale edges right so if I was wearing a black and white patterned shirt that had strong edges in it but I wanted to really find the boundaries of these black and white monitors against the white wall in that case I would probably want to do a you know filtering a big smoothing of my image to get this part to go away in that part to show more strong right so it's kind of that's why we use the yellow G is is to make this kind of scale space standout so the idea is that you know could also find the scale by which I mean Sigma at which a given edge is most significant and then filter on that if you want to do so just one comment on the elegy right so theology is you know fine but also there's something called the difference of gaussians so we can approximate the LOD with a difference of gaussians sometimes also called do G so that definition basically is exactly what it sounds like so what I could do is I could say okay I'm going to take a Gaussian with one variance I'm going to subtract a Gaussian with another variance entra is up that you can make these do G operators look a lot like the Mexican hat so for example let me just show you why that's true so again I can look at my F special and I'm gonna make two Gaussian operators and let's say so let's again make these like reasonably big and so here's a Gaussian that has a big variance and here's a Gaussian that has a smaller variance and so if I look at the first Gaussian so here's one Gaussian okay and let me just make this a little bit smaller and if I look at my other Gaussian has a smaller variance right and if I look at the difference between those things so I'm going to subtract these two things what I get is something that is actually pretty much I'm gonna make the negative of this you know something that kind of already pretty much resembles the Mexican had I had before right and say it is that by carefully choosing the sigma1 and sigma2 I can make something that looks almost like velocity and Gaussian it turns out that for computational reasons sometimes we like to do this because there are reasons why we want a filter the goths filter the image with Gaussian filters of different sizes and so it's like saying okay well if we've already got these different levels of Gaussian filtering I can subtract them and I can get these LG so that's more of a computational thing but certainly used a lot in computer vision so I'm gonna say this is used a lot so for example if you've ever heard of the sift algorithm we're gonna maybe talk a little bit about this after the exam - this is a super popular algorithm for automatically finding good features in image like nice corners and blobs and image and so this do G is a critical part of that image processing computer vision pipeline as it turns out so we may talk about that a little bit okay so questions or comments about hello G the other major edge operator that you're going to see is called the Hemi edge detector so I just want to say a couple words about that and as long as I'm talking let me to show you that in MATLAB you know there is this edge command right and it basically goes through all the stuff I'm telling you about right now so you can find edges in the image with kind of whatever you want Sobel operator l OG operator what I'm gonna tell you right now is this canny operator right and so fundamentally you know you can read more about all the details of how it works inside the segmentation eye so I tell you about what's kind of a good the hood of this one called Canon because that one you're gonna see a lot in terms of people who write an academic paper and they say well we apply the can I detector to blah blah right so let's talk about what that actually means okay so this is you know I'm not going to go through the whole grungy details that's method because there are a lot of little implementation details but I'll give you the high picture so the basic steps are the following so first we smooth the image with the Gaussian filter next we compute the gradient magnitude and orientation okay the next step is to do what's called non maximal suppression and let me just explain what that means in separate slides we're going to do this process to obtain a new gradient image which I'm gonna call GM okay so first let me explain what this is not maximal suppression is okay so the idea is that when I have a non-ideal edge right if I have like a ramp edge instead of a step edge so suppose I've got a ramp edge that goes up like this right so I got no action then I have you know some intensities and then I work my way up to intensity 75 right so if I look at the magnitude of the gradient or so see repelling out one dimension so here what I'm going to have is the difference between me and my previous guy so it's good zero zero zero 10 15 25 15 right so if I'm looking for the edge Center really what I care about is this pixel here right I want to know where is kind of the center of this edge but if I'm fresh folding on the magnitudes of the gradient these guys here maybe kind of non-trivial edge responses this here is the center but these guys here maybe kind of non-trivial magnitudes and so what I want to do is I want to suppress those guys and not include them in my edge map because I really only care about the middle of these edges okay so what does this mean not maximal suppression so what it means is Oh so the idea is to quantize this angle of the edge into four bins okay so what I'm going to do is I'm going to say here is my possible circle of this it's going to be a crappy garden who's okay it's okay so basically I'm gonna say that everything here has been one then two then three been four okay so every Edge has both the magnitude and an orientation and so if I look at by magnitude at a given pixel and my angle again pixel so let's kind of draw a little sketch like like this year so let's suppose these are edge magnitudes and he's making up numbers here and these are the corresponding bins of the edge orientation so kind the idea here is saying okay you know there's a strong edge in the middle pixel which I guess I could have drawn better and it's going in this direction okay so basically I'm going to say okay I'm gonna look at this pixel and this is its direction and I'm going to use that direction to look at my local neighbors in the corresponding directions this is saying I think the edge is going this way so I'm going to look at my neighbor above me and below me and I'm going to ask am i you know greer the both of my neighbors if I am I'm going to stay in if I'm not going to throw it out so basically if this guy is greater than both it's neighbors in the quantized as direction you know then I'm gonna keep it in this new map otherwise I'm going to knock okay Cydia is all I'm doing is I'm kind of keeping points that are locally bigger than my neighbors in the estimated direction of the edge okay so this results in some new binary image all right maybe I should say I'm going to keep it I think it's probably there is that going to keep it with the magnitude otherwise that zero it up right so now I'm going to have something that either it's going to be the same as the magnitude or it's going to get zero down because it's been suppressed right that's what not maximal suppression means and then what I'm going to do to detect the final canny edges is the following so the last step of cannae is to detect and link edges and so the idea is that I build a high map that says find me all the places where this magnitude is greater than some value so these guys are going to be like the really strong edges the places where the magnitude is really hot and then I'm going to make a low map that says edges that are not quite as strong so he's gonna be weaker edges and the final map is going to be all the strong edges along with all edges in the weaker map that are there all edge pixels here that are adjacent to at least one pixel of the strong map so basically ideas saying okay I'm gonna assign two thresholds the guys that are really strong those are all in right the guys that are somewhat strong I'm not going to include them all I'm only going to include the ones that are close to a strong edge right and the idea here is that you know this notion of including some but not all of the weak edges helps me kind of bridge some gaps that I might otherwise have missed right so typically you know this low threshold or maybe the high threshold is maybe two times or three times the low threshold right so the high threshold is pretty high the low threshold is lower and that is that you know this guy here may have some gaps these guys here may clean up some of the gaps I'm not going to include everything just the ones that may help me bridge the gaps and so the visual consequence is that canny edge Maps seem a lot cleaner than other edge maps and so if I just show you an example with the doorbell again so here what I'm going to do is I'm going to say my edge map is edge of the image and use the canny edge detector we'll so okay so on the first glance this doesn't look so great and probably the problem is that the candy had Viktor has some parameters that tell me how my threshold should work right so here I can supply fresh and fresh is going to be I believe the high threshold if I don't say anything else so Thresh is a two element vector if you supply a scalar this is used with the high threshold right so let's suppose that I look to see what was the automatically chosen threshold that so if you don't say anything MATLAB will just choose some threshold for you sometimes it'll be good sometimes it won't so here it's saying the low threshold is point zero five the high official that's like one for when I'm looking at that image I see that the image has like lots of distracting edges right too many so now I'm going to do is I'm going to specify instead I want you to use point four as the top has the high threshold okay that means that there is a stronger criterion for getting in as an edge in the first place and I look at that edge image I guess I have to look at it like this I look at that edge image well things are definitely a lot you know lot less clutter right maybe I went too far right so here one characteristic of canny edge maps though is that they do seem to have like long continuous trillions of edges right and that's useful for we're going to talk about on Thursday which is basically how can i link edges together into boundaries of objects and so you know here for example you might imagine that I could follow this octagon basically like all the way around and I don't get distracted by all the other kind of low weak edges that are inside the periphery of this area right so the end is the nice thing is that for example actually this is pretty good right so here I could follow all the way around this mouth of this mailbox with the Kantian trajector whereas if I was to look at the corresponding thing with Sobel just like let's look at as an example so right so kind of let's look at the comparison so in general you know the canny edge map looks much much cleaner than the Sobel edge map does right because so many map is picking up all sorts of crud that's just in the background image which are probably not going to get classified by canny as being strong enough to include right so that's why here there are some gaps that you know Sobel doesn't have but there's also like a lot of other crud that Sobel does have right so the nice thing about canning is you get these kind of edge maps that look like kind of what you want and let's see if I can give you actually let's just see if I could make this even a little bit better so here I feel like my canny was still a little bit conservative so let's make a little bit more like this so kind of on the left is candy with a high threshold on the right is Kenya with a low threshold you know actually I think I've made the right choice with the threshold that I did because you know if I kind of compare here I can see I'm including a more kind of random stuff right so again though the federal technically stuff is just like a turnkey solution where you just apply the default amount my parameter isn't it worse you do have to do some manual tweaking to find out what edges are going to work for a certain kind of situation right and so for example you know obviously you want to incorporate these things into some sort of hopefully automatic algorithm but what you would do is you know say that you're looking at parts coming down a conveyor belt right you've got a camera you've got some sort of lighting you know that something's probably not going to change and so what you do is you would say okay I want to find the edges these parts I'm going to look at a whole bunch of images and tune my candy and detector to get the parameters I think you're gonna work right from my situation and then I'm gonna hard code those it's a by algorithm and forget about it right but I wouldn't just use the default parameters and hope for the best you know in any real application you have to kind of actually work with it a little bit supposed to see not sure if I have any other good edgy images here so let's try ceiling for corner I don't think I could be wrong well let's just see if edge detection works with color images so here's an example that has like some definitely strong color images or color edges and I'm not sure whether if I just say this it will work so we have to turn this into a grayscale image as we do oh I guess I returned into this okay so here's the grayscale version and now I'm going to make an edge image I haven't tried this before so who knows what's gonna look like uh well you know let's see what we got I mean again part of this is just a resolution issue so if I were to zoom in on these regions maybe it would look a little better so here you can see I'm actually getting pretty nice you know continuous edges in this image if I were to look kind of in these guys here you know a little bit harder and you know I'm not expecting to get bunch of these paving stones here but you could imagine that if I wanted to use this to for example find the doors and find the windows this is looking a lot more like what you would get a human to do if you asked them to trace the edges in the image right so again there's lots of clutter that's making edge you're making object detection this image is gonna be a little bit more of a challenging thing but you know I mean I think this is you know not too bad and if I wanted to be a little more aggressive so let's see for example what what did Kenny choose as its thresholds so here it made some different automatic tries officials so say I want to be more aggressive about my edges and saying that shoes you know 0.40 okay so now I'm definitely getting much fewer edges right so for example if I look at the if I look at the cobblestone area I'm not picking up any that stuff anymore but I am picking up like oops maybe I should be a little more high I'm picking up basically the edges of the doorway so it's supposed I was looking to find doors right doors and windows yeah here I did a pretty good job outlining just the most important stuff right and actually you can see that even though there were lots of edges over here before now the planting edges have all gotten kind of abstracted out for the most part and so again I could tour out of these parameters to get something that looks as much like you know a good edge image as I want but it's not a you know it's not an exact science right there secondly some manual tweaking around to get what you want so yes upshot is that on the plus side Canyon Canyon image I just often look more like what you want eventually the downside is that the algorithm makes more cobble gate implement right so you know I've got this multiple steps of Gaussian stuff maximum suppression so if you have an embedded device you may not be enthusiastic about implementing the whole candy and recycle you may just go for a LG or Sobel or whatever because it's easier right so there's always those kinds of trade-offs okay so any questions about any of this stuff all right so then I will close this guy up and let's just talk about the exam for a second
Info
Channel: Rich Radke
Views: 23,715
Rating: undefined out of 5
Keywords: rich radke, radke, rpi, image processing, digital image processing, edge detection, sobel, laplacian of gaussian, difference of gaussian, canny, canny edge detector, edge detector
Id: APBXfqVccS0
Channel Id: undefined
Length: 63min 22sec (3802 seconds)
Published: Mon Mar 09 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.