// file: $USFS/class/image_analysis/v6.1/imaga_ent_14.cc
//

// isip include files
//
#include "image_analysis.h"
#include "image_analysis_constants.h"

// method: ent_train_cc
//
// arguments:
//  uint_1* blk_r: (input) buffer for red color
//  uint_1* blk_g: (input) buffer for green color
//  uint_1* blk_b: (input) buffer for blue color
//  int_4 offset_w: (input) offset in width for the image block
//  int_4 offset_h: (input) offset in height for the image block
//  int_4 width: (input) width of the image block
//  int_4 height: (input) height of the image block
//
// return:
//  a logical_1 value indicating status
//
// this method computes the entropy on some prescribed region of the image
// in the training mode
//
logical_1 Image_analysis::ent_train_cc(uint_1* blk_r_a, uint_1* blk_g_a,
				       uint_1* blk_b_a, int_4 offset_w_a,
				       int_4 offset_h_a, int_4 width_a,
				       int_4 height_a) {
  
  // compute the entropy
  //
  if (ent_compute_cc(blk_r_a, blk_g_a, blk_b_a, offset_w_a, offset_h_a,
		     width_a, height_a) == ISIP_FALSE) {
    error_handler_cc((char_1*)"ent_train_cc",
		     (char_1*)"error while computing the entropy");
    return ISIP_FALSE;
  }

  // provide some debugging information
  //
  if (debug_level_d > ISIP_DEBUG_BRIEF) {
    fprintf(stdout, "<%s> %s = %ld\n", "Image_analysis::ent_train_cc",
	    "ent_npxls", huf_r_npxls_d);
    fprintf(stdout, "<%s> %s = %ld\n", "Image_analysis::ent_train_cc",
	    "huf_r_nimages_d", huf_r_nimages_d);
    
    fprintf(stdout, "%s\n", "the values of the entropy are");
    
    fprintf(stdout, "rent = %f\tgent = %f\tbent = %f\t\n", huf_t_red_d,
	    huf_t_grn_d, huf_t_blu_d);
  }
  
  // exit gracefully
  //
  return ISIP_TRUE;
}
