🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Greg Sandell Sat, 06 Oct 1990 17:29
Peak detection
#977
Author: Greg Sandell
Date: Sat, 06 Oct 1990 17:29
59 lines
3117 bytes
Can anybody tell me about the existence of any peak detection
algorithms?  Below is an example of what I mean:

B & E are real peaks, the rest are not.
|--------------------------------------------------|
|              B                                   |
|              *   C                               |
|             * *  *                               |
|            *   ** *                     E        |
|           *    *   *                    *        |
|           *    *   *                   **        |
|          *          *                 *  *       |
|         *            *               *    *      |
|         *            *           D   *     *     |
|        *              *         *   *      *     |
|        *               *        ** *        *    |
|  A    *                *       *  *          *   |
|-------*-----------------*-----*--------------*---| (threshold)
|  *   *                  *     *               *  |
| * * *                    *   *                 * |
|*   *                      * *                   *|
|*                           *                    *|
|--------------------------------------------------|

A is not a real peak because it falls below my arbitrary
threshold.  C is not real because it is subsidiary to
the fall away from real peak B, and D is not real 
because it is subsidiary to the climb toward real
peak E.

Certainly any number of hacks will solve this (with
variables such as threshold, minimum valley required
before and after a peak, and so on).  One way would
be to run a lowpass filter on it, but I would prefer
something more direct since it needs to run very fast.
But I would like to know if there are any classic solutions to this
problem.  Also, has code for such an algorithm been 
printed anywhere (such as Numerical Recipes)?  

To satsify your curiosity, I need a peak detector for
a speech processing problem:  I have a curve which
represents the gross changes in amplitude for a recording
of speech.  By identifying the primary peaks, I can
find the principle syllable boundaries.  Obviously this
type of signal proposes particular issues for peak
detection:  for example, the peaks are skewed to the right
in speech (rising side is more acute than the falling side),
because onsets are quicker than decays.

I would appreciate replies via email.  I will be glad to share
any code I receive with all who are interested.

Thanks in advance,
Greg Sandell

****************************************************************
* Greg Sandell (sandell@ils.nwu.edu)              Evanston, IL *
* Institute for the Learning Sciences, Northwestern University *
****************************************************************
Re: Peak detection
#978
Author: Mike Black
Date: Sun, 07 Oct 1990 12:41
80 lines
3297 bytes
In article <13060@accuvax.nwu.edu> sandell@ferret.ils.nwu.edu (Greg Sandell) writes:
>Can anybody tell me about the existence of any peak detection
>algorithms?  Below is an example of what I mean:
>
>B & E are real peaks, the rest are not.
>|--------------------------------------------------|
>|              B                                   |
>|              *   C                               |
>|             * *  *                               |
>|            *   ** *                     E        |
>|           *    *   *                    *        |
>|           *    *   *                   **        |
>|          *          *                 *  *       |
>|         *            *               *    *      |
>|         *            *           D   *     *     |
>|        *              *         *   *      *     |
>|        *               *        ** *        *    |
>|  A    *                *       *  *          *   |
>|-------*-----------------*-----*--------------*---| (threshold)
>|  *   *                  *     *               *  |
>| * * *                    *   *                 * |
>|*   *                      * *                   *|
>|*                           *                    *|
>|--------------------------------------------------|
>
>A is not a real peak because it falls below my arbitrary
>threshold.  C is not real because it is subsidiary to
>the fall away from real peak B, and D is not real 
>because it is subsidiary to the climb toward real
>peak E.
>
What you appear to be interested in is a maximum peak detector with a 
conditional threshold crossing.  I would approach it this way:


#define N 25 /* # of points in waveform */
#define MIN 10 /* threshold minimum */

int peakloc=-1,crossthreshold=0;
int wave[N],threshold=MIN,peakmax=-1; /* these could be floats too */

findpeaks()
{
	int i;
	for(i=0;i<N-1;i++) {
		if (wave[i]>threshold) { /* cross threshold ? */
			crossthreshold=1;
		}
		else { /* if on downside show our peak */
			if (crossthreshold) {
				printf("Found peak at %d\n",peakloc);
			}
			crossthreshold=0;
			peakmax=-1;
		}
		if (crossthreshold && wave[i]-wave[i+1]>0 && wave[i]>peakmax) {
			peakmax = wave[i];
			peakloc = i;
		}
	}
	if (peakmax > 0) {
		printf("Found peak? at %d\n",peakloc);
	}
}

main()
{
	int i;
	for(i=0;i<N;i++) scanf("%d",&wave[i]);
	findpeaks();
}

I think this should run fairly fast for you but could use some optimization.
Mike...

--
-------------------------------------------------------------------------------
: usenet: black@beno.CSS.GOV   :  land line: 407-494-5853  : I want a computer:
: real home: Melbourne, FL     :  home line: 407-242-8619  : that does it all!:
-------------------------------------------------------------------------------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads