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

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

#include <integral_constants.h>

// method: edge_train_cc
//
// arguments:
//  char_1* image_fname_a: (input) the image filename
//
// return: a logical_1 value indicating status
//
// this method computes the edge detection in the training mode
//
logical_1 Image_analysis::edge_train_cc(char_1* image_fname_a) {
  
  // compute the edge detection
  //
  if (edge_compute_cc(image_fname_a) == ISIP_FALSE) {
    error_handler_cc((char_1*)"edge_train_cc",
		     (char_1*)"error while computing the edge detection");
    return ISIP_FALSE;
  }

  // normalize the edge detected data
  //
  if (edge_normalize_cc() == ISIP_FALSE) {
    error_handler_cc((char_1*)"edge_train_cc",
		     (char_1*)"error normalizing the data");
    return ISIP_FALSE;
  }

  for (int_4 i=0; i < edge_r_nbins_d; i++) {
    fprintf(stdout, " %f\t", edge_t_lpdf_d[i]);
  }

  // provide some debugging information
  //
  if (debug_level_d > ISIP_DEBUG_BRIEF) {
    fprintf(stdout, "<%s> %s = %ld\n", "Image_analysis::edge_train_cc",
	    "edge_t_nlines", edge_t_tlines_d);
    fprintf(stdout, "<%s> %s = %ld\n", "Image_analysis::edge_train_cc",
	    "edge_t_nimages_d", edge_t_nimages_d);

    // display the distribution of lines
    //
    fprintf(stdout, "lines pdf:\n");
    for (int_4 i=0; i<edge_r_nbins_d; i++) {
      fprintf(stdout, "%ld: %f\n", i, edge_t_lpdf_d[i]);
    }
  }
  
  // exit gracefully
  //
  return ISIP_TRUE;
}
