📄 median.h
字号:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright (c) 2007 by Qu chun lei watt@vip.163.com
*
* File Name: MEDIAN.H
* Module: 0603C
* Language: ANSI C
* $Revision: 3 $
*
* DEFINITION
*
* This is the header file for a library module used to calculate the median
* of a list of values. It finds the value that would be in the center if
* the list were sorted. If the list contains an even number of values, the
* lower of the two center values is reported. The values themselves are not
* sorted or modified in any way. This algorithm can be used as a filtering
* tool for rejecting noisy data.
*
* CONSTRAINTS AND REQUIRED MODULES
*
* The input list must not contain any negative values
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef MEDIAN_H
#define MEDIAN_H
#include "dac.h"
/*---------------*
| Module Options
*---------------*/
#define MEDIAN_LIST_SIZE_DYNAMIC FALSE /* if TRUE, allows the number of entries to be defined at run-time;
otherwise, uses MEDIAN_LIST_SIZE_MAX for number of entries */
#define MEDIAN_BIT_SIZE_8_AVAIL FALSE /* if TRUE, includes the 8 bit median routine;
otherwise, excludes the 8 bit median routine */
#define MEDIAN_BIT_SIZE_16_AVAIL TRUE /* if TRUE, includes the 16 bit median routine;
otherwise, excludes the 16 bit median routine */
#define MEDIAN_BIT_SIZE_32_AVAIL FALSE /* if TRUE, includes the 32 bit median routine;
otherwise, excludes the 32 bit median routine */
#define MEDIAN_LIST_SIZE_MAX 5
/*---------*
| Types
*---------*/
/*------------------*
| Public Functions
*------------------*/
#if MEDIAN_BIT_SIZE_32_AVAIL
/*---------------------------------------------------------------------------*
| Median32
|
| Report the median value of a set of 32-bit numbers.
|
| Entry: pointer to array of numbers to find median from
| if list size dynamic, number of entries in array
| Exit: the median point of the array of numbers
*---------------------------------------------------------------------------*/
#if MEDIAN_LIST_SIZE_DYNAMIC
UINT32 Median32( UINT32 *medianArray, UINT8 meidanNumberOfEntries );
#else
UINT32 Median32( UINT32 *medianArray );
#endif
#endif
#if MEDIAN_BIT_SIZE_16_AVAIL
/*---------------------------------------------------------------------------*
| Median16
|
| Report the median value of a set of 16-bit numbers.
|
| Entry: pointer to array of numbers to find median from
| if list size dynamic, number of entries in array
| Exit: the median point of the array of numbers
*---------------------------------------------------------------------------*/
#if MEDIAN_LIST_SIZE_DYNAMIC
UINT16 Median16( UINT16 *medianArray, UINT8 meidanNumberOfEntries );
#else
UINT16 Median16( UINT16 *medianArray );
#endif
#endif
#if MEDIAN_BIT_SIZE_8_AVAIL
/*---------------------------------------------------------------------------*
| Median8
|
| Report the median value of a set of 8-bit numbers.
|
| Entry: pointer to array of numbers to find median from
| if list size dynamic, number of entries in array
| Exit: the median point of the array of numbers
*---------------------------------------------------------------------------*/
#if MEDIAN_LIST_SIZE_DYNAMIC
UINT8 Median8( UINT8 *medianArray, UINT8 meidanNumberOfEntries );
#else
UINT8 Median8( UINT8 *medianArray );
#endif
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -