thresh_array.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include <stdio.h>
  2. #include "vizual.h"
  3. /*
  4. ** return an array of struct cmndln_info of resulting
  5. ** thresholds based on in_out flag
  6. */
  7. int build_thresh_arrays(D_spec, headp)
  8. struct dspec *D_spec;
  9. file_info *headp;
  10. {
  11. double min_thresh, max_thresh;
  12. int a, b, i;
  13. min_thresh = headp->linefax.tvalue[D_spec->low];
  14. max_thresh = headp->linefax.tvalue[D_spec->hi];
  15. /* initializations */
  16. D_spec->threshes[0].nthres = 0;
  17. D_spec->threshes[1].nthres = 0; /* for INSIDE CASE */
  18. if (D_spec->in_out == INSIDE) {
  19. b = 0;
  20. for (a = 0; a < headp->linefax.nthres; a++) {
  21. if (min_thresh <= headp->linefax.tvalue[a] &&
  22. max_thresh >= headp->linefax.tvalue[a]) {
  23. D_spec->threshes[0].tvalue[b++] = headp->linefax.tvalue[a];
  24. D_spec->threshes[0].nthres++;
  25. }
  26. }
  27. }
  28. else { /* OUTSIDE */
  29. for (i = 0; i < 2; i++) {
  30. b = 0;
  31. for (a = 0; a < headp->linefax.nthres; a++) {
  32. if (!i) {
  33. if (min_thresh >= headp->linefax.tvalue[a]) {
  34. D_spec->threshes[i].tvalue[b++] =
  35. headp->linefax.tvalue[a];
  36. D_spec->threshes[i].nthres++;
  37. }
  38. else if (max_thresh <= headp->linefax.tvalue[a]) {
  39. D_spec->threshes[i].tvalue[b++] =
  40. headp->linefax.tvalue[a];
  41. D_spec->threshes[i].nthres++;
  42. }
  43. } /* is this brace correct? MN 2001 */
  44. }
  45. }
  46. }
  47. }