/* adapt threshold to image values values */
double SsocrImg::adapt_threshold(double thresh, int x, int y, int w, int h, SsocrThreshold thresh_flags) const
{
	switch (thresh_flags) {
		case ABSOLUTE_THRESHOLD:
			return thresh;
			break;
		case ADAPTIVE_THRESHOLD:
			return get_threshold(thresh/100.0, x, y, w, h);
			break;
		case ITERATIVE_THRESHOLD:
			return iterative_threshold(thresh, x, y, w, h);
			break;
		default:
			return thresh;
			break;
	}
}
Exemplo n.º 2
0
/* adapt threshold to image values values */
double adapt_threshold(Imlib_Image *image, double thresh, luminance_t lt, int x,
                       int y, int w, int h, int flags)
{
  double t = thresh;
  if(!(flags & ABSOLUTE_THRESHOLD)) {
    if(flags & DEBUG_OUTPUT)
      fprintf(stderr, "adjusting threshold to image: %f ->", t);
    t = get_threshold(image, thresh/100.0, lt, x, y, w, h);
    if(flags & DEBUG_OUTPUT)
      fprintf(stderr, " %f\n", t);
    if(flags & DO_ITERATIVE_THRESHOLD) {
      if(flags & DEBUG_OUTPUT)
        fprintf(stderr, "doing iterative_thresholding: %f ->", t);
      t = iterative_threshold(image, t, lt, x, y, w, h);
      if(flags & DEBUG_OUTPUT)
        fprintf(stderr, " %f\n", t);
    }
  }
  if((flags & VERBOSE) || (flags & DEBUG_OUTPUT)) {
    fprintf(stderr, "using threshold %.2f\n", t);
  }
  return t;
}