// file: $USFS/class/image_analysis/v6.1/image_analysis_constants.h
//
// this file defines global paths, filenames and constants of the
// image analysis class

// make sure the definitions are made only once
//
#ifndef __ISIP_IMAGE_ANALYSIS_CONSTANTS
#define __ISIP_IMAGE_ANALYSIS_CONSTANTS

// isip include files
//
#ifndef __ISIP_INTEGRAL
#include <integral.h>
#endif

#ifndef __ISIP_INTEGRAL_CONSTANTS
#include <integral_constants.h>
#endif

// define the class name
//
#define IMAGE_ANALYSIS_CLASS_NAME (char_1*)"Image_analysis"

// define latest version of the software
//
#define IMAGA_VERSION (char_1*)"ANALYZE_IMAGE_V1.0"
#define IMAGA_MODEL_VERSION (char_1*)"ANALYZE_IMAGE_V1.0"

// define available modes
//
#define IMAGA_MODE (char_1*)"mode"
#define IMAGA_MODE_NONE (int_4)-1

#define IMAGA_MODE_TEST (int_4)0
#define IMAGA_MODE_TEST_NAME (char_1*)"test"

#define IMAGA_MODE_TRAIN (int_4)1
#define IMAGA_MODE_TRAIN_NAME (char_1*)"train"

#define IMAGA_MODE_ANALYSIS (int_4)2
#define IMAGA_MODE_ANALYSIS_NAME (char_1*)"analysis"

#define IMAGA_MODE_UPDATE (int_4)3
#define IMAGA_MODE_UPDATE_NAME (char_1*)"update"

// define available algorithms
//
#define IMAGA_ALG (char_1*)"algorithm"
#define IMAGA_ALG_NONE (int_4)-1

#define IMAGA_SEL (char_1*)"sel_vec"

#define IMAGA_ALG_HISTOGRAM (int_4)0
#define IMAGA_ALG_HISTOGRAM_NAME (char_1*)"histogram"

#define IMAGA_ALG_EDGEDET (int_4)1
#define IMAGA_ALG_EDGEDET_NAME (char_1*)"edge_detection"

#define IMAGA_ALG_FACTOR (int_4)2
#define IMAGA_ALG_FACTOR_NAME (char_1*)"factor_analysis"

#define IMAGA_ALG_FFT (int_4)3
#define IMAGA_ALG_FFT_NAME (char_1*)"fourier_transform"

#define IMAGA_ALG_DIFF (int_4)4
#define IMAGA_ALG_DIFF_NAME (char_1*)"variation_magnitude"

#define IMAGA_ALG_SD (int_4)5
#define IMAGA_ALG_SD_NAME (char_1*)"standard_deviation"

#define IMAGA_ALG_ENT (int_4)6
#define IMAGA_ALG_ENT_NAME (char_1*)"entropy"

#define IMAGA_ALG_RLE (int_4)7
#define IMAGA_ALG_RLE_NAME (char_1*)"run_length_coding"

#define IMAGA_ALG_FRACT (int_4)8
#define IMAGA_ALG_FRACT_NAME (char_1*)"fractal_dimension"

// define parameter keywords
//
#define IMAGA_MODEL_FILE (char_1*)"model_file"

// define segmentation related keywords
//
#define IMAGA_SEGMENTATION (char_1*)"segmentation"
#define IMAGA_SEGMENTATION_YES (char_1*)"yes"
#define IMAGA_SEGMENTATION_NO (char_1*)"no"

#define IMAGA_TRANSCRIPTION (char_1*)"transcription"

#define IMAGA_FRAME_SIZE_KEY (char_1*)"frame_size"
#define IMAGA_WINDOW_SIZE_KEY (char_1*)"window_size"

// define DCT computation related keywords
//
#define IMAGA_DCT_BLK_SIZE_KEY (char_1*)"dct_block_size"
#define IMAGA_DCT_FILTER_SIZE_KEY (char_1*)"dct_filter_size"

// define Gabor features related keywords
//
#define IMAGA_GABOR_SIGMA_X_KEY (char_1*)"gabor_sigma_x"
#define IMAGA_GABOR_SIGMA_Y_KEY (char_1*)"gabor_sigma_y"
#define IMAGA_GABOR_ALPHA_KEY (char_1*)"gabor_alpha"
#define IMAGA_GABOR_WIN_SCALE_KEY (char_1*)"gabor_win_scale"

