Edge Detection and Linking Using Wavelet Representation and Image Fusion

Note: Please Scroll Down to See the Download Link.



This article will focus on one of the most common image processing tasks, detecting edges.  We will look at a number of ways to do this, and also look at one use for such information, an edge enhance filter.  We will start with what we know from the last article, using convolution filters to detect edges.

                   Edge detection filters work essentially by looking for contrast in an image.  This can be done a number of different ways, the convolution filters do it by applying a negative weight on one edge, and a positive on the other.  This has the net effect of trending towards zero if the values are the same, and trending upwards as contrast exists.  This is precisely how our emboss filter worked, and using an offset of 127 would again make these filters look similar to our previous embossing filter.  The following examples follow the different filter types in the same order as the filters above.  The images have a tooltip if you want to be sure which is which.  These three filters also allow specification of a threshold.  Any value below this threshold will be clamped to it.  For the test I have kept the threshold at 0.

Horizontal and Vertical Edge Detection

To perform an edge detection operation in just the horizontal or vertical planes, we can again use a convolution method.  However, rather than use our framework for 3x3 filters, we are better off writing the code from scratch so that our filter ( which will be a Prewitt filter ) will be either very wide, or very high.  I've chosen 7 as a good umber, our horizontal filter is 7x3 and our vertical filter is 3x7.  The code is not dissimilar enough from what we've already done to warrant showing it to you especially, but it's there if you want to have a look.  Following is the result first of our horizontal filter, and then the vertical one.

There's more to life than convolution

Convolution filters can do some cool stuff, and if you did a search online, you'd be forgiven for thinking that they are behind all image processing.  However, it's probably more true that the sort of filters you see in Photoshop as especially written to directly do what a convolution filter can only imitate.  I'd again point to the Photoshop embossing filter with it's range of options as evidence of this.

The problem with convolution for edge detection is not so much that the process is unsatisfactory, as much as unnecessarily expensive.  I'm going to cover two more methods of edge detection, which both involve us iterating through the image directly and doing a number of compares on neighbouring pixels, but which treat the resultant values differently to a convolution filter.

Homogenity Edge Detection

If we are to perceive an edge in an image, it follows that there is a change in colour between two objects, for an edge to be apparent.  To put it another way, if we were to take a pixel and store as it's value the greatest difference between it's starting value and the values of it's eight neighbours, we would come up with black where the pixels are the same, and trend towards white the harder the colour difference was.  We would detect the edges in the image.  Furthermore, if we allowed a threshold to be set, and set values below this to 0, we could eliminate soft edges to whatever degree we desires.  The code to do this is followed by an example at threshold 0 and one at threshold 127.


 OPERATING SYSTEM                   :  Windows XP Professional

 FRONT END                                   :  Microsoft Visual Studio .Net 2010

 CODING LANGUAGE                   :  C# .Net


    SYSTEM                                         :   Pentium III 700 MHz

    HARD DISK                                   :   40 GB

    MONITOR                                      :   15 VGA colour monitor

    RAM                                                :   256MB

Click here to download Edge Detection and Linking Using Wavelet Representation and Image Fusion source code