Page 1 of 2
Canny edge and now? Edge extraction - anyone?!
Posted: Thu Nov 24, 2011 4:12 pm
by DarkDragon
Hello,
I need to find an algorithm for exact edge extraction from a canny edge result. I tried the hough transformation and the probabilistic hough transformation, but no one of them is generating good results. They either produce too much lines for one place or weird non existing lines in the middle of noisy areas and both are not reproducing all edges.
Can anyone tell me a better vectorizing algorithm for lines? I only know a good one for areas.
Re: Canny edge and now? Edge extraction - anyone?!
Posted: Thu Nov 24, 2011 4:16 pm
by codewalker
dude, you're blowing my mind

Re: Canny edge and now? Edge extraction - anyone?!
Posted: Thu Nov 24, 2011 4:39 pm
by gnasen
i already worked on the same problem and couldn't find a satisfying algorithm. I didn't try it yet, but you could use the "harris corner detector" to get the most important corners in your picture. If an edge is matching at least two corners, its a good edge. At this way you can maybe get rid of "bad" edges.
You could also try to use another convolution (I used sober instead of candy).
Re: Canny edge and now? Edge extraction - anyone?!
Posted: Thu Nov 24, 2011 4:48 pm
by Zach
codewalker wrote:dude, you're blowing my mind

QFT

Re: Canny edge and now? Edge extraction - anyone?!
Posted: Thu Nov 24, 2011 4:58 pm
by DarkDragon
First of all: thanks for your answer gnasen.
gnasen wrote:i already worked on the same problem and couldn't find a satisfying algorithm. I didn't try it yet, but you could use the "harris corner detector" to get the most important corners in your picture. If an edge is matching at least two corners, its a good edge. At this way you can maybe get rid of "bad" edges.
Does harris corner detector really get all corners? I think I'll loose more edges with it if I combine the standard hough with finding line segments through harris corner detection, because some corners won't match the exact corners or are lost completely.
gnasen wrote:You could also try to use another convolution (I used sober instead of candy).
With sober you mean sobel? I don't know every of those algorithms, that's why I'm asking.
codewalker wrote:dude, you're blowing my mind

Zach wrote:QFT


Re: Canny edge and now? Edge extraction - anyone?!
Posted: Thu Nov 24, 2011 5:28 pm
by gnasen
DarkDragon wrote:
Does harris corner detector really get all corners? I think I'll loose more edges with it if I combine the standard hough with finding line segments through harris corner detection, because some corners won't match the exact corners or are lost completely.
you have a variable called "corner response" k, which can be used to make the detector more strict or tolerant. I can send you a script with the background information if I can find it.
An idea would be to step through the "sharpness" of the detector and count how much edges would fall away with every step if you compare the edges with the corners. You could plot this as a step function f(k) = count_reject(k) / total_edges and maybe look for a max/min/inflection. Then take the result at step min/max/inflection. Just as an first idea.
DarkDragon wrote:
With sober you mean sobel? I don't know every of those algorithms, that's why I'm asking.
yes sobel, sorry for the typo

Re: Canny edge and now? Edge extraction - anyone?!
Posted: Thu Nov 24, 2011 8:01 pm
by DarkDragon
I have another idea and it seems to work somehow good already:
- Vectorize the edges as areas.
- To get poly-lines from the edges split the closed polygons, with the condition that every deleted segment from the polygon is either looking to the left or straight upwards.
Now you've got all segments from the polygon left, which look to the right or straight downwards. As they formed the edge of the edge you have to shift this a litte bit towards the edge (it matters in which order the polygons are defined, clockwise or anticlockwise).
With this you can get a perfect vectorization from your edges, but it seems to be a lot overkilled! And its buggy right now .. as some parts of the polygons aren't rejected.
Re: Canny edge and now? Edge extraction - anyone?!
Posted: Thu Nov 24, 2011 8:48 pm
by idle
without seeing what your input is it's really hard to say what would be the best method
houghs are really only of use when your looking for specific lines of interest
A canny is like a gausian blur with a sobel , did you try a laplacian? they often have better results for noise
Re: Canny edge and now? Edge extraction - anyone?!
Posted: Thu Nov 24, 2011 9:31 pm
by gnasen
DarkDragon wrote:I have another idea and it seems to work somehow good already:
- Vectorize the edges as areas.
- To get poly-lines from the edges split the closed polygons, with the condition that every deleted segment from the polygon is either looking to the left or straight upwards.
Now you've got all segments from the polygon left, which look to the right or straight downwards. As they formed the edge of the edge you have to shift this a litte bit towards the edge (it matters in which order the polygons are defined, clockwise or anticlockwise)
Honestly, I dont get it. I think a little outline/picture would help much

