Add your own alternative version
Stats
157.6K views 17.1K downloads 84 bookmarked
Posted
12 Jul 2010

Comments and Discussions



Hello togerher,
can, please, explain this peace of code inside GaussianFilter:
int[,] Output = new int[Width, Height];
.....
.....
Output = Data;
this make no sence, new int[] can be ommited, because of Output = Data.
Next lines:
for (i = Limit; i <= ((Width  1)  Limit); i++)
{
for (j = Limit; j <= ((Height  1)  Limit); j++)
{
Sum = 0;
for (k = Limit; k <= Limit; k++)
{
for (l = Limit; l <= Limit; l++)
{
Sum = Sum + ((float)Data[i + k, j + l] * GaussianKernel[Limit + k, Limit + l]);
}
}
Output[i, j] = (int)(Math.Round(Sum / (float)KernelWeight));
}
}
Here would be suggested, that Data is "input" and Output is "output", but this not true (see above), Output overwites itself inside loops.
Many thanks in advice!
Alex





Hello together,
as expirienced developer I had try to understand the edge switch/case part (many if's with Tangent as parameter) to identify if fixes suggested here are all really correct.
As I quickly saw, this is simply vector condition, the tangent circle is divided not from 0..360° but from 0..180 (bottom side) and 0..180° (upper side). The 0° is not on the top as usually (as teached at scool) but at 90°.
The is assumption, tangent vector belong an axes is that vector coordinate is near as 22.5° to corresponding axis.
Now taken pen and paper and mark a points on circle.
After that check code.
In my opinion, all parts EXCEPT 45°was CORRECT!
Only 45° part should be corrected as:
if (((157.5 < Tangent) && (Tangent <= 112.5))  ((67.5 >= Tangent) && (Tangent > 22.5)))
The part of horizontal line was correct! The fix posted here by someone is wrong.
Now, result is correct and much more pleasant  the difference is really markable!
Cu,
Alex





Dear Sir,
I am happy to see your response, I am very busy now a days, I started this as my initial PhD Work. Wanted to share with others. keep the things going.
best regards,
Dr. Vinayak Ashok Bharadi





The horizontal part is also wrong:
if (((22.5 < Tangent) && (Tangent <= 22.5))  ((157.5 < Tangent) && (Tangent <= 157.5)))
since the second part will never become true!
Tangent>157.5 and Tangent<=157.5  how should one value ever meet this condition?





Dear Dr. Vinayak Ashok Bharadi,
many thanks for sharing the code.
It's very pleasant to see and try fully workable solution.
But I have some questions:
Many posters note bugs or improvements, some posts are very strage because their does not explain what is buggy and how to solve.
It would be very nice, if You can write here some statements about such posts and mark improved code parts if something was really wrong.
Of couse, it would be also nice, if you upload a new improved version of code here.
Many thanks in advice!
Alex





Original conditions for horizontal line:
if (((22.5 < Tangent) && (Tangent <= 22.5))  ((157.5 < Tangent) && (Tangent <= 157.5)))
Good conditions:
if (((22.5 < Tangent) && (Tangent <= 22.5))  (157.5 < Tangent)  (Tangent <= 157.5))





Can You, please, explain why?
Did You verified that?





Dear Sir,
I am happy to see your response, I am very busy now a days, I started this as my initial PhD Work. Wanted to share with others. keep the things going.
best regards,
Dr. Vinayak Ashok Bharadi





the horizontal edge will never have ((157.5 < Tangent) && (Tangent <= 157.5)). Tangent > 157 then it is horizontal, or Tangent < 157, then it is horizontal too. the range of Tangent is [180,180] if you use Atan2. if you use Atan, the result range is [90,90] anyway. The computation of Tangent and quantification of direction has a discrepancy.





Given the definition of D1 (D1= 1/(2*pi*Sigma*Sigma);), the following line in the GenerateGaussianKernel subroutine is wrong:
Kernel[SizeofKernel / 2 + i, SizeofKernel / 2 + j] = ((1 / D1) * (float)Math.Exp((i * i + j * j) / D2));
(1/D1) should be replaced with D1





I totally agree with you.
Source: I teach statistics.





Can author or somebody commit that?
Did You verified this produces better/correct results?





how to get the edge detection of another image on the same mainform of canny edge detection?





Just joking, but do fix the title, your code is in C, not C#.





It should be Canny Edge Detection in C, not in C#.





Maybe I'm missing something, but the code shown in the article and in the download, are C#.





also see it as c#
project works great
thanks for posting it.





do you have any idea to add subpixel accuracy in this code?





//45 Degree Edge
if (((157.5 < Tangent) && (Tangent <= 112.5))  ((67.5 > Tangent) && (Tangent >





What is THE BUG?
What is correct solution?
Can You, please, explain why?
Did You verified that?





currently,I'm interest in Canny Edge detection and I decided to apply Canny edge detection in my project. May I know whether Canny edge detection able use in image recognition? Hope to get your reply soon






I was checking out the code (in the download) and I found that the Sobel masks used in DetectCannyEdges() are:
int[,] Dx = {{1,0,1},
{1,0,1},
{1,0,1}};
int[,] Dy = {{1,1,1},
{0,0,0},
{1,1,1}};
This differs from the Sobel masks provided in the included PDF file (which is amazing btw, you must write in the article that one can refer to the PDF to learn how Canny works):
[ 1 0 1 ] [ 1 2 1 ]
KGX = [ 2 0 2 ] KGY = [ 0 0 0 ]
[ 1 0 1 ] [ 1 2 1 ]
I was wondering if this is by intention or a mistake. Could you explain why the difference if it is by intention?
PS: Section 3 (Nonmaximum suppression) in your article appears broken. Perhaps the <pre> tag is malformed or something.





This one I am able to answer. One gives higher priority to horizontal and vertical lines (meaning they will appear slightly darker/thicker), the other treats all lines equally.





Hi sir,
I'm solve to make an implementations to convert an image to binary image bassed in threshold. Now i need some class or namespace to implements Gradient Vector Flow algoritm in C#. Could you or anybody help me plesae?
Thanks you.







General News Suggestion Question Bug Answer Joke Praise Rant Admin Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

