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

// isip include files
//
#include "image_analysis.h"
#include <integral_constants.h>

// method: ent_normalize_cc
//
// arguments: none
//
// return: a logical_1 value indicating status
//
// this method normalizes a histogram
//
logical_1 Image_analysis::ent_normalize_cc() {
  
  if (huf_r_npxls_d != (int_4)0) {

    // compute the scaling factor
    //
    float_8 scale = 1.0 / (float_8)huf_r_npxls_d;
  
    // normalize
    //
    for (int_4 i=0; i<huf_r_nbins_d; i++) {
    
      // compute the differences
      //
      huf_r_rpdf_d[i] *= scale;
      huf_r_gpdf_d[i] *= scale;
      huf_r_bpdf_d[i] *= scale;
    }
  }
  
  // provide some debugging information
  //
  if (debug_level_d > ISIP_DEBUG_BRIEF) {
    fprintf(stdout, "<%s> %s = %ld\n", "Image_analysis::ent_normalize_cc",
	    "huf_r_npxls_d", huf_r_npxls_d);
    fprintf(stdout, "<%s> %s = %ld\n", "Image_analysis::ent_normalize_cc",
	    "huf_r_nimages_d", huf_r_nimages_d);
  
    // display the distribution
    //
    fprintf(stdout, "red pdf:\n");
    for (int_4 i=0; i<huf_r_nbins_d; i++) {
      fprintf(stdout, "%ld : %f\n", i, huf_r_rpdf_d[i]);
    }
    
    fprintf(stdout, "green pdf:\n");
    for (int_4 i=0; i<huf_r_nbins_d; i++) {
      fprintf(stdout, "%ld: %f\n", i, huf_r_gpdf_d[i]);
    }
    
    fprintf(stdout, "blue pdf:\n");
    for (int_4 i=0; i<huf_r_nbins_d; i++) {
      fprintf(stdout, "%ld: %f\n", i, huf_r_bpdf_d[i]);
    }
  }
  
  // exit gracefully
  //
  return ISIP_TRUE;
}



