Skip to content Skip to navigation


You are here: Home » Content » Edge Detection


Recently Viewed

This feature requires Javascript to be enabled.

Edge Detection

Module by: Barron Stone, Rob Smith, Neil Narayan, Brent Stephens. E-mail the authors

Summary: This module investigates the use of Matlab filters to determine when notes are played within a recording from an electric guitar.

In order to determine the speed at which the user is playing it is first necessary to determine where in the recording individual notes are plucked. When a note is played on the guitar, a sharp peak occurs which is then followed by a decay as the vibrations in the string dampen. To determine where these edges occur the signal is first low pass filtered to remove some of the noise, then it is convolved with an edge detector function which produces a signal with peaks located at large edges (where notes are played).

Due to the non-uniform qualities of guitar waveforms, an edge detector function with rounded edges produced the best results. A good function to use for an edge detector function is the derivative of a Gaussian. This produces a filter that can be tuned to work well with certain frequencies specific to the instrument being tested.

Figure 1: This derivative of a Gaussian was produced in Matlab with f(x) = y(x)*exp(-y(x)^2/100000);
Derivative of a Gaussian
Derivative of a Gaussian (derivativeGaussian.bmp)

After the original signal is convolved with the Gaussian edge detector the result is a signal with peaks located where edges occurred in the original signal. A simple algorithm is used to create a vector of zeros with ones located at the locations of the peaks. Due to the nature of the guitar signal, it is not uncommon for the convolved signal to contain "double peaks" where two or more closely spaced peaks are created to represent what should be considered a single edge. To accommodate for this error, the algorithm is designed that once it finds a peak, it ignores any other peaks that occur within a given threshold range.

Figure 2: The top plot represents the original signal from the guitar. The bottom plot represents product of the convolution of the orignal signal with the derivative of a Gaussian.
Orignal Signal and Convolved Signal
Orignal Signal and Convolved Signal (OrignalAndConvolved.bmp)
Figure 3: The vector of zeros and ones representing edge locations overlayed on top of the original signal.
Location of Edges
Location of Edges (overlay.bmp)

To use the information produced by the edge detection to determine how fast the user is playing, the vector of ones and zeros representing peak locations is windowed into equal length chunks. The values within each of these chunks are summed together to determine the number of notes played within that window of time. From this, the program can determine whether the user was playing fast or slow during that period of time based on whether the number of notes played is above or below a previously decided threshold.

Figure 4: This is the Matlab code for the function EdgeDetect.
Media File: EdgeDetect.m
Figure 5: This is the Matlab code for the function GaussianFilter which works with EdgeDetect.
Media File: GaussianFilter.m

Content actions

Download module as:

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens


A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks