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

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

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

// method: test_cc
//
// arguments:
//  float_8& sbe_a: (output) the image's sbe value
//  char_1* image_fname_a: (input) the image's filename
//
// return: a logical_1 value indicating the status
//
// this method tests the algorithm to be implemented and calls the
// corresponding method
//
logical_1 Image_analysis::test_cc(float_8& sbe_a,
				  char_1* image_fname_a) {

  // provide some debugging information
  //
  if (debug_level_d > ISIP_DEBUG_DETAILED) {
    fprintf(stdout, "<%s> algorithm: %ld image_filename: %s\n",
	    "Image_analysis::test_cc", algorithm_d, image_fname_a);
  }
  
  // compute a histogram
  //
  if (algorithm_d == IMAGA_ALG_HISTOGRAM) {
    if (hist_test_cc(sbe_a, image_fname_a) == ISIP_FALSE) {
      error_handler_cc((char_1*)"test_cc",
		       (char_1*)"error while computing the histogram");
      return ISIP_FALSE;
    }
  }

  // compute edge detection
  //
  else if (algorithm_d == IMAGA_ALG_EDGEDET) {
    if (edge_test_cc(sbe_a, image_fname_a) == ISIP_FALSE) {
      error_handler_cc((char_1*)"test_cc",
		       (char_1*)"error while computing the edge detection");
      return ISIP_FALSE;
    }
  }

  // compute histogram and edge detection
  //
  else if (algorithm_d == IMAGA_ALG_FACTOR) {
    if (pca_test_cc(sbe_a, image_fname_a) == ISIP_FALSE) {
      error_handler_cc((char_1*)"test_cc",
		       (char_1*)"error while computing the algorithms");
      return ISIP_FALSE;
    }
  }

  else if (algorithm_d == IMAGA_ALG_DIFF) {
    if (dent_test_cc(sbe_a, image_fname_a) == ISIP_FALSE) {
      error_handler_cc((char_1*)"test_cc",
		       (char_1*)"error while computing the diff in magnitude");
      return ISIP_FALSE;
    }
  }

  else if (algorithm_d == IMAGA_ALG_SD) {
    if (sd_test_cc(sbe_a, image_fname_a) == ISIP_FALSE) {
      error_handler_cc((char_1*)"test_cc",
		       (char_1*)"error while computing the deviation");
      return ISIP_FALSE;
    }
  }

  else if (algorithm_d == IMAGA_ALG_ENT) {
    if (ent_test_cc(sbe_a, image_fname_a) == ISIP_FALSE) {
      error_handler_cc((char_1*)"test_cc",
		       (char_1*)"error while computing the entropy");
      return ISIP_FALSE;
    }
  }

  else if (algorithm_d == IMAGA_ALG_RLE) {
    if (rle_test_cc(sbe_a, image_fname_a) == ISIP_FALSE) {
      error_handler_cc((char_1*)"test_cc",
		       (char_1*)"error while computing the run length coding");
      return ISIP_FALSE;
    }
  }

  else if (algorithm_d == IMAGA_ALG_FRACT) {
    if (fract_test_cc(sbe_a, image_fname_a) == ISIP_FALSE) {
      error_handler_cc((char_1*)"test_cc",
		       (char_1*)"eror computing the fractal dimension");
      return ISIP_FALSE;
    }
  }
  
  // else: unknown algorithm
  //
  else {
    error_handler_cc((char_1*)"test_cc",
		     (char_1*)"unknown algorithm");
    return ISIP_FALSE;
  }
  
  // exit gracefully
  //
  return ISIP_TRUE;
}
