median.h

00001 
00002 
00003 #ifndef _MEDIAN_H_
00004 #define _MEDIAN_H_
00005 
00006 #include "local_types.h"
00007 
00008 /*---------------------------------------------------------------------------
00009    Function :   kth_smallest()
00010    In       :   array of elements, # of elements in the array, rank k
00011    Out      :   one element
00012    Job      :   find the kth smallest element in the array
00013    Notice   :   use the median_WIRTH() macro to get the median. 
00014                 MODIFIES THE INPUT ARRAY
00015 
00016                 Reference:
00017 
00018                   Author: Wirth, Niklaus 
00019                    Title: Algorithms + data structures = programs 
00020                Publisher: Englewood Cliffs: Prentice-Hall, 1976 
00021     Physical description: 366 p. 
00022                   Series: Prentice-Hall Series in Automatic Computation 
00023 
00024  ---------------------------------------------------------------------------*/
00025 
00026 pixelvalue kth_smallest(pixelvalue a[], int n, int k);
00027 
00028 
00029 /*---------------------------------------------------------------------------
00030    Function :   kth_smallest_double()
00031    In       :   array of doubles, # of elements in the array, rank k
00032    Out      :   one element
00033    Job      :   find the kth smallest element in the array
00034    Notice   :   use the median_double() macro to get the median. 
00035                 MODIFIES THE INPUT ARRAY
00036  ---------------------------------------------------------------------------*/
00037 
00038 double kth_smallest_double(double a[], int n, int k) ;
00039 #define median_double(a,n) \
00040 kth_smallest_double(a,n,(((n)&1)?((n)/2):(((n)/2)-1)))
00041 
00042 
00043 
00044 /*----------------------------------------------------------------------------
00045    Function :   opt_med3()
00046    In       :   pointer to array of 3 pixel values
00047    Out      :   a pixelvalue
00048    Job      :   optimized search of the median of 3 pixel values
00049    Notice   :   found on sci.image.processing
00050                 cannot go faster unless assumptions are made
00051                 on the nature of the input signal.
00052                 MODIFIES THE INPUT ARRAY
00053  ---------------------------------------------------------------------------*/
00054 
00055 pixelvalue
00056 opt_med3(
00057     pixelvalue  *   p
00058 ) ;
00059 
00060 /*----------------------------------------------------------------------------
00061    Function :   opt_med5()
00062    In       :   pointer to array of 5 pixel values
00063    Out      :   a pixelvalue
00064    Job      :   optimized search of the median of 5 pixel values
00065    Notice   :   found on sci.image.processing
00066                 cannot go faster unless assumptions are made
00067                 on the nature of the input signal.
00068                 MODIFIES THE INPUT ARRAY
00069  ---------------------------------------------------------------------------*/
00070 
00071 pixelvalue
00072 opt_med5(
00073     pixelvalue  *   p
00074 );
00075 
00076 /*----------------------------------------------------------------------------
00077    Function :   opt_med7()
00078    In       :   pointer to array of 7 pixel values
00079    Out      :   a pixelvalue
00080    Job      :   optimized search of the median of 7 pixel values
00081    Notice   :   found on sci.image.processing
00082                 cannot go faster unless assumptions are made
00083                 on the nature of the input signal.
00084                 MODIFIES THE INPUT ARRAY
00085  ---------------------------------------------------------------------------*/
00086 
00087 pixelvalue
00088 opt_med7(
00089     pixelvalue  *   p
00090 ) ;
00091 
00092 /*----------------------------------------------------------------------------
00093    Function :   opt_med9()
00094    In       :   pointer to an array of 9 pixelvalues
00095    Out      :   a pixelvalue
00096    Job      :   optimized search of the median of 9 pixelvalues
00097    Notice   :   in theory, cannot go faster without assumptions on the
00098                 signal.
00099                 Formula from:
00100                 XILINX XCELL magazine, vol. 23 by John L. Smith
00101   
00102                 The input array is modified in the process
00103                 The result array is guaranteed to contain the median
00104                 value
00105                 in middle position, but other elements are NOT sorted.
00106 
00107                 MODIFIES THE INPUT ARRAY
00108  ---------------------------------------------------------------------------*/
00109 
00110 pixelvalue
00111 opt_med9(
00112     pixelvalue  *   p
00113 ) ;
00114 
00115 
00116 /*----------------------------------------------------------------------------
00117    Function :   opt_med25()
00118    In       :   pointer to an array of 25 pixelvalues
00119    Out      :   a pixelvalue
00120    Job      :   optimized search of the median of 25 pixelvalues
00121    Notice   :   in theory, cannot go faster without assumptions on the
00122                 signal.
00123                 Formula from:
00124                 Graphic Gems source code
00125   
00126                 The input array is modified in the process
00127                 The result array is guaranteed to contain the median
00128                 value
00129                 in middle position, but other elements are NOT sorted.
00130  ---------------------------------------------------------------------------*/
00131  
00132 pixelvalue
00133 opt_med25(
00134     pixelvalue  *   p
00135 ) ;
00136 
00137 /*---------------------------------------------------------------------------
00138    Function :   median_pixelvalue()
00139    In       :   allocated array of pixelvalues, # of pixels in the array
00140    Out      :   1 pixel value
00141    Job      :   compute the median pixel value out of an array
00142    Notice   :   calls the fastest method depending on the number of
00143                 elements in input.
00144                 MODIFIES THE INPUT ARRAY
00145  ---------------------------------------------------------------------------*/
00146 
00147 
00148 
00149 pixelvalue median_pixelvalue(pixelvalue * a, int n);
00150 
00151 #endif

Generated on Wed Oct 26 13:08:52 2005 for SINFONI Pipeline Reference Manual by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001