tag:blogger.com,1999:blog-73331669704224959.post6387107082385025807..comments2023-08-20T04:45:55.158-07:00Comments on ComputeCube: Canny Edge Detection StepsBarretthttp://www.blogger.com/profile/13549719980585276668noreply@blogger.comBlogger13125tag:blogger.com,1999:blog-73331669704224959.post-63811410178413909412009-09-05T10:24:28.000-07:002009-09-05T10:24:28.000-07:00All the rest is easy but you gloss over the edge t...All the rest is easy but you gloss over the edge thinning problem. I tried doing an implementation of NMS based on descriptions I found on the net. Quite consistently I find that I end up either discarding too much information or not enough of it. Any pointers - or pseudo code, C code, or Delphi code, or VB code... - for NMS would be hugely appreciated.Frednoreply@blogger.comtag:blogger.com,1999:blog-73331669704224959.post-38379504732818228172009-10-15T02:58:05.000-07:002009-10-15T02:58:05.000-07:00Non-Maximal Suppression is rather tricky as it is ...Non-Maximal Suppression is rather tricky as it is easy to discard too little information or too much.<br>I can't go into too many details as it gets very close to what I do for work but I tend to base it on the document type (if known) or the "crispness" of the straight lines in the image. Luckily I only really deal with scanned text so my problem space is vastly reduced.<br><br>I can recommend "Algorithms for Image Processing and Computer Vision" by J.R. Parker, although it is an older book and doesnt include a lot of the more recent developments it is a very good starting point and includes source code in C.Barretthttp://www.bv2.co.uknoreply@blogger.comtag:blogger.com,1999:blog-73331669704224959.post-52246355730048604902009-11-05T22:42:36.000-08:002009-11-05T22:42:36.000-08:00can u pls tell me how will i run gaussian mask ove...can u pls tell me how will i run gaussian mask over the image.<br>i mean do i have to run it in the same manner as derivative mask are run??ajayhttp://bv2.co.uknoreply@blogger.comtag:blogger.com,1999:blog-73331669704224959.post-32229808902808244902009-11-06T02:25:04.000-08:002009-11-06T02:25:04.000-08:00Hi Ajay,In the simplist implementation you would t...Hi Ajay,<br><br>In the simplist implementation you would take an element of your image, find the surrounding 24 points, apply the Gaussian equation to each point and sum. Divide by the factor you calculated for your mask and then save the value in another image. Repeat until done.<br><br>Of course this is a very poor way of doing it as the Gaussian is a convolution and is therefore seperable. You will find sample Gaussian convolution code here: http://www.bv2.co.uk/?page_id=863 <br>Here we are calculating the Gaussian for row elements at a time and when we have enough of them completed we compute the column. <br><br>Hope this helps<br><br>/BarrettBarretthttp://www.bv2.co.uknoreply@blogger.comtag:blogger.com,1999:blog-73331669704224959.post-87046062143656035222009-11-09T22:00:44.000-08:002009-11-09T22:00:44.000-08:00Hi BarrettThanx for replying. I was thinking abou...Hi Barrett<br>Thanx for replying. I was thinking about 1st method which is inefficient as u told.<br>The second method u suggested is better than previous.<br>Can u pls explain as what are we exactly doing in the procedure??Ajayhttp://bv2.co.uknoreply@blogger.comtag:blogger.com,1999:blog-73331669704224959.post-26243533312434914982009-11-12T07:57:51.000-08:002009-11-12T07:57:51.000-08:00Hi Ajay,Sorry for delay in reply....I assume you h...Hi Ajay,<br><br>Sorry for delay in reply....<br><br>I assume you have the CUDA kernel which does both x and y convolution at once. It is a rather tricky kernel to understand as it is quite optimized.<br><br>The basic principle is to compute the x direction gaussian first using a 1D gaussian function (equation for it is here: http://www.bv2.co.uk/?p=532)<br><br>once all the 1D gaussians have been computed in the x direction take their results and apply the 1D function again in the y direction. The difference is that you are now applying the function to the results obtained from the in the first step and not on the raw data.<br><br>The result will be the same as if you had applied the 2D Gaussian to the data.<br><br>The cuda kernel is a little different in that it starts computing the y direction as soon as enough data is available rather than waiting for the x direction to complete fully. This ensures a higher throughput with greater shared mem usage.<br><br>/BarrettBarretthttp://www.bv2.co.uknoreply@blogger.comtag:blogger.com,1999:blog-73331669704224959.post-29766315241826068382009-11-13T13:13:23.000-08:002009-11-13T13:13:23.000-08:00hi barrett,i knew you will reply.so dont be sorry....hi barrett,<br>i knew you will reply.so dont be sorry..<br>i read ur reply.<br><br>when we apply sobel operator. mask [1 2 1]' is used for x direction and then <br>[1 0 -1] is applied to get final o/p as it would be obtained had we applied the whole mask at atime. you know what i mean.([1 2 1]' is tranpose of [1 2 1]).<br><br>if u got my point in the above statement then pls tell me if i have to split the smoothing filter into x and y direction then what will be masks for respective directions.<br><br>thanx AjayAjayhttp://bv2.co.uknoreply@blogger.comtag:blogger.com,1999:blog-73331669704224959.post-82427606674292654772009-11-16T06:56:52.000-08:002009-11-16T06:56:52.000-08:00Hi Ajay,I see what you mean now :)For the smoothin...Hi Ajay,<br><br>I see what you mean now :)<br><br>For the smoothing filter (Gaussian in this example) you can just apply the function in each direction.<br>Once the result from both directions have been calculated I then multiply the Amplitude in and divide by the reciprocal of the sum of all the factors.<br>You can do the Amplitude multiplication in each dir by then multiply by the sqrt of A. The same goes for the divide. <br>If you look at the equation of the 2D gaussian and the 1D versions you will see why you need to handle the Amplitude differently.<br>I just do the mul and divide at the end to save myself a few operations.<br><br>/BarrettBarretthttp://www.bv2.co.uknoreply@blogger.comtag:blogger.com,1999:blog-73331669704224959.post-20275572039285697422009-11-17T23:20:53.000-08:002009-11-17T23:20:53.000-08:00hi barrett look at this URL http://www-personal.en...hi barrett <br>look at this URL <br>http://www-personal.engin.umd.umich.edu/~jwvm/ece581/21_GBlur.pdf<br>see page no 7.i used the same concept ,of splitting 2D mask ,in the mask<br>stated by you but did not get desired result.<br>pls suggest something on this.<br>thanxAjayhttp://bv2.co.uknoreply@blogger.comtag:blogger.com,1999:blog-73331669704224959.post-90124940994587118092009-11-18T02:15:23.000-08:002009-11-18T02:15:23.000-08:00Hi Ajay,On page 7 they are using a Difference of G...Hi Ajay,<br><br>On page 7 they are using a Difference of Gaussian - ie they compute different sized gaussian filters and then subtract them. Its not quite the same as discussed here. Differences of Gaussian are rather useful in smoothing out high freq noise. It may also even be used in our own neurons for visual processing. They are also rather useful for smoothing random noise out of image documents before ocr'ing although you may need to rebuild some letters afterwards (i's for example)<br><br>On page 3 they are using a similar technique. Although they are using state machines it's essentially what I am doing in the cuda kernel. Note that they don't seem to state their A or sigma in computing the coefficients, that is why results may vary.<br>They also only divide in the final stage, but the divisor varies from mine - probably due to differences in the co-efficients.<br><br>/BarrettBarretthttp://www.bv2.co.uknoreply@blogger.comtag:blogger.com,1999:blog-73331669704224959.post-13553058413871372342009-11-18T07:35:47.000-08:002009-11-18T07:35:47.000-08:00hi barrettGaussian blurs are separable into row an...hi barrett<br>Gaussian blurs are separable into row and column operations.<br>this is what the abstract of the URL says (give above).<br><br>So what i was doing is that for horizontal direction i was taking<br>5<br>12<br>15<br>12<br>5<br>as operative mask and then applied mask 5 12 15 12 5 to get o/p but it dint work.<br>Can you pls tell what wrong iam doing???Ajayhttp://bv2.co.uknoreply@blogger.comtag:blogger.com,1999:blog-73331669704224959.post-4891622794769265472010-05-29T12:53:39.000-07:002010-05-29T12:53:39.000-07:00Hi I have completed steps in canny edge detection ...Hi <br>I have completed steps in canny edge detection till non maximum suppression but as said non maximum suppression should make edge more defined but it is not the same in my case. The edges are not very clear. Can you pls tell me what is problem at my end??<br>I followed this link to implement non maximum suppression.<br>http://en.wikipedia.org/wiki/Canny_edge_detector<br><br>pls reply i need your help urgently.<br>ThanxAjaynoreply@blogger.comtag:blogger.com,1999:blog-73331669704224959.post-86059004337167951612010-06-22T03:12:44.000-07:002010-06-22T03:12:44.000-07:00Hi Ajay,Without actually seeing the results of the...Hi Ajay,<br><br>Without actually seeing the results of the individual steps of your Canny Edge I can only guess at possible problems.<br><br>Is your Gaussian blur code correct? Ie dividing by the correct divisor for your mask - a rather easy mistake to make if you hand key your masks in.<br><br>Have you tried changing your Gausian blur parameters? Ie changing the width and std deviation of your mask? The example I gave in the article works in a wide variety of cases but may not be perfect for you.<br><br>It is quite easy to make an error in the non-maximum suppression code. The one mentioned in the wikipedia article should work, but there are other ways of doing it. Basically you are looking for a local maximum in the gradient direction you determined in the Canny step. The direction is the angle obtained by: theta = arctan (Gy/Gx). So if theta is 0 degrees see if the intensity of the pixels above and below are greater than or less than, if both less than we have a local maximum in the correct direction.<br><br>Hope this helps you a bit.<br>/BarrettBarretthttp://www.bv2.co.uknoreply@blogger.com