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

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

// method: hist_train_cc
//
// arguments:
//  char_1* image_fname: (input) the image filename
//
// return: a logical_1 value indicating status
//
// this method computes the histogram in the training mode
//
logical_1 Image_analysis::hist_train_cc(char_1* image_fname_a) {
  
  // compute a histogram
  //
  if (hist_compute_cc(image_fname_a) == ISIP_FALSE) {
    error_handler_cc((char_1*)"hist_train_cc",
		     (char_1*)"error while computing the histogram");
    return ISIP_FALSE;
  }

  // provide some debugging information
  //
  if (debug_level_d > ISIP_DEBUG_BRIEF) {
    fprintf(stdout, "<%s> %s = %ld\n", "Image_analysis::hist_compute_cc",
	    "hist_t_npxls", hist_t_npxls_d);
    fprintf(stdout, "<%s> %s = %ld\n", "Image_analysis::hist_compute_cc",
	    "hist_t_nimages_d", hist_t_nimages_d);
    
    // display the histogram
    //
    fprintf(stdout, "red pdf:\n");
    for (int_4 i=0; i<hist_r_nbins_d; i++) {
      fprintf(stdout, "%ld %ld: %f\n", hist_r_redp_d, i, hist_t_rpdf_d[i]);
    }
    
    fprintf(stdout, "green pdf:\n");
    for (int_4 i=0; i<hist_r_nbins_d; i++) {
      fprintf(stdout, "%ld %ld: %f\n", hist_r_grnp_d, i, hist_t_gpdf_d[i]);
    }
    
    fprintf(stdout, "blue pdf:\n");
    for (int_4 i=0; i<hist_r_nbins_d; i++) {
      fprintf(stdout, "%ld %ld: %f\n", hist_r_blup_d, i, hist_t_bpdf_d[i]);
    }
  }
  
  // exit gracefully
  //
  return ISIP_TRUE;
}