//-----------------------------------------------------------------------------
//
// define histogram-specific constants
//
//-----------------------------------------------------------------------------
//
#define IMAGA_HIST_MODEL_LINES (int_4)8
#define IMAGA_HIST_COMMENT ISIP_POUND
#define IMAGA_HIST_COMMENT_FORMAT (char_1*)"%c %s\n%c\n"
#define IMAGA_HIST_ALG_COMMENT (char_1*)"define the type of the model file"
#define IMAGA_HIST_PARAM_COMMENT (char_1*)"define the parameters of the histogram"
#define IMAGA_HIST_COLOR_COMMENT (char_1*)"define the red, green and blue indices"
#define IMAGA_HIST_DATA_COMMENT (char_1*)"define the amount of data used to generate the histograms"
#define IMAGA_HIST_VALUES_COMMENT (char_1*)"specify the histogram values"
#define IMAGA_HIST_CWTS_COMMENT (char_1*)"specify the color weights"
#define IMAGA_HIST_SCAL_COMMENT (char_1*)"specify the scaling function"

// define the constants to be used for the training mode
//
#define IMAGA_HIST_MIN (float_8)0
#define IMAGA_HIST_MAX (float_8)255
#define IMAGA_HIST_NBINS (int_4)10
#define IMAGA_HIST_RPTR (int_4)0
#define IMAGA_HIST_GPTR (int_4)1
#define IMAGA_HIST_BPTR (int_4)2
#define IMAGA_HIST_WRED (float_4)0.33
#define IMAGA_HIST_WGRN (float_4)0.33
#define IMAGA_HIST_WBLU (float_4)0.33
#define IMAGA_HIST_ASCL (int_4)-100
#define IMAGA_HIST_BSCL (int_4)100

// define formats used to parse parameter file data
//
#define IMAGA_FORMAT_0 (char_1*)"%s%*s%s"
#define IMAGA_FORMAT_1 (char_1*)"%ld%ld%e"
#define IMAGA_FORMAT_2 (char_1*)"%s%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld"

// declare the block size
//
#define IMAGA_DEFAULT_BSIZE (int_4)256

// define parameters related to parsing the model file
//
#define IMAGA_HIST_NPARAMS (int_4)14

//-----------------------------------------------------------------------------
//
// define segmentation-related constants
//
//-----------------------------------------------------------------------------
//
#define IMAGA_TRANSCRIPTION_TAG (char_1*)"Class"
#define IMAGA_END_POLYGON (int_4)-1

//-----------------------------------------------------------------------------
//
// define edge detection-specific constants
//
//-----------------------------------------------------------------------------
//
#define IMAGA_EDGE_WOFF (int)0
#define IMAGA_EDGE_HOFF (int)0

// define the constant for PI
//
#define PI 3.14

// define the constants to be used for the training mode
//
#define IMAGA_EDGE_MODEL_LINES (int_4)7
#define IMAGA_EDGE_FACTOR (float_4)0.3
#define IMAGA_EDGE_THRESHOLD_HIGH (float_4)60
#define IMAGA_EDGE_THRESHOLD_LOW (float_4)30
#define IMAGA_EDGE_XMEAN (float_4)0.0
#define IMAGA_EDGE_YMEAN (float_4)0.0
#define IMAGA_EDGE_SIGMA (float_4)2.0
#define IMAGA_EDGE_MSIZE (int_4)3

// define the constants to be used for computing the length of lines
//
#define IMAGA_EDGE_COLMAX (int_4)255
#define IMAGA_EDGE_COLMIN (int_4)0
#define IMAGA_EDGE_HDEV (int_4)2
#define IMAGA_EDGE_VDEV (int_4)5
#define IMAGA_EDGE_SLIM (int_4)25
#define IMAGA_EDGE_LLIM (int_4)45
#define IMAGA_EDGE_PINCR (int_4)4
#define IMAGA_EDGE_PIXEL (int_4)40
#define IMAGA_EDGE_MAX (float_4)0.0
#define IMAGA_EDGE_MIN (float_4)1000.0
#define IMAGA_EDGE_MNUM (char_1*)"P5"
#define IMAGA_EDGE_RCNST (float_4)0.299
#define IMAGA_EDGE_GCNST (float_4)0.587
#define IMAGA_EDGE_BCNST (float_4)0.114
#define IMAGA_EDGE_LMIN (float_4)0.0
#define IMAGA_EDGE_LMAX (float_4)1024.0

// define the constants to be written into the model file
//
#define IMAGA_EDGE_NPARAMS (int_4)13
#define IMAGA_EDGE_NBINS (int_4)10
#define IMAGA_EDGE_ASCL (float_4)-100
#define IMAGA_EDGE_BSCL (float_4)100
#define IMAGA_EDGE_LWGT (float_4)0.33
#define IMAGA_EDGE_SWGT (float_4)0.33

//-----------------------------------------------------------------------------
//
// define edge detection-specific constants
//
//-----------------------------------------------------------------------------
//
#define IMAGA_EDGE_PARAM_COMMENT (char_1*)"define the parameters of the edgedetection"
#define IMAGA_EDGE_DATA_COMMENT (char_1*)"define the amount of data used to generate the edge detection"
#define IMAGA_EDGE_LWGTS_COMMENT (char_1*)"specify the line weights"
#define IMAGA_EDGE_VALUES_COMMENT (char_1*)"specify the line numbers"

