SumitBirla.com

Home » Software » Image Processing I » Edge Thinning and Linking

Assignment 7: Edge Thinning and Linking

This project involved building on previous edge detection algorithms for implementing edge thinning and linking and removal of short edges.

All the functions are in the EdgeDetector class

The following sections describe how each one of them was accomplished.

Edge Thinning:

This is a process by which an edge detected binary image is reduced to thin (one pixel wide) lines. The result is a skeleton line which is close to a medial line. This is done by finding the contour lines and then erasing them repeatedly till we are left with the skeleton. Let 'P' be our pixel, then it can be erased in the following cases:



By doing so, we can safely eliminate '1' pixels without losing connectivity. In the code for edge thinning, notice that for the scan loop of the image, we chose different neighbors to be zero (non-edge). Otherwise, we would get only the left, right, top or the bottom edge line and not the medial line.

Images:


Edge linking:

We link pixels with similar gradient amplitude and direction. The amplitude and angle thresholds are passed to the functions as parameters. The functions compares neighboring pixels to see if their gradients are close enough, if they are, they are marked as being part of the same edge. In the implementation, it is marked as having a value of 100 which shows up as gray in the output image. A neighborhood of 8 pixels was chosen for each of the pixels.

Images:

Note: The linking is not so obvious on paper, but the tiny gaps in the edges have been filled. The links formed are overlapped with the edge detected image.


Removal of short edges:

Short edges are removed by calculating the length of the edges. This is done by traversing along white pixels (image[x] = 255) using a recursive function. Then, if this length is less than 9 pixels (arbitrarily chosen), we call the subroutine deleteEdge() which traverses the edge as well. The only difference is that it marks the pixels 0 as it goes along, thus removing the edge from the image.

Images:

Note: most of the noise (short edges) has been removed. In theory, by choosing an appropriate threshold for the length of the edges, all undesirable noise can be removed without sacrificing any information contained in the image.