Re: Canny edge and now? Edge extraction - anyone?!
Posted: Sat Nov 26, 2011 6:10 pm
by DarkDragon
Thanks for your answers.
idle wrote:without seeing what your input is it's really hard to say what would be the best method
My input consists of any photos chosen by the user. Then I modify it with an bilateral filter, convert it to grayscale and use the opencv canny edge variant (which is not a true canny edge, as there would be no sobel in it).
idle wrote:houghs are really only of use when your looking for specific lines of interest
Yes, I first thought that would be enough, but it isn't. Well I was able to filter the output of the probabilistic hough transformation, so that small parallel lines which have a small distance get connected to a bit longer lines.
idle wrote:A canny is like a gausian blur with a sobel , did you try a laplacian? they often have better results for noise
I didn't try yet, thanks for the hint. But the extraction of those lines is more a problem than canny edge itself. I would like to have an algorithm which lets me specify the segment minimum length and then it tries to fit the
whole edge image with lines that are longer. Not only the best edges, also all other edges.
gnasen wrote:Honestly, I dont get it. I think a little outline/picture would help much

This sketch explains it, but I've changed the condition, as holes in polygons may produce the same edges again if you're not having all polygons described in the same way (clockwise or anticlockwise):
http://www.bradan.eu/files/vectorizationOfEdges.png
This works quite well, but in some situations it still has problems. And after this you can shift the lines towards the real edge with a simple shift by the edge normal and the dilatation radius.
If you want my full name for this new invented algorithm using marching squares, let me know or look at my homepage
.
Re: Canny edge and now? Edge extraction - anyone?!
Posted: Sun Nov 27, 2011 7:25 pm
by idle
I still don't fully understand what you're aiming to achieve.
Do you have an example images of your input and the desired output?
It sounds like it'll be a difficult problem if it's intended to work on arbitrary input
and there are so many ways to skin the cat.
Re: Canny edge and now? Edge extraction - anyone?!
Posted: Mon Nov 28, 2011 7:50 am
by DarkDragon
idle wrote:I still don't fully understand what you're aiming to achieve.
Do you have an example images of your input and the desired output?
With
this as input image I will get
this from canny edge and then I want exactly those edges as vectorized polyline, or if not possible as longest lines approximation. For the longest lines is p. hough transformation enough, but for the smaller ones it creates lines which only hit the real edge by 2 pixels or such. And it cuts long lines in some cases. Have a look at
this. The first car's side window is full of edges which are very small, but not really belonging to a real edge. P. Hough transformation is good for long lines, but I also need the small lines! My goal would be something like this if every connected color represents one vectorized line:
http://en.wikipedia.org/wiki/File:Valve ... ur_(4).PNG and this was the input image:
http://en.wikipedia.org/wiki/File:Valve ... ny_(6).PNG
idle wrote:It sounds like it'll be a difficult problem if it's intended to work on arbitrary input
and there are so many ways to skin the cat.
It doesn't need to be very fast. It is allowed to calculate a minute or two on a usual pc.
Re: Canny edge and now? Edge extraction - anyone?!
Posted: Mon Nov 28, 2011 8:41 pm
by idle
If you've got time to process the image then I'd probably go in to frequency space to process the image
and use a high pass filter like a butterworth to bring out the edges. Then use morphological operations
dilate and Errodes on the inversed FFT image.
You could possibly also use a hough in frequency space to find the best candidate angles
in the image or maybe even filter the FFT with the hough, never tried it so don't know if it'd work.
Don't know if openCV exports an FFT and filter functions but it will have one
Re: Canny edge and now? Edge extraction - anyone?!
Posted: Fri Dec 16, 2011 9:10 am
by blueznl
idle wrote:... I'd probably go in to frequency space to process the image and use a high pass filter like a butterworth to bring out the edges. Then use morphological operations dilate and Errodes on the inversed FFT image. You could possibly also use a hough in frequency space to find the best candidate angles in the image or maybe even filter the FFT with the hough, never tried it so don't know if it'd work. Don't know if openCV exports an FFT and filter functions but it will have one
Now, seriously, anybody
ever wondered why they consider programmers 'geeks'? I mean, the last time a girl talked to me that way, I pulled up my trousers and left...
Re: Canny edge and now? Edge extraction - anyone?!
Posted: Fri Dec 16, 2011 3:16 pm
by gnasen
blueznl wrote:Now, seriously, anybody ever wondered why they consider programmers 'geeks'? I mean, the last time a girl talked to me that way, I pulled up my trousers and left...
good point