//-----------------------------------------------------------------------------
//
// define feature analysis-specific constants
//
//-----------------------------------------------------------------------------
//
#define IMAGA_HE_VECTORS (char_1*)"num_of_vectors"
#define IMAGA_HE_FRAMES (char_1*)"num_of_frames"
#define IMAGA_HE_READ_VECTORS (char_1*)"num_of_trans_vectors"
#define IMAGA_HE_FEATURE_FNAME (char_1*)"feature_model_file"
#define IMAGA_HE_COVAR (char_1*)"covariance_matrix_file"
#define IMAGA_HE_MEAN (char_1*)"mean_vector_file"
#define IMAGA_HE_EIGEN_VALUES (char_1*)"eigen_values_file"
#define IMAGA_HE_EIGEN_VECTORS (char_1*)"eigen_vectors_file"
#define IMAGA_HE_TRANS_VECTORS_FNAME (char_1*)"transform_vectors_file"
#define IMAGA_HE_TRANS_MATRIX_FNAME (char_1*)"transform_matrix_file"
#define IMAGA_HE_DEVIATION (float_4)0.0000000000005

#define IMAGA_HE_VECTORS_VALUE 181
#define IMAGA_HE_READ_VECTORS_VALUE 10
#define IMAGA_HE_NPARAMS (int_4)23

#define IMAGA_HE_MODEL_LINES (int)12
#define IMAGA_HE_MEAN_COMMENT (char_1*)"define the values of the mean"
#define IMAGA_HE_COVAR_COMMENT (char_1*)"define the values of the covariance matrix"
#define IMAGA_HE_PARAM_COMMENT (char_1*)"define the parameters of the principal components analysis"
#define IMAGA_HE_FEATURE_FILE (char_1*)"$USFS/util/analyze_image/v1.0/feature.dat"
#define IMAGA_HE_MEAN_FILE (char_1*)"$USFS/util/analyze_image/v1.0/mean_vector.dat"
#define IMAGA_HE_COVAR_FILE (char_1*)"$USFS/util/analyze_image/v1.0/covariance_matrix.dat"
#define IMAGA_HE_EIGEN_VALUES_FILE (char_1*)"$USFS/util/analyze_image/v1.0/eigen_values.dat"
#define IMAGA_HE_EIGEN_VECTORS_FILE (char_1*)"$USFS/util/analyze_image/v1.0/eigen_vectors.dat"
#define IMAGA_HE_TRANS_VECTORS_FILE (char_1*)"$USFS/util/analyze_image/v1.0/transform_vectors.dat"
#define IMAGA_HE_TRANS_MATRIX_FILE (char_1*)"$USFS/util/analyze_image/v1.0/transform_matrix.dat"

#define IMAGA_SEL_VECTOR_COMMENT (char_1*)"# define the selecttion vector"

#define IMAGA_FFT_BASE (int_4)2
#define IMAGA_FFT_NBINS (int_4)10
#define IMAGA_FFT_MIN (int_4)0
#define IMAGA_FFT_MAX (int_4)300
#define IMAGA_FFT_NBINS (int_4)10
#define IMAGA_FFT_MODEL_LINES (int_4)6
#define IMAGA_FFT_NPARAMS (int_4)7
#define IMAGA_FFT_ASCL (int_4)-100
#define IMAGA_FFT_BSCL (int_4)100

#define IMAGA_DIFF_MIN (int_4)0
#define IMAGA_DIFF_MAX (int_4)255
#define IMAGA_DIFF_NBINS (int_4)256
#define IMAGA_DIFF_RPTR (int_4)0
#define IMAGA_DIFF_GPTR (int_4)1
#define IMAGA_DIFF_BPTR (int_4)2
#define IMAGA_DIFF_ASCL (int_4)-100
#define IMAGA_DIFF_BSCL (int_4)100
#define IMAGA_DIFF_NPARAMS (int_4)11
#define IMAGA_DIFF_MODEL_LINES (int_4)6
#define IMAGA_DIFF_VALUES_COMMENT (char_1*)"specify the sharpness of the image"

#define IMAGA_SD_VALUES_COMMENT (char_1*)"specify the standard deviations"
#define IMAGA_SD_MODEL_LINES (int_4)6
#define IMAGA_SD_ASCL (int_4)-100
#define IMAGA_SD_BSCL (int_4)100
#define IMAGA_SD_WRED (float_8)0.33
#define IMAGA_SD_WGRN (float_8)0.33
#define IMAGA_SD_WBLU (float_8)0.33
#define IMAGA_SD_NPARAMS (int_4)11
#define IMAGA_SD_NO_COLORS (int_4)3

