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

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

// method: rle_test_cc
//
// arguments:
//  float_8& sbe: (output) the image's sbe value
//  char_1* image_fname: (input) the image file name
//  char_1* seg_fname: (input) the segmentation file name
//
// return:
//  a logical_1 value indicating the status
//
// this method computes a histogram on a prescribed region and compares it
// with the reference model.
//
logical_1 Image_analysis::rle_test_cc(float_8& sbe_a, char_1* image_fname_a,
				      char_1* seg_fname_a) {
  
  // initialize
  //
  if (rle_init_cc() == ISIP_FALSE) {
    error_handler_cc((char_1*)"rle_test_cc",
		     (char_1*)"error while initializing for the compression");
    return ISIP_FALSE;
  }
  
  // compute the compression ratio
  //
  if (rle_compute_cc(image_fname_a, seg_fname_a) == ISIP_FALSE) {
    error_handler_cc((char_1*)"rle_test_cc",
		     (char_1*)"error while computing the compression");
    return ISIP_FALSE;
  }
  
  // provide some debugging information
  //
  if (debug_level_d > ISIP_DEBUG_BRIEF) {
    fprintf(stdout, "<%s> %s = %ld\n", "Image_analysis::rle_compute_cc",
	    "ent_npxls", huf_r_npxls_d);
    fprintf(stdout, "<%s> %s = %ld\n", "Image_analysis::rle_compute_cc",
	    "rle_r_nimages_d", rle_r_nimages_d);
  }
  
  // compute the sbe
  //
  if (rle_compare_cc(sbe_a) == ISIP_FALSE) {
    error_handler_cc((char_1*)"ent_test_cc",
  	     (char_1*)"error while computing the sbe");
    return ISIP_FALSE;
  }
  
  // exit gracefully
  //
  return ISIP_TRUE;
}
