// file: $USFS/class/image_analysis/v3.1/imaga_hist_08.cc
//

// system include files
//
#include <memory.h>

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

// method: hist_init_cc
//
// arguments: none
//
// return: a logical_1 value indicating status
//
// this method initializes the histogram computation.
//
logical_1 Image_analysis::hist_init_cc() {
  
  // deallocate memory if necessary
  //
  if (hist_t_rpdf_d != (float_8*)NULL) {
    delete [] hist_t_rpdf_d;
    hist_t_rpdf_d = (float_8*)NULL;
  }
  if (hist_t_gpdf_d != (float_8*)NULL) {
    delete [] hist_t_gpdf_d;
    hist_t_gpdf_d = (float_8*)NULL;
  }
  if (hist_t_bpdf_d != (float_8*)NULL) {
    delete [] hist_t_bpdf_d;
    hist_t_bpdf_d = (float_8*)NULL;
  }
  if (hist_t_ylwpdf_d != (float_8*)NULL) {
    delete [] hist_t_ylwpdf_d;
    hist_t_ylwpdf_d = (float_8*)NULL;
  }
  if (hist_t_brnpdf_d != (float_8*)NULL) {
    delete [] hist_t_brnpdf_d;
    hist_t_brnpdf_d = (float_8*)NULL;
  }
 
  // allocate memory and clear
  //
  hist_t_rpdf_d = new float_8[hist_r_nbins_d];
  hist_t_gpdf_d = new float_8[hist_r_nbins_d];
  hist_t_bpdf_d = new float_8[hist_r_nbins_d];
  hist_t_ylwpdf_d = new float_8[hist_r_nbins_d];
  hist_t_brnpdf_d = new float_8[hist_r_nbins_d];
  
  memset((void*)hist_t_rpdf_d, (int)0, (size_t)(hist_r_nbins_d*sizeof(float_8)));
  memset((void*)hist_t_gpdf_d, (int)0, (size_t)(hist_r_nbins_d*sizeof(float_8)));
  memset((void*)hist_t_bpdf_d, (int)0, (size_t)(hist_r_nbins_d*sizeof(float_8)));
  memset((void*)hist_t_ylwpdf_d, (int)0, (size_t)(hist_r_nbins_d*sizeof(float_8)));
  memset((void*)hist_t_brnpdf_d, (int)0, (size_t)(hist_r_nbins_d*sizeof(float_8)));

  // allocate memory and clear
  //
  if (hist_t_rcval_d != (float_8*)NULL) {
    delete [] hist_t_rcval_d;
    hist_t_rcval_d = (float_8*)NULL;
  }

  if (hist_t_gcval_d != (float_8*)NULL) {
    delete [] hist_t_gcval_d;
    hist_t_gcval_d = (float_8*)NULL;
  }

  if (hist_t_bcval_d != (float_8*)NULL) {
    delete [] hist_t_bcval_d;
    hist_t_bcval_d = (float_8*)NULL;
  }

  if (hist_t_ylwcval_d != (float_8*)NULL) {
    delete [] hist_t_ylwcval_d;
    hist_t_ylwcval_d = (float_8*)NULL;
  }

  if (hist_t_brncval_d != (float_8*)NULL) {
    delete [] hist_t_brncval_d;
    hist_t_brncval_d = (float_8*)NULL;
  }

  hist_t_rcval_d = new float_8[hist_r_nbins_d];
  hist_t_gcval_d = new float_8[hist_r_nbins_d];
  hist_t_bcval_d = new float_8[hist_r_nbins_d];
  hist_t_ylwcval_d = new float_8[hist_r_nbins_d];
  hist_t_brncval_d = new float_8[hist_r_nbins_d];
  
  memset((void*)hist_t_rcval_d, (int)0, (size_t)(hist_r_nbins_d*sizeof(float_8)));
  memset((void*)hist_t_gcval_d, (int)0, (size_t)(hist_r_nbins_d*sizeof(float_8)));
  memset((void*)hist_t_bcval_d, (int)0, (size_t)(hist_r_nbins_d*sizeof(float_8)));
  memset((void*)hist_t_ylwcval_d, (int)0, (size_t)(hist_r_nbins_d*sizeof(float_8)));
  memset((void*)hist_t_brncval_d, (int)0, (size_t)(hist_r_nbins_d*sizeof(float_8)));

  // clear counters
  //
  hist_t_npxls_d = (int_4)0;
  hist_t_nimages_d = (int_4)0;
  hist_t_nblks_d = (int_4)0;
  
  // exit gracefully
  //
  return ISIP_TRUE;
}



