Search code examples
algorithmimage-processingdxfcorner-detection

Corner detection by points location or image


I have some simple shapes which shapes are not necessarily regular. enter image description here

I need an algorithm to find their corners, actually i want to summarize their points to minimum, to saving them in dxf format and I have their points location in array. Simple algorithms like harris or surf do not find proper points and return too much points as result. Can u please help me to solve this problem by algorithm or idea or code? (in c, c#,java ,...) or image processing thanks in advance.


Solution

  • What you want to achieve is called polygon vectorization.

    In the first place, you need to apply a contour following algorithm to get the pixels in sequence. In this case, it seems that simply linking the pixels to their neighbor will do (beware that in your sample some of the shapes are open and you probably have to extend the neighborhoods to twoor three pixels.

    Then detect the long straight edges by means of the Douglas-Peucker algorithm (https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm) or similar.

    Some of your corners are blunt and you may want to put them right. I would suggest to discard the sequences of short segments forming flat angles and join the long adjoining segments to restore square corners.

    enter image description here

    enter image description here

    Don't expect "perfect" results.