// file: $USFS/class/image_analysis/v1.0/imaga_fract_11.cc
//

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

#include "image_analysis_constants.h"
#include <integral_constants.h>

// method: fract_dim_cc
//
// arguments: none
//
// return: a logical_1 value indicating status
//
// this method intializes the variables for the fractal dimension
//
logical_1 Image_analysis::fract_dim_cc() {
  
  // declare local variables
  //
  float_4 log_fred_a, log_sred_a, log_fgrn_a, log_sgrn_a;
  float_4 log_fblu_a, log_sblu_a, log_fir_dim, log_sec_dim;
    
  // compute the log of the area
  //
  log_fred_a = log(fract_t_fir_ared_d);
  log_sred_a = log(fract_t_sec_ared_d);

  log_fgrn_a = log(fract_t_fir_agrn_d);
  log_sgrn_a = log(fract_t_sec_agrn_d);
  
  log_fblu_a = log(fract_t_fir_ablu_d);
  log_sblu_a = log(fract_t_sec_ablu_d);

  // compute the log of the distance
  //
  log_fir_dim = log(IMAGA_FRACT_FDIST*2);
  log_sec_dim = log(IMAGA_FRACT_SDIST*2);
  
  // compute the scale
  //
  float_4 scale_n = 1 / (log_fir_dim - log_sec_dim);
  
  // compute the fractal dimension
  //
  float_4 scale_red = (log_fred_a - log_sred_a) * scale_n;
  float_4 scale_grn = (log_fgrn_a - log_sgrn_a) * scale_n;
  float_4 scale_blu = (log_fblu_a - log_sblu_a) * scale_n;
  
  fract_t_dimred_d = 2 - scale_red;
  fract_t_dimgrn_d = 2 - scale_grn;
  fract_t_dimblu_d = 2 - scale_blu;

  // exit gracefully
  //
  return ISIP_TRUE;
}

