// file: $USFS/class/image_analysis/v6.0/imaga_ent_04.cc
//

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

// method: ent_assign_cc
//
// arguments:
//  uint_1* b_red: (input) red buffer
//  uint_1* b_green: (input) green buffer
//  uint_1* b_blue: (input) blue buffer
//  int_4 width: (input) width of the image
//  int_4 height: (input) height of the image
//
// return: a logical_1 value indicating the status
//
// this method computes histogram for the three primary colors
//
logical_1 Image_analysis::ent_assign_cc(uint_1* b_red_a, uint_1* b_green_a,
				        uint_1* b_blue_a, int_4 width_a,
				        int_4 height_a) {

  // declare local variables
  //
  int_4 index_r;
  int_4 index_g;
  int_4 index_b;
  int_4 npixels = width_a * height_a;
  
  // loop over all the data to compute histograms
  // 
  for (int_4 i=0; i<npixels; i++) {

    // assign the pixels to the bins equal to the value of the color
    //
    index_r = b_red_a[i];
    huf_r_rpdf_d[index_r]++;
    index_g = b_green_a[i];
    huf_r_gpdf_d[index_g]++;
    index_b = b_blue_a[i];
    huf_r_bpdf_d[index_b]++;
    
    // increment the pixels
    //
    huf_r_npxls_d++;
  }
  
  // exit gracefully
  //
  return ISIP_TRUE;
}
 
