Thursday, 21 April 2011

Adaptive Threshold Edge Detection in GIMP

We have a particular edge detection algorithm that was developed for the OpenIllusionist project specifically to help with detecting fiducials in live video since it was faster and better suited to the task than algorithms such as the canny edge detector.

The original algorithm was designed by Prof. John Robinson at the University of York and then modified and optimised by myself. The following diagram, taken from my thesis, provides an overview of how the algorithm works:


The GIMP is an extremely useful tool, not only for manipulating your photos but also for prototyping machine vision algorithms. Since the edge detection is part of our standard toolkit it would make sense to be able to test it out on images alongside all of the usual filters found in the GIMP.

The porting of this algorithm to a GIMP plugin was not simple, since GIMP plugins usually make use of tile-based processing thereby reducing the overall memory required to handle very large images. However, as can be seen in the above diagram, the adaptive threshold edge detector uses many full and scaled down buffers to produce the final result and as such cannot easily be modified to work with tiles. The current implementation of my plugin simply uses full image regions and therefore the user must be aware that it may have issues if applied to very large images.

One problem that this particular algorithm attempts to address is that of edge ringing in images, especially those captured from low-quality cameras or affected by compression artefacts. The following image is based on an example from wikipedia but also includes the results from our edge detector which clearly shows that it is unaffected by the jpeg compression artefacts present in the lossy image:


The code for the plugin along with a binary for Linux x64 can be found in my github plugins repository and further examples of the algorithm in action are shown below.

Source image copyright Dan Parnham

Source image copyright Benh Lieu Song