// file: $USFS/class/image_segmentation/v1.0/image_segmentation.h
//

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

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

// other include files
//
#ifndef __ISIP_IMAGE_ANALYSIS
#include <image_analysis.h>
#endif

// Image_segmentation: a class that segments an image into different regions
// such as tree, foliage, grass, bush, sky and background sky
//
class Image_segmentation {

  //---------------------------------------------------------------------------
  //
  // protected data
  //
  //---------------------------------------------------------------------------
protected:

  // general information
  //
  int_4 num_models_d;
  char_1** param_files_d;
  int_4 mode_d;
  int_4 frm_size_d;
  int_4 win_size_d;
  int_4 dct_blk_size_d;
  Image_analysis* ia_d;
  
  // debugging parameters
  //
  int_4 debug_level_d;
  
  //---------------------------------------------------------------------------
  //
  // public methods
  //
  //---------------------------------------------------------------------------
public:

  // required methods
  //
  char_1* name_cc();
  volatile void error_handler_cc(char_1* method_name, char_1* message);
  logical_1 set_debug_cc(int_4 debug_level);
  
  // destructor/constructors
  //
  ~Image_segmentation();
  Image_segmentation();

  // initialize methods
  //
  logical_1 init_cc();
  
  // load/write methods
  //
  logical_1 get_nmods_cc(char_1* param_filelist);
  logical_1 load_models_cc();
  logical_1 write_models_cc();     // for training
   
  // processing methods
  //
  logical_1 process_cc(char_1* image_file, char_1* seg_file,
		       char_1* output_imagefile, char_1* output_datafile);
  logical_1 train_cc(char_1* image_file, char_1* seg_file);
  logical_1 test_cc(char_1* image_file, char_1* output_imagefile,
		    char_1* output_datafile);
  
  //---------------------------------------------------------------------------
  //
  // private methods
  //
  //---------------------------------------------------------------------------
private:

  // methods relating to windowing a frame of image data
  //
  logical_1 pad_zero_cc(uint_1*& buf_red, uint_1*& buf_green,
			uint_1*& buf_blue, int_4 offset_w, int_4 offset_h,
			int_4 width, int_4 height, int_4 actual_off_w,
			int_4 actual_off_h, int_4 actual_w, int_4 actual_h);
  logical_1 update_buf_cc(int_4 result, uint_1*& buf_red, uint_1*& buf_green,
			  uint_1*& buf_blue, int_4 width, int_4 height);
};

// end of file
//
#endif
