// file: $USFS/class/image_analysis/v3.0/imaga_ent_06.cc
//

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

#include "image_analysis_constants.h"
#include <integral_constants.h>

// method: ent_value_cc
//
// arguments: none
//
// return: a logical_1 value indicating status
//
// this method computes the entropy of the three colors
//
logical_1 Image_analysis::ent_value_cc() {
  
  // delcare local variables
  //
  float_8 scale = 1 / log(2);
  
  for (int_4 i=0; i < huf_r_nbins_d; i++) {
    
    // taking care of zero probability of the colors
    //
    if (huf_r_rpdf_d[i] != (int)0) {
      huf_t_red_d += huf_r_rpdf_d[i] * log ( 1 / huf_r_rpdf_d[i]) * scale;
    }
    
    if (huf_r_gpdf_d[i] != (int)0) {
      huf_t_grn_d += huf_r_gpdf_d[i] * log ( 1 / huf_r_gpdf_d[i]) * scale;
    }

    if (huf_r_bpdf_d[i] != (int)0) {
      huf_t_blu_d += huf_r_bpdf_d[i] * log ( 1 / huf_r_bpdf_d[i]) * scale;
    }
  }
  
  // debug purposes
  //
  if (debug_level_d > ISIP_DEBUG_NONE) {
    
    fprintf(stdout, "<%s> ent_red = %f: ent_grn = %f: ent_blue = %f:\n",
	    "Image_analysis::ent_value_cc", huf_t_red_d, huf_t_grn_d,
	    huf_t_blu_d);
  }
  
  // exit gracefully
  //
  return ISIP_TRUE;
}
    
  