#define IMAGA_ENT_MIN (int_4)0
#define IMAGA_ENT_MAX (int_4)255
#define IMAGA_ENT_NBINS (int_4)256
#define IMAGA_ENT_MODEL_LINES (int_4)7
#define IMAGA_ENT_ASCL (int_4)-100
#define IMAGA_ENT_BSCL (int_4)100
#define IMAGA_ENT_WRED (float_8)0.33
#define IMAGA_ENT_WGRN (float_8)0.33
#define IMAGA_ENT_WBLU (float_8)0.33
#define IMAGA_ENT_NPARAMS (int_4)14

#define IMAGA_RLE_MID (int_4)128
#define IMAGA_RLE_VALUES_COMMENT (char_1*)"the compression ratio of the file"
#define IMAGA_RLE_MODEL_LINES (int_4)4
#define IMAGA_RLE_NPARAMS (int_4)4
#define IMAGA_RLE_BLK_SIZE (int_4)8

#define IMAGA_DCT_MID (int_4)128
#define IMAGA_DCT_FEATURE_SIZE (int_4)32

// define some global constants
//
static const float_4 rle_norm_d[IMAGA_RLE_BLK_SIZE][IMAGA_RLE_BLK_SIZE] = {
  {16.0, 11.0, 10.0, 16.0, 24.0, 40.0, 51.0, 61.0},
  {12.0, 12.0, 14.0, 19.0, 26.0, 58.0, 60.0, 55.0},
  {14.0, 13.0, 16.0, 24.0, 40.0, 57.0, 69.0, 56.0},
  {14.0, 17.0, 22.0, 29.0, 51.0, 87.0, 80.0, 62.0},
  {18.0, 22.0, 37.0, 56.0, 68.0, 109.0, 103.0, 77.0},
  {24.0, 35.0, 55.0, 64.0, 81.0, 104.0, 113.0, 92.0},
  {49.0, 64.0, 78.0, 87.0, 103.0, 121.0, 120.0, 101.0},
  {72.0, 92.0, 95.0, 98.0, 112.0, 100.0, 103.0, 99.0}
};

#define IMAGA_NUM_CATEGORIES 12
#define IMAGA_NUM_ZEROLENGTHS 16

static const int_4 rle_dc_codes_d[IMAGA_NUM_CATEGORIES] = {
  2, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9
};

static const int_4 rle_ac_codes_d[IMAGA_NUM_ZEROLENGTHS][IMAGA_NUM_CATEGORIES - 2] = {
  {2, 2, 3, 4, 5, 7, 8, 10, 16, 16},
  {4, 5, 7, 9, 11, 16, 16, 16, 16, 16},
  {5, 8, 10, 12, 16, 16, 16, 16, 16, 16},
  {6, 9, 12, 16, 16, 16, 16, 16, 16, 16},
  {6, 10, 16, 16, 16, 16, 16, 16, 16, 16},
  {7, 11, 16, 16, 16, 16, 16, 16, 16, 16},
  {7, 12, 16, 16, 16, 16, 16, 16, 16, 16},
  {8, 12, 16, 16, 16, 16, 16, 16, 16, 16},
  {9, 15, 16, 16, 16, 16, 16, 16, 16, 16},
  {9, 16, 16, 16, 16, 16, 16, 16, 16, 16},
  {9, 16, 16, 16, 16, 16, 16, 16, 16, 16},
  {10, 16, 16, 16, 16, 16, 16, 16, 16, 16},
  {10, 16, 16, 16, 16, 16, 16, 16, 16, 16},
  {11, 16, 16, 16, 16, 16, 16, 16, 16, 16},
  {16, 16, 16, 16, 16, 16, 16, 16, 16, 16},
  {16, 16, 16, 16, 16, 16, 16, 16, 16, 16}
};

#define IMAGA_FRACT_FDIST (int_4)1
#define IMAGA_FRACT_SDIST (int_4)2
#define IMAGA_FRACT_MODEL_LINES (int_4)6
#define IMAGA_FRACT_ASCL (int_4)-100
#define IMAGA_FRACT_BSCL (int_4)100
#define IMAGA_FRACT_WRED (float_8)0.33
#define IMAGA_FRACT_WGRN (float_8)0.33
#define IMAGA_FRACT_WBLU (float_8)0.33
#define IMAGA_FRACT_NPARAMS (int_4)11

#define NR_END 1
#define FREE_ARG char*

#define IMAGA_GABOR_NUM_RAD_FRQ (int_4)5
#define IMAGA_GABOR_NUM_ORIENT (int_4)4
#define IMAGA_GABOR_SIGMA_X (float_8)5.0
#define IMAGA_GABOR_SIGMA_Y (float_8)5.0
#define IMAGA_GABOR_ALPHA (float_8)0.00002
#define IMAGA_GABOR_WIN_SCALE (int_4)4

// end of file
//
#endif
