Commit 11ff9d7e8502c67b100c9104f815b1bfe7399c8d

Authored by David Mayerich
1 parent d661ab7d

improved user output, removed the max() warning from stim::image

Showing 3 changed files with 25 additions and 11 deletions   Show diff stats
stim/envi/bsq.h
... ... @@ -650,13 +650,24 @@ public:
650 650  
651 651 //to make sure the left and the right bound are in the bandwidth
652 652 if (lb < w[0] || rb < w[0] || lb > w[n-1] || rb >w[n-1]){
653   - std::cout<<"ERROR: left bound or right bound out of bandwidth"<<std::endl;
654   - exit(1);
  653 + if (lb < w[0]) {
  654 + std::cout << "bsq::area ERROR - left bound " << lb << " is below the minimum available wavelength " << w[0] << std::endl;
  655 + }
  656 + if (rb < w[0]) {
  657 + std::cout << "bsq::area ERROR - right bound " << rb << " is below the minimum available wavelength " << w[0] << std::endl;
  658 + }
  659 + if (lb > w[n - 1]) {
  660 + std::cout << "bsq::area ERROR - left bound " << lb << " is above the maximum available wavelength " << w[n - 1] << std::endl;
  661 + }
  662 + if (rb > w[n - 1]) {
  663 + std::cout << "bsq::area ERROR - right bound " << rb << " is above the maximum available wavelength " << w[0] << std::endl;
  664 + }
  665 + return false;
655 666 }
656 667 //to make sure right bound is bigger than left bound
657 668 else if(lb > rb){
658   - std::cout<<"ERROR: right bound should be bigger than left bound"<<std::endl;
659   - exit(1);
  669 + std::cout << "bsq::area ERROR - right bound " << rb << " should be larger than left bound " << lb << std::endl;
  670 + return false;
660 671 }
661 672  
662 673 //find the indices of the left and right baseline points
... ...
stim/envi/envi.h
... ... @@ -1046,7 +1046,7 @@ public:
1046 1046 else if(header.data_type == envi_header::float64)
1047 1047 return ((bsq<double>*)file)->ph_to_ph((double*)result, lb1, rb1, pos1, lb2, rb2, pos2, mask);
1048 1048 else
1049   - std::cout<<"ERROR: unidentified data type"<<std::endl;
  1049 + std::cout<<"envi::ph_to_ph ERROR - unidentified data type"<<std::endl;
1050 1050 }
1051 1051  
1052 1052 else if(header.interleave == envi_header::BIL){ //if the infile is bil file
... ... @@ -1055,7 +1055,7 @@ public:
1055 1055 else if(header.data_type == envi_header::float64)
1056 1056 return ((bil<double>*)file)->ph_to_ph((double*)result, lb1, rb1, pos1, lb2, rb2, pos2, mask);
1057 1057 else
1058   - std::cout<<"ERROR: unidentified data type"<<std::endl;
  1058 + std::cout<<"envi::ph_to_ph ERROR - unidentified data type"<<std::endl;
1059 1059 }
1060 1060  
1061 1061 else if(header.interleave == envi_header::BIP){ //if the infile is bip file
... ... @@ -1064,11 +1064,11 @@ public:
1064 1064 else if(header.data_type == envi_header::float64)
1065 1065 return ((bip<double>*)file)->ph_to_ph((double*)result, lb1, rb1, pos1, lb2, rb2, pos2, mask);
1066 1066 else
1067   - std::cout<<"ERROR: unidentified data type"<<std::endl;
  1067 + std::cout<<"envi::ph_to_ph ERROR - unidentified data type"<<std::endl;
1068 1068 }
1069 1069  
1070 1070 else{
1071   - std::cout<<"ERROR: unidentified file type"<<std::endl;
  1071 + std::cout<<"envi::ph_to_ph ERROR - unidentified file type"<<std::endl;
1072 1072 exit(1);
1073 1073 }
1074 1074 return false;
... ...
stim/image/image.h
... ... @@ -10,7 +10,8 @@
10 10 #endif
11 11 #include <vector>
12 12 #include <iostream>
13   -#include <limits>
  13 +#include <climits> //use limits and remove the MIN and MAX macros
  14 +#define NOMINMAX
14 15 #include <typeinfo>
15 16 #include <fstream>
16 17 #include <cstring>
... ... @@ -79,10 +80,12 @@ class image{
79 80 #endif
80 81 /// Returns the value for "white" based on the dynamic range (assumes white is 1.0 for floating point images)
81 82 T white(){
82   - return std::numeric_limits<T>::max();
  83 + if (typeid(T) == typeid(double) || typeid(T) == typeid(float))
  84 + return (T)1.0;
  85 + else
  86 + return std::numeric_limits<T>::max();
83 87 }
84 88  
85   -
86 89 public:
87 90  
88 91 size_t bytes() { return size() * sizeof(T); }
... ...