Question

Today I tried myself in corner detection in c#. I added an example image down there. The image is in black and white and has an outer shape and an inner shape.

example image

I only care for the outer shape, not the inner one. Trying Harris corner detection led me nowhere, so I thought I could put each pixel in a simple two-int structure like that:

struct coordinates
{
    public int x, y;
    public coordinates(int xx, int yy)
    {
        this.x = xx;
        this.y = yy;
    }
};

but trying to gain the biggest and lowest, most right and left tupel again failed me and returned sth like that (red line connects upperleft, upperright and lowerleft):

example Image processed

I think this happens due to the not full rectangle shape (left upper and lower corners are rounded) and uneven form (the upper right corner is right, but the lower right corner ends somewhere 3/4 down lower right).

Any ideas on how I could fix this problem? Using the upper/lower left as not-round corners would be fine for me (and better), so in the end I have a full rectangle around that white shape.

Was it helpful?

Solution

Do a hough transformation, find the dominant lines and calculate their intersections. This will improve your result, though it does not guarantee that the found shape contains all white pixels. Is that required?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top