// file: $USFS/class/image_analysis/v6.2/image_analysis.h
//

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

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

// forward declaration of classes
//
#ifndef __ISIP_LINK_LIST
#include <link_list.h>
#endif

// forward class definitions
//
class Ppm;
class Polygon;

// Image_analysis: a class that computes 181 features on a specified region
// separated from ppm images. the region can be chosen from the following
// list: tree, foliage, grass, bush, sky, background sky and a whole image
//
class Image_analysis {
  
  //---------------------------------------------------------------------------
  //
  // protected data
  //
  //---------------------------------------------------------------------------
protected:
  
  // declare a variable for debugging
  //
  int_4 debug_level_d;
  
  // parameter filename information
  //
  char_1* param_version_d;	// version of parameter file
  char_1* param_fname_d;	// parameter filename  

  // model filename information
  //
  char_1* model_version_d;	// version of parameter file
  char_1* model_fname_d;	// model filename
  char_1* model_name_d;		// model name - hsbe, msbe or lsbe

  // parameter for specifying selection of feature vectors
  //
  int_4* sel_vec_d;		// feature vectors selection
  
  // parameters related to the choice of analysis algorithm and mode
  //
  int_4 algorithm_d;		// choice of algorithm specified in param file
  int_4 mode_d;			// test or train specified in param file

  // segmentation related information
  //
  logical_1 seg_flag_d;      // segmentation flag
  char_1* transcription_d;   // transcription used in segmentation

  Link_list* polygon_list_d;  // a linked list of polygons related to this
                              // transcription

  // parameters related to windowing a frame of image data
  //
  int_4 frm_size_d;         // frame size
  int_4 win_size_d;         // window size
  
  //---------------------------------------------------------------------------
  //
  // parameters related to histogram-based processing
  // 
  //---------------------------------------------------------------------------
  
  // declare the reference model parameters
  //
  int_4 hist_r_nbins_d;		// number of bins from the model file
  int_4 hist_r_redp_d;		// index of the red color from the model file
  int_4 hist_r_grnp_d;		// index of the green color from the model file
  int_4 hist_r_blup_d;		// index of the blue color from the model file
  int_4 hist_r_npxls_d;		// reference number of pixels
  int_4 hist_r_nimages_d;	// number of images processed in this model
  int_4 hist_r_nblks_d;         // number of image blocks processed in this
                                // model

  float_8 hist_r_min_d;		// minimum value of historgram
  float_8 hist_r_max_d;		// maximum value of histogram
  float_8* hist_r_rpdf_d;	// reference distribution of red 
  float_8* hist_r_gpdf_d;	// reference distribution of green
  float_8* hist_r_bpdf_d;	// reference distribution of blue
  float_8* hist_r_ylwpdf_d;	// reference distribution of yellow 
  float_8* hist_r_brnpdf_d;	// reference distribution of brown
  float_8* hist_r_rcval_d;	// center values of the red color
  float_8* hist_r_gcval_d;	// center values of the green color
  float_8* hist_r_bcval_d;	// center values of the blue color
  float_8* hist_r_ylwcval_d;	// center values of the yellow color
  float_8* hist_r_brncval_d;	// center values of the brown color
  
  // declare parameters involved in scaling distance measures
  //
  float_8 hist_ascale_d;        // scaling factors related to sbe
  float_8 hist_bscale_d;	// sbe_a = hist_ascale_d * rms_scaled +
				// hist_bscale_d
  float_8 hist_rwgt_d;		// weights related to SBE
  float_8 hist_gwgt_d;		// 
  float_8 hist_bwgt_d;		//
  
  // declare parameters involved in computing features of images
  //
  int_4 hist_t_npxls_d;		// number of pixels tested
  int_4 hist_t_nimages_d;	// number of images tested
  int_4 hist_t_nblks_d;         // number of image blocks tested
  float_8* hist_t_rpdf_d;	// computed distribution of red
  float_8* hist_t_gpdf_d;	// computed distribution of green
  float_8* hist_t_bpdf_d;	// computed distribution of blue
  float_8* hist_t_ylwpdf_d;	// computed distribution of yellow
  float_8* hist_t_brnpdf_d;	// computed distribution of brown
  float_8* hist_t_rcval_d;	// computed center values of the red colors
  float_8* hist_t_gcval_d;	// computed center values of the green colors
  float_8* hist_t_bcval_d;	// computed center values of the blue colors
  float_8* hist_t_ylwcval_d;	// computed center values of the yellow colors
  float_8* hist_t_brncval_d;	// computed center values of the brown colors
  
  //---------------------------------------------------------------------------
  //
  // parameters related to edge detection processing
  // 
  //---------------------------------------------------------------------------
  
  // declare reference parameters
  //
  int_4 edge_r_nbins_d;		// number of bins from the model file 
  int_4 edge_r_msize_d;		// reference mask size from the model file
  int_4 edge_r_tlines_d;	// reference total number of lines
  int_4 edge_r_nimages_d;	// reference total number of images processed
  int_4 edge_r_nblks_d;         // reference total number of image blocks
                                // processed
  
  float_8 edge_r_lmin_d;	// minimum value of the length of the line
  float_8 edge_r_lmax_d;	// maximum value of the length of the line
  float_8 edge_r_xmean_d;	// mean value from the model file
  float_8 edge_r_ymean_d;	// reference ymean from the model file
  float_8 edge_r_sigma_d;	// reference sigma from the model file
  float_8 edge_r_rfact_d;	// reference ratio factor from the model file
  float_8* edge_r_lpdf_d;	// reference distribution of the lines
  float_8* edge_r_lcval_d;	// reference center values of the bin

  // declare parameters involved in scaling measures
  //
  float_8 edge_ascale_d;	// scaling functions related to sbe 
  float_8 edge_bscale_d;	// sbe = edge_ascale_d * rms_scaled +
			        // edge_bscale_d 
  float_8 edge_lwgt_d;		// weight factors related to sbe
  float_8 edge_swgt_d;		// 
  
  // declare parameters involved in computing features of images
  //
  int_4 edge_t_tlines_d;	// computed number of lines
  int_4 edge_t_nimages_d;	// number of images
  int_4 edge_t_nblks_d;         // number of image blocks
  
  float_8* edge_t_lpdf_d;	// computed distribution of lines
  float_8* edge_t_lcval_d;	// computed center values of the bins
  float_8 edge_perlong_t_lines_d;	// computed number of long lines
  float_8 edge_pershrt_t_lines_d;	// computed number of short lines

  //---------------------------------------------------------------------------
  //
  // parameters related to factor analysis
  // 
  //---------------------------------------------------------------------------
  
  // declare parameters involved in computing features of images
  //
  int_4 pca_t_num_vectors_d;	// number of feature vectors
  int_4 pca_t_num_frames_d;	// number of frames (image files)
  int_4 pca_t_values_read_d;	// number of required vectors to be read
  int_4 pca_t_npxls_d;		// number of pixels processed
  int_4 pca_t_nimages_d;	// number of images processed
  int_4 pca_t_nblks_d;	        // number of image blocks processed

  float_4* pca_t_data_d;	// feature values for factor analysis
  float_4* covar_t_data_d;	// computed covariance data
  float_4* mean_t_data_d;	// mean vector of the features
  
  //---------------------------------------------------------------------------
  //
  // parameters related to differential entropy calculations
  // 
  //---------------------------------------------------------------------------
  
  // declare reference model parameters
  //
  int_4 dent_r_min_d;		// minimum differential entropy value
  int_4 dent_r_max_d;		// maximum differential entropy value
  int_4 dent_r_nbins_d;		// number of bins
  int_4 dent_r_npxls_d;		// number of pixels processed
  int_4 dent_r_nimages_d;	// number of images processed
  int_4 dent_r_nblks_d;         // number of blocks processed
  float_8 dent_r_sumred_d;	// reference values for differential entropy
  float_8 dent_r_sumgrn_d;	// 
  float_8 dent_r_sumblu_d;	//
  
  // declare the parameters involved in scaling measures
  //
  int_4 dent_ascale_d;		// scaling factors related to sbe
  int_4 dent_bscale_d;		// sbe = dent_scale_d * rms_scaled +
				// dent_bscale_d
  
  // declare parameters involved in computing features of images
  //
  float_8* dent_t_red_d;	// computed red value differential entropy
  float_8* dent_t_grn_d;	// computed green value differential entropy
  float_8* dent_t_blu_d;	// computed blue value differential entropy
  float_8 dent_t_sumred_d;	// 
  float_8 dent_t_sumgrn_d;	//
  float_8 dent_t_sumblu_d;	//
  
  //---------------------------------------------------------------------------
  //
  // parameters related to standard deviation
  // 
  //---------------------------------------------------------------------------
  
  // declare the reference model parameters
  //
  int_4 sd_r_npxls_d;		// reference number of pixels
  int_4 sd_r_nimages_d;		// number of images processed in this model
  int_4 sd_r_nblks_d;           // number of image blocks processed
  
  float_8 sd_r_red_d;		// red reference standard deviations
  float_8 sd_r_grn_d;		// green reference standard deviations
  float_8 sd_r_blu_d;		// blue reference standard deviations
  float_8 sd_r_mean_red_d;	// mean of red pixel values
  float_8 sd_r_mean_grn_d;	// mean of green pixel values
  float_8 sd_r_mean_blu_d;	// mean of blue pixel values

  // declare the parameters involved in scaling measures
  //
  float_8 sd_ascale_d;		// scaling factors related to sbe
  float_8 sd_bscale_d;		// sbe_a = sd_ascale_d * rms_scaled
				// sd_bscale_d
  float_8 sd_rwgt_d;		// weights related to SBE
  float_8 sd_gwgt_d;		// 
  float_8 sd_bwgt_d;		// 

  // declare the parameters involved in computing features of images
  //
  float_8 sd_t_red_d;		// standard deviation of the red
  float_8 sd_t_grn_d;		// standard deviation of the green
  float_8 sd_t_blu_d;		// standard deviation of the blue 

  //---------------------------------------------------------------------------
  //
  // parameters related to the average code length of huffman code
  // 
  //---------------------------------------------------------------------------
  
  // declare the reference model parameters
  //
  int_4 huf_r_min_d;		// minimum pixel value
  int_4 huf_r_max_d;		// maximum pixel value
  int_4 huf_r_nbins_d;		// number of bins
  int_4 huf_r_npxls_d;		// number of pixels
  int_4 huf_r_nimages_d;        // number of images tested or trained
  int_4 huf_r_nblks_d;          // number of image blocks processed
  float_8 huf_r_red_d;		// parameters for reference of huffman code 
  float_8 huf_r_grn_d;		//
  float_8 huf_r_blu_d;		//
  float_8* huf_r_rpdf_d;        // buffers to store the distribution
  float_8* huf_r_gpdf_d;        //
  float_8* huf_r_bpdf_d;	//

  // declare the parameters involved in scaling measures
  //
  int_4 huf_ascale_d;		// scaling factors related to sbe
  int_4 huf_bscale_d;		// sbe_a = ent_ascale_d * rms_scaled +
				// ent_bscale_d
  float_8 huf_rwgt_d;		// weights related to SBE
  float_8 huf_gwgt_d;		// 
  float_8 huf_bwgt_d;		// 
  
  // declare the parameters involved in computing features of images
  //
  float_8 huf_t_red_d;		// parameters for testing of huffman code
  float_8 huf_t_grn_d;		// 
  float_8 huf_t_blu_d;		//	
  
  //---------------------------------------------------------------------------
  //
  // parameters related to the jpeg dct coding (8 x 8 dct transformation and 
  // run length coding)
  // 
  //---------------------------------------------------------------------------
  
  // declare the reference model parameters
  //
  int_4 rle_r_redbits_d;        // number of bits for red in rle  
  int_4 rle_r_grnbits_d;	// number of bits for green in rle  
  int_4 rle_r_blubits_d;        // number of bits for blue in rle  
  int_4 rle_r_nimages_d;	// number of images processed
  int_4 rle_r_npxls_d;		// number of pixels processed
  int_4 rle_r_nblks_d;          // number of image blocks processed
  
  float_4 rle_r_compression_d;	// reference compression values using rle
  float_4 rle_r_rpdc_d;		// number of pixel values for red
  float_4 rle_r_gpdc_d;         // number of pixel values for green
  float_4 rle_r_bpdc_d;         // number of pixel values for blue
  float_4** rle_r_cos_d;        // computed cosine coefficients for dct
  float_4* rle_r_red_d;		// manipulation arrays for red 
  float_4* rle_r_grn_d;		// manipulation arrays for green
  float_4* rle_r_blu_d;		// manipulation arrays for blue

  // declare the parameters involved in computing features of images
  //
  float_4 rle_t_compression_d;	// compression values for testing using rle

  //---------------------------------------------------------------------------
  //
  // parameters related to the dct-based feature extraction
  //
  //---------------------------------------------------------------------------

  // declare the reference model parameters
  //
  int_4 dct_r_nimages_d;	// number of images processed
  int_4 dct_r_npxls_d;		// number of pixels processed
  int_4 dct_r_nblks_d;          // number of image blocks processed
  
  float_4** dct_r_cos_d;        // computed cosine coefficients for dct
  float_4** dct_norm_d;         // normalization matrix
  float_4* dct_r_red_d;		// manipulation arrays for red 
  float_4* dct_r_grn_d;		// manipulation arrays for green
  float_4* dct_r_blu_d;		// manipulation arrays for blue

  // declare the parameters involved in dct transformation
  //
  int_4 dct_blk_size_d;         // the block size
  int_4 dct_filter_size_d;      // the size for frequency domain filtering
    
  // declare the feature parameters
  //
  float_4* dct_t_red_filter_d;  // features subtracted from the dct
                                // coefficients for the red pixels
  float_4* dct_t_grn_filter_d;  // features subtracted from the dct
                                // coefficients for the green pixels
  float_4* dct_t_blu_filter_d;  // features subtracted from the dct
                                // coefficients for the blue pixels
  
  //---------------------------------------------------------------------------
  //
  // parameters related to the fractal dimensions
  // 
  //---------------------------------------------------------------------------
  
  // declare the reference model parameters
  //
  int_4 fract_r_nimages_d;	// number of images processed	      
  int_4 fract_r_npxls_d;	// number of pixels processed
  int_4 fract_r_nblks_d;        // number of image blocks processed
  float_4 fract_r_dimred_d;     // reference parameter values for fractal
  float_4 fract_r_dimgrn_d;     // dimension
  float_4 fract_r_dimblu_d;	//

  // declare the parameters involved in scaling measures
  //
  int_4 fract_ascale_d;		// scaling factors related to sbe
  int_4 fract_bscale_d;		// sbe_a = fract_ascale_d * rms_scaled
				// fract_bscale_d
  float_8 fract_rwgt_d;		// weights related to SBE
  float_8 fract_gwgt_d;		// 
  float_8 fract_bwgt_d;		//
  
  // declare the parameters involved in computing features of images
  //
  float_4 fract_t_dimred_d;	// computed fractal dimension for red
  float_4 fract_t_dimgrn_d;	// computed fractal dimension for green
  float_4 fract_t_dimblu_d;	// computed fractal dimension for blue

  float_4 fract_t_fir_ared_d;   // computed sum of the areas for red
  float_4 fract_t_fir_agrn_d;   // computed sum of the areas for green   
  float_4 fract_t_fir_ablu_d;	// computed sum of the areas for blue
  float_4 fract_t_sec_ared_d;	// parameter related to areas for non
  float_4 fract_t_sec_agrn_d;	// zero condition
  float_4 fract_t_sec_ablu_d;	//

  //---------------------------------------------------------------------------
  //
  // parameters related to Gabor filters-based features
  // 
  //---------------------------------------------------------------------------

  // declare reference model parameters
  //
  int_4 gabor_r_npxls_d;          // number of pixels computed
  int_4 gabor_r_nblks_d;          // number of blocks computed
  float_8* gabor_feature_d;       // the computed feature vector
  
  // declare parameters involved in computing impulse responses of Gabor
  // filters
  //
  int_4 gabor_num_col_d;          // number of columns
  int_4 gabor_num_row_d;          // number of rows
  int_4 gabor_num_rad_frq_d;      // number of radial frequencies used
  int_4 gabor_num_orient_d;       // number of orientations used
  float_8* gabor_rad_frq_d;       // an array of all radial frequencies in use
  float_8* gabor_orient_d;        // an array of all orientations in use
  float_8 gabor_sigma_x_d;        // sigma x
  float_8 gabor_sigma_y_d;        // sigma y

  // declare parameters involved in computing feature vectors
  //
  int_4 gabor_feature_dim_d;  // dimension of feature vector
  float_8 gabor_alpha_d;          // alpha value used in nonlinear
                                  // transformation
  int_4 gabor_win_scale_d;        // parameter relates gaussian window size
                                  // to corresponding sigma value
  
  //---------------------------------------------------------------------------
  //
  // public members
  //
  //---------------------------------------------------------------------------
public:
  
  // required methods
  //
  char_1* name_cc();
  volatile void error_handler_cc(char_1* method_name, char_1* message);
  logical_1 debug_cc(FILE* fp, char_1* message);
  logical_1 set_debug_cc(int_4 debug_level);
   
  // destructor/constructor
  //
  ~Image_analysis();
  Image_analysis();
  
  // load/write methods
  //
  logical_1 load_cc(char_1* param_file);
  logical_1 load_model_cc();
  logical_1 write_cc();
  
  // initialize methods
  //
  logical_1 init_cc();
  
  // methods for processing multiple model files
  //
  logical_1 get_nmods_cc(int_4& num_models, char_1**& param_file,
			 char_1* list_param_file);
  
  // process methods: these methods control the type of computation
  //
  // process methods for sbe classification
  //
  logical_1 process_cc(float_8& sbe_value, char_1* image_fname);
  logical_1 test_cc(float_8& sbe_value, char_1* image_fname);
  logical_1 train_cc(char_1* image_fname);
  logical_1 update_cc(float_8& sbe_value, char_1* image_fname);

  // process methods for segmentation-based cheating experiments
  //
  logical_1 process_cc(float_8& sbe_value, char_1* image_fname,
		       char_1* seg_fname);
  logical_1 test_cc(float_8& sbe_value, char_1* image_fname,
		    char_1* seg_fname);
  logical_1 train_cc(char_1* image_fname, char_1* seg_fname);

  // process methods for image segmentation
  //
  logical_1 train_cc(uint_1* blk_r, uint_1* blk_g, uint_1* blk_b,
		     int_4 offset_w, int_4 offset_h, int_4 width,
		     int_4 height);
  logical_1 test_cc(float_8& distance, uint_1* blk_r, uint_1* blk_g,
		    uint_1* blk_b, int_4 offset_w, int_4 offset_h,
		    int_4 width, int_4 height);
  
  // process methods for edge and line detection
  //
  logical_1 detect_lines_cc(char_1* in_img_fname, char_1* out_data_fname,
			    char_1* out_img_fname);

  // display methods
  //
  logical_1 display_model_cc(FILE* fp);
  
  // computational methods
  //
  logical_1 sbe_components_cc();        // for sbe classification
  logical_1 seg_components_cc();        // for image segmentation

  //--------------------------------------------------------------------------
  //
  // segmentation related methods
  //
  //--------------------------------------------------------------------------
  
  // check the segmentation flag
  //
  logical_1 check_segflag_cc();

  // read data from the segmentation file
  // 
  logical_1 load_polygons_cc(char_1* seg_fname); 

  // determine if a given pixel is inside one of the listed polygons or not
  //
  logical_1 is_inside_cc(int_4 x_val, int_4 y_val);
  logical_1 is_inside_cc(int_4 x_val, int_4 y_val, char_1*& trans);
  
  // pass parameters to Image_segmentation class
  //
  int_4 mode_cc();
  int_4 frm_size_cc();
  int_4 win_size_cc();
  int_4 dct_blk_size_cc();
  
  //---------------------------------------------------------------------------
  //
  // private members
  //
  //---------------------------------------------------------------------------
private:
  
  // input/output methods
  //
  FILE* open_cc(char_1* filename, int_4 mode_a);
  logical_1 close_cc(FILE* fp);
  logical_1 write_cc(float_4* out_image, char_1* fname_a,
		     int_4 width, int_4 height);
  logical_1 hist_write_cc();
  logical_1 edge_write_cc();
  logical_1 pca_write_cc();
  logical_1 dent_write_cc();
  logical_1 sd_write_cc();
  logical_1 ent_write_cc();
  logical_1 rle_write_cc();
  logical_1 fract_write_cc();
  
  // get methods
  //
  logical_1 get_mode_cc(FILE* fp);
  logical_1 get_algorithm_cc(FILE* fp);
  logical_1 get_modelfile_cc(FILE* fp);
  logical_1 get_selvec_cc(FILE* fp);
  logical_1 get_segflag_cc(FILE* fp);
  logical_1 get_trans_cc(FILE* fp);
  logical_1 get_frmsize_cc(FILE* fp);
  logical_1 get_winsize_cc(FILE* fp);
  logical_1 get_dct_blksize_cc(FILE* fp);
  logical_1 get_dct_filtersize_cc(FILE* fp);
  logical_1 get_gabor_sigma_x_cc(FILE* fp);
  logical_1 get_gabor_sigma_y_cc(FILE* fp);
  logical_1 get_gabor_alpha_cc(FILE* fp);
  logical_1 get_gabor_win_scale_cc(FILE* fp);
  
  //---------------------------------------------------------------------------
  //
  // histogram related methods
  //
  //---------------------------------------------------------------------------
  
  // load methods
  //
  logical_1 hist_load_cc();

  // computation methods
  //
  logical_1 hist_test_cc(float_8& sbe_value, char_1* image_fname);
  logical_1 hist_test_cc(float_8& sbe_value, char_1* image_fname,
			 char_1* seg_fname);  
  logical_1 hist_test_cc(float_8& distance, uint_1* blk_r, uint_1* blk_g,
			 uint_1* blk_b, int_4 offset_w, int_4 offset_h,
			 int_4 width, int_4 height);
  logical_1 hist_train_cc(char_1* image_fname);
  logical_1 hist_train_cc(char_1* image_fname, char_1* seg_fname);
  logical_1 hist_train_cc(uint_1* blk_r, uint_1* blk_g, uint_1* blk_b,
			  int_4 offset_w, int_4 offset_h, int_4 width,
			  int_4 height);
  logical_1 hist_compute_cc(char_1* image_fname);
  logical_1 hist_compute_cc(char_1* image_fname, char_1* seg_fname);
  logical_1 hist_compute_cc(uint_1* blk_r, uint_1* blk_g, uint_1* blk_b,
			    int_4 offset_w, int_4 offset_h, int_4 width,
			    int_4 height);
  logical_1 hist_compare_cc(float_8& sbe_value);

  // lower-level methods
  //
  logical_1 hist_assign_cc(uint_1* b_red, uint_1* b_green, uint_1* b_blue,
			   int_4 width, int_4 height);
  logical_1 hist_assign_cc(uint_1* b_red, uint_1* b_green, uint_1* b_blue,
			   int_4 offset_width, int_4 offset_height,
			   int_4 width, int_4 height);
  int_4 hist_compute_index_cc(float_8 value, float_8 min,
			      float_8 max, float_8 scale);
  logical_1 hist_display_cc(FILE* fp);
  logical_1 hist_init_cc();
  logical_1 hist_normalize_cc();
  
  //---------------------------------------------------------------------------
  //
  // edge detection related methods
  //
  //---------------------------------------------------------------------------
  
  // load methods
  //
  logical_1 edge_load_cc();
  
  // computation methods
  //
  logical_1 edge_test_cc(float_8& sbe_value, char_1* image_fname);
  logical_1 edge_test_cc(float_8& sbe_value, char_1* image_fname,
			 char_1* seg_fname);
  logical_1 edge_test_cc(float_8& distance, uint_1* blk_r, uint_1* blk_g,
			 uint_1* blk_b, int_4 offset_w, int_4 offset_h,
			 int_4 width, int_4 height);
  logical_1 edge_train_cc(char_1* image_fname);
  logical_1 edge_train_cc(char_1* image_fname, char_1* seg_fname);
  logical_1 edge_train_cc(uint_1* blk_r, uint_1* blk_g, uint_1* blk_b,
			  int_4 offset_w, int_4 offset_h, int_4 width,
			  int_4 height);
  logical_1 edge_compute_cc(char_1* image_fname);
  logical_1 edge_compute_cc(char_1* image_fname, char_1* seg_fname);
  logical_1 edge_compute_cc(uint_1* blk_r, uint_1* blk_g, uint_1* blk_b,
			    int_4 offset_w, int_4 offset_h, int_4 width,
			    int_4 height);
  logical_1 edge_compare_cc(float_8& sbe_value);

  // lower level methods
  //
  logical_1 edge_init_cc();
  logical_1 edge_gauss_cc(float_4* edge_gauss);
  logical_1 edge_derivatives_cc(float_4* edge_xderiv, float_4* edge_yderiv);
  logical_1 edge_gradient_cc(float_4* grad_output, int_4 width, int_4 height,
			     float_4* xderiv_image, float_4* yderiv_image);
  logical_1 edge_convolve_cc(float_4* convol_output, float_4* convol_buf1,
			     float_4* convol_buf2, int_4 width, int_4 height);
  logical_1 edge_maxsup_cc(float_4* out_image, float_4* grad_output,
			   int_4 width, int_4 height);
  logical_1 edge_lines_cc(int_4* num_lines, float_4* edgedet_data,
	 		  int_4 width, int_4 height);
  logical_1 edge_lines_cc(float_4*& edge_data, int_4 width, int_4 height,
			  FILE* fp_out);
  logical_1 edge_gray_cc(float_4* gray_output, int_4 width, int_4 height,
			 uint_1* b_red, uint_1* b_green, uint_1* b_blue);
  logical_1 edge_assign_cc(int_4 num_lines);
  logical_1 edge_normalize_cc();

  //---------------------------------------------------------------------------
  //
  // factor analysis related methods
  //
  //---------------------------------------------------------------------------
  
  // load methods
  //
  logical_1 pca_load_cc();       // loads the model file 
  
  // computational methods
  //
  logical_1 pca_test_cc(float_8& sbe_value, char_1* image_fname);
  logical_1 pca_test_cc(float_8& sbe_value, char_1* image_fname,
			   char_1* seg_fname);
  logical_1 pca_test_cc(float_8& distance, uint_1* blk_r, uint_1* blk_g,
		        uint_1* blk_b, int_4 offset_w, int_4 offset_h,
			int_4 width, int_4 height);
  logical_1 pca_train_cc(char_1* image_fname);  
  logical_1 pca_train_cc(char_1* image_fname, char_1* seg_fname);
  logical_1 pca_train_cc(uint_1* blk_r, uint_1* blk_g, uint_1* blk_b,
			 int_4 offset_w, int_4 offset_h, int_4 width,
			 int_4 height);
  
  logical_1 pca_compare_cc(float_8& sbe_value);
  
  // lower level method
  //
  logical_1 pca_init_cc();       // initialize the data         
  logical_1 pca_covar_cc();      // compute the covariance matrix
  logical_1 pca_inverse_cc(float_8** inv_data);    // computes the inverse
                                                   // of the matrix


  //---------------------------------------------------------------------------
  //
  // differential entropy related methods
  //
  //---------------------------------------------------------------------------
  
  // load methods
  //
  logical_1 dent_load_cc();       // loads the model file 
  
  // computational methods
  //
  logical_1 dent_test_cc(float_8& sbe_value, char_1* image_fname);
  logical_1 dent_test_cc(float_8& sbe_value, char_1* image_fname,
			 char_1* seg_fanme);
  logical_1 dent_test_cc(float_8& distance, uint_1* blk_r, uint_1* blk_g,
			 uint_1* blk_b, int_4 offset_w, int_4 offset_h,
			 int_4 width, int_4 height);
  logical_1 dent_train_cc(char_1* image_fname);  
  logical_1 dent_train_cc(char_1* image_fname, char_1* seg_fname);   
  logical_1 dent_train_cc(uint_1* blk_r, uint_1* blk_g, uint_1* blk_b,
			  int_4 offset_w, int_4 offset_h, int_4 width,
			  int_4 height);
  logical_1 dent_compute_cc(char_1* image_fname);
  logical_1 dent_compute_cc(char_1* image_fname, char_1* seg_fname);
  logical_1 dent_compute_cc(uint_1* blk_r, uint_1* blk_g, uint_1* blk_b,
			    int_4 offset_w, int_4 offset_h, int_4 width,
			    int_4 height);  
  logical_1 dent_compare_cc(float_8& sbe_value);
  
  // lower level method
  //
  logical_1 dent_init_cc();       // initialize the data         
  logical_1 dent_red_assign_cc(uint_1* b_red, int_4 width, int_4 height);
  logical_1 dent_grn_assign_cc(uint_1* b_grn, int_4 width, int_4 height);
  logical_1 dent_blu_assign_cc(uint_1* b_blu, int_4 width, int_4 height);
  logical_1 dent_normalize_cc();
  logical_1 dent_sum_cc();

  //---------------------------------------------------------------------------
  //
  // standard deviation related methods
  //
  //---------------------------------------------------------------------------
  
  // load methods
  //
  logical_1 sd_load_cc();       // loads the model file 
  
  // computational methods
  //
  logical_1 sd_test_cc(float_8& sbe_value, char_1* image_fname);
  logical_1 sd_test_cc(float_8& sbe_value, char_1* image_fname,
		       char_1* seg_fname);
  logical_1 sd_test_cc(float_8& distance, uint_1* blk_r, uint_1* blk_g,
		       uint_1* blk_b, int_4 offset_w, int_4 offset_h,
		       int_4 width, int_4 height);
  logical_1 sd_train_cc(char_1* image_fname);
  logical_1 sd_train_cc(char_1* image_fname, char_1* seg_fname);
  logical_1 sd_train_cc(uint_1* blk_r, uint_1* blk_g, uint_1* blk_b,
			int_4 offset_w, int_4 offset_h, int_4 width,
			int_4 height);
  logical_1 sd_compute_cc(char_1* image_fname);
  logical_1 sd_compute_cc(char_1* image_fname, char_1* seg_fname);
  logical_1 sd_compute_cc(uint_1* blk_r, uint_1* blk_g, uint_1* blk_b,
			  int_4 offset_w, int_4 offset_h, int_4 width,
			  int_4 height);
  logical_1 sd_compare_cc(float_8& sbe_value);
  
  // lower level method
  //
  logical_1 sd_init_cc();       // initialize the data
  logical_1 sd_mean_cc(uint_1* b_red, uint_1* b_green, uint_1* b_blue,
		       int_4 width, int_4 height);
  logical_1 sd_assign_cc(uint_1* b_red, uint_1* b_green, uint_1* b_blue,
			 int_4 width, int_4 height);
  logical_1 sd_normalize_cc();

  //---------------------------------------------------------------------------
  //
  // entropy related methods
  //
  //---------------------------------------------------------------------------
    
  // load methods
  //
  logical_1 ent_load_cc();       // loads the model file 
  
  // computational methods
  //
  logical_1 ent_test_cc(float_8& sbe_value, char_1* image_fname);
  logical_1 ent_test_cc(float_8& sbe_value, char_1* image_fname,
			   char_1* seg_fname);
  logical_1 ent_test_cc(float_8& distance, uint_1* blk_r, uint_1* blk_g,
			uint_1* blk_b, int_4 offset_w, int_4 offset_h,
			int_4 width, int_4 height);
  logical_1 ent_train_cc(char_1* image_fname);  
  logical_1 ent_train_cc(char_1* image_fname, char_1* seg_fname);   
  logical_1 ent_train_cc(uint_1* blk_r, uint_1* blk_g, uint_1* blk_b,
			 int_4 offset_w, int_4 offset_h, int_4 width,
			 int_4 height);
  logical_1 ent_compute_cc(char_1* image_fname);
  logical_1 ent_compute_cc(char_1* image_fname, char_1* seg_fname);
  logical_1 ent_compute_cc(uint_1* blk_r, uint_1* blk_g, uint_1* blk_b,
			   int_4 offset_w, int_4 offset_h, int_4 width,
			   int_4 height);
  logical_1 ent_compare_cc(float_8& sbe_value);
  
  // lower level method
  //
  logical_1 ent_init_cc();       // initialize the data
  logical_1 ent_assign_cc(uint_1* b_red, uint_1* b_green,
			  uint_1* b_blue, int_4 width, int_4 height);
  logical_1 ent_normalize_cc();
  logical_1 ent_value_cc();

  //---------------------------------------------------------------------------
  //
  // jpeg dct coding related methods (8 x 8 dct transformation and run
  // length coding)
  //
  //---------------------------------------------------------------------------
    
  // load methods
  //
  logical_1 rle_load_cc();       // loads the model file 
  
  // computational methods
  //
  logical_1 rle_test_cc(float_8& sbe_value, char_1* image_fname);
  logical_1 rle_test_cc(float_8& sbe_value, char_1* image_fname,
			   char_1* seg_fname);
  logical_1 rle_test_cc(float_8& distance, uint_1* blk_r, uint_1* blk_g,
			uint_1* blk_b, int_4 offset_w, int_4 offset_h,
		        int_4 width, int_4 height);
  logical_1 rle_train_cc(char_1* image_fname);
  logical_1 rle_train_cc(char_1* image_fname, char_1* seg_fname);
  logical_1 rle_train_cc(uint_1* blk_r, uint_1* blk_g, uint_1* blk_b,
			 int_4 offset_w, int_4 offset_h, int_4 width,
			 int_4 height);
  logical_1 rle_compute_cc(char_1* image_fname);
  logical_1 rle_compute_cc(char_1* image_fname, char_1* seg_fname);
  logical_1 rle_compute_cc(uint_1* blk_r, uint_1* blk_g, uint_1* blk_b,
			   int_4 offset_w, int_4 offset_h, int_4 width,
			   int_4 height);
  logical_1 rle_compare_cc(float_8& sbe_value);
    
  // lower level methods
  //
  logical_1 rle_init_cc();       // initialize the data
  logical_1 rle_normalize_cc();
  logical_1 rle_debias_cc(uint_1* b_red, uint_1* b_grn, uint_1* b_blu,
			  int_4 width, int_4 height);
  logical_1 rle_cos_cc();
  logical_1 rle_dct_cc();
  logical_1 rle_zigzag_cc();
  logical_1 rle_bitred_cc();
  logical_1 rle_bitgrn_cc();
  logical_1 rle_bitblu_cc();
  logical_1 rle_bits_cc();
  logical_1 rle_category_cc(float_4 value_a, int_4& cat_a,
			    int_4& offset_a);

  //---------------------------------------------------------------------------
  //
  // dct transformation related methods
  //
  //---------------------------------------------------------------------------

  // computational methods
  //
  logical_1 dct_compute_cc(uint_1* blk_r, uint_1* blk_g, uint_1* blk_b,
			   int_4 offset_w, int_4 offset_h, int_4 width,
			   int_4 height);

  // lower level methods
  //
  logical_1 dct_init_cc();         // initialize the data
  logical_1 dct_debias_cc(uint_1* b_red, uint_1* b_grn, uint_1* b_blu,
			  int_4 width, int_4 height);
  logical_1 dct_cos_cc();          // compute the cosine template
  logical_1 dct_set_norm_cc();     // compute the normalization matrix
  logical_1 dct_trans_cc();        // compute forward transformation
  logical_1 dct_normalize_cc();    // normalize the coefficients
  logical_1 dct_zigzag_cc();       // zigzag scan
  logical_1 dct_filter_cc();       // frequency domain filtering
  
  //---------------------------------------------------------------------------
  //
  // fractal dimension related methods
  //
  //---------------------------------------------------------------------------
    
  // load methods
  //
  logical_1 fract_load_cc();       // loads the model file 
  
  // computational methods
  //
  logical_1 fract_test_cc(float_8& sbe_value, char_1* image_fname);
  logical_1 fract_test_cc(float_8& sbe_value, char_1* image_fname,
			     char_1* seg_fname);
  logical_1 fract_test_cc(float_8& distance, uint_1* blk_r, uint_1* blk_g,
			  uint_1* blk_b, int_4 offset_w, int_4 offset_h,
			  int_4 width, int_4 height);
  logical_1 fract_train_cc(char_1* image_fname);
  logical_1 fract_train_cc(char_1* image_fname, char_1* seg_fname);
  logical_1 fract_train_cc(uint_1* blk_r, uint_1* blk_g, uint_1* blk_b,
			   int_4 offset_w, int_4 offset_h, int_4 width,
			   int_4 height);
  logical_1 fract_compute_cc(char_1* image_fname);
  logical_1 fract_compute_cc(char_1* image_fname, char_1* seg_fname);
  logical_1 fract_compute_cc(uint_1* blk_r, uint_1* blk_g, uint_1* blk_b,
			     int_4 offset_w, int_4 offset_h, int_4 width,
			     int_4 height);
  logical_1 fract_compare_cc(float_8& sbe_value);

  // lower level methods
  //
  logical_1 fract_init_cc();       // initialize the data
  logical_1 fract_normalize_cc();
  logical_1 fract_tri_cc(int_4 x_dim, int_4 y_dim, int_4 width_a,
			 int_4 height_a, float_4* b_red_a, float_4* b_grn_a,
			 float_4* b_blu_a, int_4 n);
  logical_1 fract_tri1_cc(int_4 x_dim, int_4 y_dim, int_4 width_a,
			  int_4 height_a, float_4* b_red_a, 
			  float_4* b_grn_a, float_4* b_blu_a, int_4 n);
  logical_1 fract_tri2_cc(int_4 x_dim, int_4 y_dim, int_4 width_a,
			  int_4 height_a, float_4* b_red_a,
			  float_4* b_grn_a, float_4* b_blu_a, int_4 n);
  logical_1 fract_tri3_cc(int_4 x_dim, int_4 y_dim, int_4 width_a,
			  int_4 height_a, float_4* b_red_a,
			  float_4* b_grn_a, float_4* b_blu_a, int_4 n);
  logical_1 fract_tri4_cc(int_4 x_dim, int_4 y_dim, int_4 width_a,
			  int_4 height_a, float_4* b_red_a,
			  float_4* b_grn_a, float_4* b_blu_a, int_4 n);
  logical_1 fract_area_cc(float_4 side_red_a, float_4 side_red_b,
			  float_4 side_red_c, float_4 side_grn_a,
			  float_4 side_grn_b, float_4 side_grn_c,
			  float_4 side_blu_a, float_4 side_blu_b,
			  float_4 side_blu_c, int_4 n);
  logical_1 fract_dim_cc();
  
  //---------------------------------------------------------------------------
  //
  // gabor filters related methods
  //
  //---------------------------------------------------------------------------
    
  // computational methods
  //
  logical_1 gabor_compute_cc(uint_1* blk_r, uint_1* blk_g, uint_1* blk_b,
			     int offset_w, int offset_h,
			     int width, int height);

  // lower level methods
  //
  logical_1 gabor_init_cc(int_4 width, int_4 height);
  logical_1 gabor_gen_cc(float_8* gabor_filter, float_8 rad_frq,
			 float_8 orient);    
  logical_1 gabor_convolve_cc(float_8* result_buf, float_8* image_buf,
			      float_8* filter_buf, int_4 width, int_4 height);
  logical_1 gabor_compu_features_cc(float_8** blk_fltr, int_4 width,
				    int_4 height);
  logical_1 gabor_gray_cc(float_8* gabor_gray, int_4 width, int_4 height,
			  uint_1* b_red, uint_1* b_green, uint_1* b_blue);
};

// end of file
//
#endif

