Author: Peter Bugaj

The following problem discussed here involves taking a set of labeled edges within an image, each enclosing an area of space within the image, and breaking them down into sections of straight lines.

Such a technique is very useful when one wants to use the edges as a part of a set of features, to see where in the image parallel lines are being formed. Parallel lines are hard to detect unless the edges themselves within the image are found, clearly labelled and stored in memory. In this report, we will briefly explain our approach and show a few sample results of how these straight edges appear as part of a task in human pose detection.

The first step involves taking the original image (Left), and using the technique described in the following Blog that discusses how to apply the idea of cell membranes to edges, to simplify the input for the initial labeling (Right):

Detecting Straight Edges: Input Image Detecting Straight Edges: Grouping Edges Together

The next step involved using the connected components algorithm on the area of the image occupied by a chosen labelled edge, and keeping track of when the algorithm began to move around a sharp corner, while iterating over the pixels making up that one edge (Left). Whenever such an occurence was detected, the algorithm would labelled the sub component of the edge is had iterated over so far - using a unique color, and it would number it and save it in memory. It would then continue iterating over the remaining part of labelled edge. The label for the sub component of the edge was stored in a different location than the location storing the label of the edge itself. Since the algorithm would detect a new sub-component only when encountering a sharp curve within the edge it was iterating over, each sub-component stored represented a single straight part of the complete edge. Two separate techniques where used to keep track of the connected components curving around an edge. The result of the second technique has also been computed and is shown (Right) as well:

Detecting Straight Edges: Approach One Detecting Straight Edges: Approach Two

The problem with two of the above approaches was that the edges were being constructed in sequence, and hence, by the time a straight line was detected, stored and labeled, the algorithm had already iterated over a large part of the curve. This resulted in entire corners being labeled as part of a straight line.

The solution to this problem was inspired by the idea presented by the Graph Based Component Labelling algorithm. This algorithm places pixels into sets, and then grows the sets organically to segment an image into distinct regions. This algorithm is both very time and memory efficient. When applying this similar idea to the edges within our samples, all edges end up being iterated over at the same time. This results in the edges being divided into sub-components along the corners, as intended:

Detecting Straight Edges: Organic Construction Detecting Straight Edges: Organic Construction