Commit 3ff136b3e1318a6efa27db1335b91e2e25b7ca5b
1 parent
0196c9ed
replaced C++11 code in stim::image with something more compatible
Showing
1 changed file
with
36 additions
and
18 deletions
Show diff stats
stim/image/image.h
... | ... | @@ -61,32 +61,50 @@ class image{ |
61 | 61 | |
62 | 62 | |
63 | 63 | int cv_type(){ |
64 | - /*if(std::is_same<T, unsigned char>::value) return CV_MAKETYPE(CV_8U, (int)C()); | |
65 | - if(std::is_same<T, char>::value) return CV_MAKETYPE(CV_8S, (int)C()); | |
66 | - if(std::is_same<T, unsigned short>::value) return CV_MAKETYPE(CV_16U, (int)C()); | |
67 | - if(std::is_same<T, short>::value) return CV_MAKETYPE(CV_16S, (int)C()); | |
68 | - if(std::is_same<T, int>::value) return CV_MAKETYPE(CV_32S, (int)C()); | |
69 | - if(std::is_same<T, float>::value) return CV_MAKETYPE(CV_32F, (int)C()); | |
70 | - if(std::is_same<T, double>::value) return CV_MAKETYPE(CV_64F, (int)C()); | |
64 | + // The following is C++ 11 code, but causes problems on some compilers (ex. nvcc). Below is my best approximation to a solution | |
65 | + | |
66 | + //if(std::is_same<T, unsigned char>::value) return CV_MAKETYPE(CV_8U, (int)C()); | |
67 | + //if(std::is_same<T, char>::value) return CV_MAKETYPE(CV_8S, (int)C()); | |
68 | + //if(std::is_same<T, unsigned short>::value) return CV_MAKETYPE(CV_16U, (int)C()); | |
69 | + //if(std::is_same<T, short>::value) return CV_MAKETYPE(CV_16S, (int)C()); | |
70 | + //if(std::is_same<T, int>::value) return CV_MAKETYPE(CV_32S, (int)C()); | |
71 | + //if(std::is_same<T, float>::value) return CV_MAKETYPE(CV_32F, (int)C()); | |
72 | + //if(std::is_same<T, double>::value) return CV_MAKETYPE(CV_64F, (int)C()); | |
73 | + | |
74 | + if(typeid(T) == typeid(unsigned char)) return CV_MAKETYPE(CV_8U, (int)C()); | |
75 | + if(typeid(T) == typeid(char)) return CV_MAKETYPE(CV_8S, (int)C()); | |
76 | + if(typeid(T) == typeid(unsigned short)) return CV_MAKETYPE(CV_16U, (int)C()); | |
77 | + if(typeid(T) == typeid(short)) return CV_MAKETYPE(CV_16S, (int)C()); | |
78 | + if(typeid(T) == typeid(int)) return CV_MAKETYPE(CV_32S, (int)C()); | |
79 | + if(typeid(T) == typeid(float)) return CV_MAKETYPE(CV_32F, (int)C()); | |
80 | + if(typeid(T) == typeid(double)) return CV_MAKETYPE(CV_64F, (int)C()); | |
71 | 81 | |
72 | 82 | std::cout<<"ERROR in stim::image::cv_type - no valid data type found"<<std::endl; |
73 | - exit(1);*/ | |
74 | - return CV_MAKETYPE(CV_8U, (int)C()); | |
83 | + exit(1); | |
75 | 84 | } |
76 | 85 | |
77 | 86 | /// Returns the value for "white" based on the dynamic range (assumes white is 1.0 for floating point images) |
78 | 87 | T white(){ |
79 | - /*if(std::is_same<T, unsigned char>::value) return UCHAR_MAX; | |
80 | - if(std::is_same<T, unsigned short>::value) return SHRT_MAX; | |
81 | - if(std::is_same<T, unsigned>::value) return UINT_MAX; | |
82 | - if(std::is_same<T, unsigned long>::value) return ULONG_MAX; | |
83 | - if(std::is_same<T, unsigned long long>::value) return ULLONG_MAX; | |
84 | - if(std::is_same<T, float>::value) return 1.0f; | |
85 | - if(std::is_same<T, double>::value) return 1.0; | |
88 | + // The following is C++ 11 code, but causes problems on some compilers (ex. nvcc). Below is my best approximation to a solution | |
89 | + | |
90 | + //if(std::is_same<T, unsigned char>::value) return UCHAR_MAX; | |
91 | + //if(std::is_same<T, unsigned short>::value) return SHRT_MAX; | |
92 | + //if(std::is_same<T, unsigned>::value) return UINT_MAX; | |
93 | + //if(std::is_same<T, unsigned long>::value) return ULONG_MAX; | |
94 | + //if(std::is_same<T, unsigned long long>::value) return ULLONG_MAX; | |
95 | + //if(std::is_same<T, float>::value) return 1.0f; | |
96 | + //if(std::is_same<T, double>::value) return 1.0; | |
97 | + | |
98 | + if(typeid(T) == typeid(unsigned char)) return UCHAR_MAX; | |
99 | + if(typeid(T) == typeid(unsigned short)) return SHRT_MAX; | |
100 | + if(typeid(T) == typeid(unsigned)) return UINT_MAX; | |
101 | + if(typeid(T) == typeid(unsigned long)) return ULONG_MAX; | |
102 | + if(typeid(T) == typeid(unsigned long long)) return ULLONG_MAX; | |
103 | + if(typeid(T) == typeid(float)) return 1.0f; | |
104 | + if(typeid(T) == typeid(double)) return 1.0; | |
86 | 105 | |
87 | 106 | std::cout<<"ERROR in stim::image::white - no white value known for this data type"<<std::endl; |
88 | - */ | |
89 | - return UCHAR_MAX; | |
107 | + exit(1); | |
90 | 108 | } |
91 | 109 | |
92 | 110 | ... | ... |