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

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

// method: hist_compare_cc
//
// arguments:
//  float_8& sbe_a: (output) sbe value
//
// return: a logical_1 value indicating status
//
// this method computes an sbe from two histograms.
//
 logical_1 Image_analysis::dent_compare_cc(float_8& sbe_a) {
  
  // declare local variables
  //
  float_8 sum_r = (float_4)0.0;
  float_8 sum_g = (float_4)0.0;
  float_8 sum_b = (float_4)0.0;
  float_8 rms_scaled;
  
  // compare the data from the model file with the computed data
  //
  float_8 diff_r = dent_r_sumred_d - dent_t_sumred_d;
  float_8 diff_g = dent_r_sumgrn_d - dent_t_sumgrn_d;
  float_8 diff_b = dent_r_sumblu_d - dent_t_sumblu_d;
  
  // weight the contributions from each color
  //
  rms_scaled = hist_rwgt_d * diff_r + hist_gwgt_d * diff_g +
    hist_bwgt_d * diff_b;
  
  // compute the scaled sbe
  //
  sbe_a = dent_ascale_d * rms_scaled + dent_bscale_d;
  
  if (debug_level_d > ISIP_DEBUG_DETAILED) {
    fprintf(stdout,"<%s> rms error = %f: (r) %f (g) %f (b) %f\n",
	    "Image_analysis::dent_compare_cc",
	    rms_scaled, sum_r, sum_g, sum_b);
  }
  
  if (debug_level_d > ISIP_DEBUG_BRIEF) {
    fprintf(stdout,"<%s> sbe = %f\n",
	    "Image_analysis::hist_compare_cc", sbe_a);
  }
  
  // exit gracefully
  //
  return ISIP_TRUE;
}
