Median Search Demo
0.4
Median search demo (lib used by adaptive median image filter)
|
A benchmark demo driver for medians_1D and a couple of other methods. More...
#include "medians_1D.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <string.h>
#include <math.h>
#include <float.h>
Go to the source code of this file.
Macros | |
#define | BIG_NUM (1024*1024) |
Number of elements in the target array. More... | |
#define | MAX_ARRAY_VALUE 1024 |
Random test data; generated values are in [0...MAX_ARRAY_VALUE-1]. More... | |
#define | N_METHODS 5 |
Number of search methods tested. More... | |
#define | odd(x) ((x)&1) |
Macro to determine an integer's oddness. More... | |
#define | PIX_SWAP(a, b) { pixelvalue temp=(a);(a)=(b);(b)=temp; } |
#define | PIX_STACK_SIZE 50 |
Functions | |
void | bench (int, size_t) |
int | compare (const void *f1, const void *f2) |
This function is only useful to the qsort() routine. More... | |
void | pixel_qsort (pixelvalue *, int) |
Old and supposedly optimized quicksort algorithm. More... | |
pixelvalue | median_AHU (pixelvalue *list, int n) |
This function uses select_k to find the median. More... | |
pixelvalue | select_k (int, pixelvalue *, int) |
Called by median_AHU() More... | |
int | main (int argc, char *argv[]) |
Main driver demo for median search routines. More... | |
Variables | |
static const char | rcsid [] |
A benchmark demo driver for medians_1D and a couple of other methods.
Comparison of qsort-based and optimized median search methods for a 1-D data array. The data type is flexible.
Original code by Nicolas Devillard ndevi August 1998. Modified by Stephen Arnold lla@ free. frsteph August 2005. This code is now licensed under the LGPLv3. See the LICENSE file for details. en.a rnold @acm .org
A note about this benchmarking method:
The reported times indicate the actual time spent on CPU, they are quite dependent on CPU load. However, the test is quite fast and it is reasonable to assume a constant machine load throughout the test.
Definition in file demo.c.
#define BIG_NUM (1024*1024) |
#define MAX_ARRAY_VALUE 1024 |
#define N_METHODS 5 |
#define odd | ( | x | ) | ((x)&1) |
Macro to determine an integer's oddness.
Definition at line 42 of file demo.c.
Referenced by bench(), and median_AHU().
#define PIX_STACK_SIZE 50 |
Definition at line 232 of file demo.c.
Referenced by pixel_qsort().
#define PIX_SWAP | ( | a, | |
b | |||
) | { pixelvalue temp=(a);(a)=(b);(b)=temp; } |
Definition at line 231 of file demo.c.
Referenced by pixel_qsort().
void bench | ( | int | verbose, |
size_t | array_size | ||
) |
Random number seed
Initialize random generator with PID. This is the only Unix-ish thing; can be replaced with an alternate scheme.
benchmark the quickselect sort
benchmark wirth function
benchmark AHU sort
benchmark torben's method
benchmark the eclipse fast pixel sort
Definition at line 51 of file demo.c.
References BIG_NUM, MAX_ARRAY_VALUE, median_AHU(), N_METHODS, odd, pixel_qsort(), quick_select(), torben(), and wirth().
Referenced by main().
int compare | ( | const void * | f1, |
const void * | f2 | ||
) |
int main | ( | int | argc, |
char * | argv[] | ||
) |
pixelvalue median_AHU | ( | pixelvalue * | list, |
int | n | ||
) |
This function uses select_k to find the median.
Definition at line 360 of file demo.c.
References odd, and select_k().
Referenced by bench().
void pixel_qsort | ( | pixelvalue * | pix_arr, |
int | npix | ||
) |
Old and supposedly optimized quicksort algorithm.
Function : pixel_qsort()
Definition at line 234 of file demo.c.
References PIX_STACK_SIZE, and PIX_SWAP.
Referenced by bench().
pixelvalue select_k | ( | int | k, |
pixelvalue * | list, | ||
int | n | ||
) |
Called by median_AHU()
Function : select_k()
Definition at line 316 of file demo.c.
Referenced by median_AHU().