www.pudn.com > source.zip > gaborutil.h
#ifndef GABORUTIL_H #define GABORUTIL_H #include#include #include #include #include #include #include #include #define gray unsigned char #define Alloc_dvector(rows) dvector(0,(rows)-1) #define Alloc_ivector(rows) ivector(0,(rows)-1) #define Alloc_dmatrix(rows,cols) dmatrix(0,(rows)-1,0,(cols)-1) #define Free_ivector(name,rows) free_ivector((name),0,(rows)-1) #define NR_END 0 #define MIN(a,b) (((a)<(b))?(a):(b)) #define MAX(a,b) (((a)>(b))?(a):(b)) #define SQ(x) ((x)*(x)) #define NUM_RAD_FREQ_SKIP 3 #define NUM_ORIENT 4 #define DEFAULT_SIGMA_U_FACTOR 0.283107266752 #define DEFAULT_SIGMA_V_FACTOR 0.351800608497 #define DEFAULT_SIGMA_FACTOR 1.0 #define DEFAULT_ALPHA 40 #define DEFAULT_COD 0.999 /* such that all filters are selected */ #define M_SQRT2 1.41421356237309504880 #define M_PI_4 0.785398163397448309616 #define M_PI 3.14159265358979323846 #define MAXPATHLEN 256 #define pgm_allocarray( cols, rows ) \ ((gray**) pm_allocarray( cols, rows, sizeof(gray) )) #define HALFCOMPLEXMATRIX_MAGIC "HALFCOMPLEXMATRIX" #define REALMATRIX_MAGIC "REALMATRIX" #define ABS(x) ((x)<0? -(x) : (x)) #define pgm_freearray( grays, rows ) pm_freearray( (char**) grays, rows ) #define FREE_ARG char* #define TINY 1.0e-20 /* A small number. */ #define COMBINE_TEXTURE 0 #define TEXTURE_COMBINE 1 #define COMBINE_COLOR 2 #define COLOR_COMBINE 3 #define COLOR_INIT_TEMP 4.0 #define COMBINE_INIT_TEMP 4.0 #define TEXTURE_INIT_TEMP 4.0 #define COMBINED 2 #define COLOR 1 #define TEXTURE 0 #define MAXDOUBLE 1.79769313486231570e+308 typedef double (*locale_energy_func)(int f, int row, int col, gray l); typedef struct { gray ***mask_frames; gray mask_value; int *class_index; } restrict_data; static double *E; double *dvector(long nl, long nh); int *ivector(long nl, long nh); double **dmatrix(long nrl, long nrh, long ncl, long nch); fftw_real *real_scaling(fftw_real *realim, fftw_real *out, int num_rows, int num_cols, int real_row_length, int out_row_length); fftw_real *mirror_pad_real(fftw_real *image, fftw_real *pad, int num_rows, int num_cols, int im_row_length, int pad_row_length, int row_pad, int col_pad); fftwnd_plan rfftw2d_create_plan_specific(int nx, int ny, fftw_direction dir, int flags, fftw_real *in, int istride, fftw_real *out, int ostride); void ft_even_gabor(fftw_complex *filter, int num_rows, int num_cols, double U, double SigmaU, double SigmaV, double theta); gray **halfcomplex_to_gray(fftw_complex *hcim, gray **img, int num_rows, int num_cols, int hcim_row_length); char ** pm_allocarray(int cols, int rows, int size); void pm_freearray(char **its, int rows); void save_halfcomplexmatrix(char *fname, int num_rows, int num_cols, int col_pad, fftw_complex *mx); fftw_real *extract_realsubimage(fftw_real *image, fftw_real *subimg, int num_rows, int num_cols, int im_row_length, int sub_row_length, int start_row, int start_col); void save_realmatrix(char *fname, int num_rows, int num_cols, int col_pad, fftw_real *mx); gray **real_to_gray(fftw_real *realim, gray **img, int num_rows, int num_cols, int real_row_length); fftw_real *load_realmatrix(char *fname, int *num_rows, int *num_cols, int col_pad); void free_dvector(double *v, long nl, long nh); void free_ivector(int *v, long nl, long nh); void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch); static int Ecmp(const void *i1, const void *i2) { double diff = E[*(int*)i1]-E[*(int*)i2]; return(diff == 0.0? 0 : (diff < 0.0? -1 : 1)); } double inverse(double **a, double **res, int n); double determinant(double **a, int n); void ludcmp(double **a, int n, int *indx, double *d); void lubksb(double **a, int n, int *indx, double *b); void eredmeny(double** a, double** e, int d, int n); void sorcsere(double** a, double** e, int xm, int k, int n); void foelem(double** a, double** e, int n, int k, int *d); void dekompf(double** a, double** e, int n,int *d); void yvektor(double* y,double** a, int n); void xvektor(double* x, double* y, double** a, int n); void inverz(double** a, double** e, int n); double det(double** a, int n, int d); #endif