Index: gmic-1.6.0.0/src/CImg.h =================================================================== --- gmic-1.6.0.0.orig/src/CImg.h +++ gmic-1.6.0.0/src/CImg.h @@ -220,8 +220,13 @@ // OpenMP directives may be used in a (very) few CImg functions to get // advantages of multi-core CPUs. #ifdef cimg_use_openmp #include +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) +#define COLLAPSE(x) collapse(x) +#else +#define COLLAPSE(x) +#endif #endif // Configure OpenCV support. // (http://opencv.willowgarage.com/wiki/) @@ -10548,9 +10553,9 @@ namespace cimg_library_suffixed { **/ template CImg& operator+=(const t value) { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=524288) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)(*ptrd + value); return *this; @@ -10579,9 +10584,9 @@ namespace cimg_library_suffixed { if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)(*ptrd + lmp(x,y,z,c)); ++ptrd; } } @@ -10639,9 +10644,9 @@ namespace cimg_library_suffixed { - Writing \c ++img is equivalent to \c img+=1. **/ CImg& operator++() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=524288) #endif cimg_rof(*this,ptrd,T) ++*ptrd; return *this; @@ -10708,9 +10713,9 @@ namespace cimg_library_suffixed { **/ template CImg& operator-=(const t value) { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=524288) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)(*ptrd - value); return *this; @@ -10735,9 +10740,9 @@ namespace cimg_library_suffixed { if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)(*ptrd - lmp(x,y,z,c)); ++ptrd; } } @@ -10777,9 +10782,9 @@ namespace cimg_library_suffixed { Similar to operator++(), except that it performs a decrement instead of an increment. **/ CImg& operator--() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=524288) #endif cimg_rof(*this,ptrd,T) *ptrd = *ptrd-(T)1; return *this; @@ -10848,9 +10853,9 @@ namespace cimg_library_suffixed { **/ template CImg& operator*=(const t value) { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=262144) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)(*ptrd * value); return *this; @@ -10875,9 +10880,9 @@ namespace cimg_library_suffixed { if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)(*ptrd * lmp(x,y,z,c)); ++ptrd; } } @@ -10949,9 +10954,9 @@ namespace cimg_library_suffixed { cimg_instance, img._width,img._height,img._depth,img._spectrum,img._data); CImg<_cimg_Tt> res(img._width,_height); #ifdef cimg_use_openmp -#pragma omp parallel for if (size()>1024 && img.size()>1024) collapse(2) +#pragma omp parallel for if (size()>1024 && img.size()>1024) COLLAPSE(2) cimg_forXY(res,i,j) { _cimg_Ttdouble value = 0; cimg_forX(*this,k) value+=(*this)(k,j)*img(i,k); res(i,j) = (_cimg_Tt)value; } #else @@ -10969,9 +10974,9 @@ namespace cimg_library_suffixed { **/ template CImg& operator/=(const t value) { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) #pragma omp parallel for if (size()>=32768) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)(*ptrd / value); return *this; @@ -10996,9 +11001,9 @@ namespace cimg_library_suffixed { if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)(*ptrd / lmp(x,y,z,c)); ++ptrd; } } @@ -11066,9 +11071,9 @@ namespace cimg_library_suffixed { **/ template CImg& operator%=(const t value) { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=16384) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)cimg::mod(*ptrd,(T)value); return *this; @@ -11093,9 +11098,9 @@ namespace cimg_library_suffixed { if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)cimg::mod(*ptrd,(T)lmp(x,y,z,c)); ++ptrd; } } @@ -11165,9 +11170,9 @@ namespace cimg_library_suffixed { **/ template CImg& operator&=(const t value) { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=32768) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)((unsigned long)*ptrd & (unsigned long)value); return *this; @@ -11194,9 +11199,9 @@ namespace cimg_library_suffixed { if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)((unsigned long)*ptrd & (unsigned long)lmp(x,y,z,c)); ++ptrd; } } @@ -11266,9 +11271,9 @@ namespace cimg_library_suffixed { **/ template CImg& operator|=(const t value) { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=32768) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)((unsigned long)*ptrd | (unsigned long)value); return *this; @@ -11295,9 +11300,9 @@ namespace cimg_library_suffixed { if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)((unsigned long)*ptrd | (unsigned long)lmp(x,y,z,c)); ++ptrd; } } @@ -11369,9 +11374,9 @@ namespace cimg_library_suffixed { **/ template CImg& operator^=(const t value) { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=32768) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)((unsigned long)*ptrd ^ (unsigned long)value); return *this; @@ -11400,9 +11405,9 @@ namespace cimg_library_suffixed { if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)((unsigned long)*ptrd ^ (unsigned long)lmp(x,y,z,c)); ++ptrd; } } @@ -11474,9 +11479,9 @@ namespace cimg_library_suffixed { **/ template CImg& operator<<=(const t value) { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=65536) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)(((long)*ptrd) << (int)value); return *this; @@ -11501,9 +11506,9 @@ namespace cimg_library_suffixed { if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)((long)*ptrd << (int)lmp(x,y,z,c)); ++ptrd; } } @@ -11574,9 +11579,9 @@ namespace cimg_library_suffixed { **/ template CImg& operator>>=(const t value) { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=65536) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)(((long)*ptrd) >> (int)value); return *this; @@ -11601,9 +11606,9 @@ namespace cimg_library_suffixed { if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)((long)*ptrd >> (int)lmp(x,y,z,c)); ++ptrd; } } @@ -14947,9 +14952,9 @@ namespace cimg_library_suffixed { \image html ref_sqr.jpg **/ CImg& sqr() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=524288) #endif cimg_rof(*this,ptrd,T) { const T val = *ptrd; *ptrd = (T)(val*val); }; return *this; @@ -14974,9 +14979,9 @@ namespace cimg_library_suffixed { \image html ref_sqrt.jpg **/ CImg& sqrt() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=8192) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)std::sqrt((double)*ptrd); return *this; @@ -14995,9 +15000,9 @@ namespace cimg_library_suffixed { - The \newinstance returns a \c CImg image, if the pixel type \c T is \e not float-valued. **/ CImg& exp() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=4096) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)std::exp((double)*ptrd); return *this; @@ -15017,9 +15022,9 @@ namespace cimg_library_suffixed { - The \newinstance returns a \c CImg image, if the pixel type \c T is \e not float-valued. **/ CImg& log() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=262144) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)std::log((double)*ptrd); return *this; @@ -15039,9 +15044,9 @@ namespace cimg_library_suffixed { - The \newinstance returns a \c CImg image, if the pixel type \c T is \e not float-valued. **/ CImg& log2() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=4096) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)cimg::log2((double)*ptrd); return *this; @@ -15061,9 +15066,9 @@ namespace cimg_library_suffixed { - The \newinstance returns a \c CImg image, if the pixel type \c T is \e not float-valued. **/ CImg& log10() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=4096) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)std::log10((double)*ptrd); return *this; @@ -15082,9 +15087,9 @@ namespace cimg_library_suffixed { - The \newinstance returns a \c CImg image, if the pixel type \c T is \e not float-valued. **/ CImg& abs() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=524288) #endif cimg_rof(*this,ptrd,T) *ptrd = cimg::abs(*ptrd); return *this; @@ -15108,9 +15113,9 @@ namespace cimg_library_suffixed { - The \newinstance returns a \c CImg image, if the pixel type \c T is \e not float-valued. **/ CImg& sign() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=32768) #endif cimg_rof(*this,ptrd,T) *ptrd = cimg::sign(*ptrd); return *this; @@ -15130,9 +15135,9 @@ namespace cimg_library_suffixed { - The \newinstance returns a \c CImg image, if the pixel type \c T is \e not float-valued. **/ CImg& cos() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=8192) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)std::cos((double)*ptrd); return *this; @@ -15152,9 +15157,9 @@ namespace cimg_library_suffixed { - The \newinstance returns a \c CImg image, if the pixel type \c T is \e not float-valued. **/ CImg& sin() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=8192) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)std::sin((double)*ptrd); return *this; @@ -15175,9 +15180,9 @@ namespace cimg_library_suffixed { - The \newinstance returns a \c CImg image, if the pixel type \c T is \e not float-valued. **/ CImg& sinc() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=2048) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)cimg::sinc((double)*ptrd); return *this; @@ -15197,9 +15202,9 @@ namespace cimg_library_suffixed { - The \newinstance returns a \c CImg image, if the pixel type \c T is \e not float-valued. **/ CImg& tan() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=2048) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)std::tan((double)*ptrd); return *this; @@ -15219,9 +15224,9 @@ namespace cimg_library_suffixed { - The \newinstance returns a \c CImg image, if the pixel type \c T is \e not float-valued. **/ CImg& cosh() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=2048) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)std::cosh((double)*ptrd); return *this; @@ -15241,9 +15246,9 @@ namespace cimg_library_suffixed { - The \newinstance returns a \c CImg image, if the pixel type \c T is \e not float-valued. **/ CImg& sinh() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=2048) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)std::sinh((double)*ptrd); return *this; @@ -15263,9 +15268,9 @@ namespace cimg_library_suffixed { - The \newinstance returns a \c CImg image, if the pixel type \c T is \e not float-valued. **/ CImg& tanh() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=2048) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)std::tanh((double)*ptrd); return *this; @@ -15285,9 +15290,9 @@ namespace cimg_library_suffixed { - The \newinstance returns a \c CImg image, if the pixel type \c T is \e not float-valued. **/ CImg& acos() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=8192) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)std::acos((double)*ptrd); return *this; @@ -15307,9 +15312,9 @@ namespace cimg_library_suffixed { - The \newinstance returns a \c CImg image, if the pixel type \c T is \e not float-valued. **/ CImg& asin() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=8192) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)std::asin((double)*ptrd); return *this; @@ -15329,9 +15334,9 @@ namespace cimg_library_suffixed { - The \newinstance returns a \c CImg image, if the pixel type \c T is \e not float-valued. **/ CImg& atan() { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=8192) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)std::atan((double)*ptrd); return *this; @@ -15458,37 +15463,37 @@ namespace cimg_library_suffixed { **/ CImg& pow(const double p) { if (is_empty()) return *this; if (p==-4) { -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=32768) #endif cimg_rof(*this,ptrd,T) { const T val = *ptrd; *ptrd = (T)(1.0/(val*val*val*val)); } return *this; } if (p==-3) { -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=32768) #endif cimg_rof(*this,ptrd,T) { const T val = *ptrd; *ptrd = (T)(1.0/(val*val*val)); } return *this; } if (p==-2) { -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=32768) #endif cimg_rof(*this,ptrd,T) { const T val = *ptrd; *ptrd = (T)(1.0/(val*val)); } return *this; } if (p==-1) { -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=32768) #endif cimg_rof(*this,ptrd,T) { const T val = *ptrd; *ptrd = (T)(1.0/val); } return *this; } if (p==-0.5) { -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=8192) #endif cimg_rof(*this,ptrd,T) { const T val = *ptrd; *ptrd = (T)(1/std::sqrt((double)val)); } return *this; @@ -15497,22 +15502,22 @@ namespace cimg_library_suffixed { if (p==0.5) return sqrt(); if (p==1) return *this; if (p==2) return sqr(); if (p==3) { -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=262144) #endif cimg_rof(*this,ptrd,T) { const T val = *ptrd; *ptrd = val*val*val; } return *this; } if (p==4) { -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=131072) #endif cimg_rof(*this,ptrd,T) { const T val = *ptrd; *ptrd = val*val*val*val; } return *this; } -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=1024) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)std::pow((double)*ptrd,p); return *this; @@ -15543,9 +15548,9 @@ namespace cimg_library_suffixed { if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)std::pow((double)*ptrd,lmp(x,y,z,c)); ++ptrd; } } @@ -15602,9 +15607,9 @@ namespace cimg_library_suffixed { Similar to operator<<=(unsigned int), except that it performs a left rotation instead of a left shift. **/ CImg& rol(const unsigned int n=1) { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=32768) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)cimg::rol(*ptrd,n); return *this; @@ -15636,9 +15641,9 @@ namespace cimg_library_suffixed { if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)cimg::rol(*ptrd,(unsigned int)lmp(x,y,z,c)); ++ptrd; } } @@ -15695,9 +15700,9 @@ namespace cimg_library_suffixed { Similar to operator>>=(unsigned int), except that it performs a right rotation instead of a right shift. **/ CImg& ror(const unsigned int n=1) { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=32768) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)cimg::ror(*ptrd,n); return *this; @@ -15729,9 +15734,9 @@ namespace cimg_library_suffixed { if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)cimg::ror(*ptrd,(unsigned int)lmp(x,y,z,c)); ++ptrd; } } @@ -15790,9 +15795,9 @@ namespace cimg_library_suffixed { \f$\mathrm{min}(I_{(x,y,z,c)},\mathrm{val})\f$. **/ CImg& min(const T val) { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=65536) #endif cimg_rof(*this,ptrd,T) *ptrd = cimg::min(*ptrd,val); return *this; @@ -15850,9 +15855,9 @@ namespace cimg_library_suffixed { if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)cimg::min(*ptrd,(T)lmp(x,y,z,c)); ++ptrd; } } @@ -15887,9 +15892,9 @@ namespace cimg_library_suffixed { \f$\mathrm{max}(I_{(x,y,z,c)},\mathrm{val})\f$. **/ CImg& max(const T val) { if (is_empty()) return *this; -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=65536) #endif cimg_rof(*this,ptrd,T) *ptrd = cimg::max(*ptrd,val); return *this; @@ -15947,9 +15952,9 @@ namespace cimg_library_suffixed { if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)cimg::max(*ptrd,(T)lmp(x,y,z,c)); ++ptrd; } } @@ -18509,9 +18514,9 @@ namespace cimg_library_suffixed { if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) *ptrd++ = (T)lmp(x,y,z,c); } @@ -18744,9 +18749,9 @@ namespace cimg_library_suffixed { - \c 1: Forward. **/ CImg& round(const double y=1, const int rounding_type=0) { if (y>0) -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) #pragma omp parallel for if (size()>=8192) #endif cimg_rof(*this,ptrd,T) *ptrd = cimg::round(*ptrd,y,rounding_type); return *this; @@ -18855,9 +18860,9 @@ namespace cimg_library_suffixed { T m, M = max_min(m); const Tfloat fm = (Tfloat)m, fM = (Tfloat)M; if (m==M) return fill(min_value); if (m!=a || M!=b) -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=65536) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)((*ptrd-fm)/(fM-fm)*(b-a)+a); return *this; @@ -18879,9 +18884,9 @@ namespace cimg_library_suffixed { **/ CImg& normalize() { const unsigned long whd = (unsigned long)_width*_height*_depth; #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width>=512 && _height*_depth>=16) +#pragma omp parallel for COLLAPSE(2) if (_width>=512 && _height*_depth>=16) #endif cimg_forYZ(*this,y,z) { T *ptrd = data(0,y,z,0); cimg_forX(*this,x) { @@ -18925,9 +18930,9 @@ namespace cimg_library_suffixed { CImg res(_width,_height,_depth); switch (norm_type) { case -1 : { // Linf norm #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width>=512 && _height*_depth>=16) +#pragma omp parallel for COLLAPSE(2) if (_width>=512 && _height*_depth>=16) #endif cimg_forYZ(*this,y,z) { const unsigned long off = offset(0,y,z); const T *ptrs = _data + off; @@ -18941,9 +18946,9 @@ namespace cimg_library_suffixed { } } break; case 1 : { // L1 norm #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width>=512 && _height*_depth>=16) +#pragma omp parallel for COLLAPSE(2) if (_width>=512 && _height*_depth>=16) #endif cimg_forYZ(*this,y,z) { const unsigned long off = offset(0,y,z); const T *ptrs = _data + off; @@ -18957,9 +18962,9 @@ namespace cimg_library_suffixed { } } break; default : { // L2 norm #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width>=512 && _height*_depth>=16) +#pragma omp parallel for COLLAPSE(2) if (_width>=512 && _height*_depth>=16) #endif cimg_forYZ(*this,y,z) { const unsigned long off = offset(0,y,z); const T *ptrs = _data + off; @@ -18989,9 +18994,9 @@ namespace cimg_library_suffixed { **/ CImg& cut(const T min_value, const T max_value) { if (is_empty()) return *this; const T a = min_value=32768) #endif cimg_rof(*this,ptrd,T) *ptrd = (*ptrdb)?b:*ptrd); return *this; @@ -19022,16 +19027,16 @@ namespace cimg_library_suffixed { if (is_empty()) return *this; Tfloat m, M = (Tfloat)max_min(m), range = M - m; if (range>0) { if (keep_range) -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=32768) #endif cimg_rof(*this,ptrd,T) { const unsigned int val = (unsigned int)((*ptrd-m)*nb_levels/range); *ptrd = (T)(m + cimg::min(val,nb_levels-1)*range/nb_levels); } else -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=32768) #endif cimg_rof(*this,ptrd,T) { const unsigned int val = (unsigned int)((*ptrd-m)*nb_levels/range); @@ -19061,27 +19066,27 @@ namespace cimg_library_suffixed { CImg& threshold(const T value, const bool soft_threshold=false, const bool strict_threshold=false) { if (is_empty()) return *this; if (strict_threshold) { if (soft_threshold) -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=32768) #endif cimg_rof(*this,ptrd,T) { const T v = *ptrd; *ptrd = v>value?(T)(v-value):v<-(float)value?(T)(v+value):(T)0; } else -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=65536) #endif cimg_rof(*this,ptrd,T) *ptrd = *ptrd>value?(T)1:(T)0; } else { if (soft_threshold) -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=32768) #endif cimg_rof(*this,ptrd,T) { const T v = *ptrd; *ptrd = v>=value?(T)(v-value):v<=-(float)value?(T)(v+value):(T)0; } else -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=65536) #endif cimg_rof(*this,ptrd,T) *ptrd = *ptrd>=value?(T)1:(T)0; } @@ -19158,9 +19163,9 @@ namespace cimg_library_suffixed { T vmin = min_value hist = get_histogram(nb_levels,vmin,vmax); unsigned long cumul = 0; cimg_forX(hist,pos) { cumul+=hist[pos]; hist[pos] = cumul; } -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=1048576) #endif cimg_rof(*this,ptrd,T) { const int pos = (int)((*ptrd-vmin)*(nb_levels-1)/(vmax-vmin)); @@ -19374,9 +19379,9 @@ namespace cimg_library_suffixed { } else { // Non-dithered versions switch (_spectrum) { case 1 : { // Optimized for scalars. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width>=64 && _height*_depth>=16 && pwhd>=16) +#pragma omp parallel for COLLAPSE(2) if (_width>=64 && _height*_depth>=16 && pwhd>=16) #endif cimg_forYZ(*this,y,z) { tuint *ptrd = res.data(0,y,z); for (const T *ptrs0 = data(0,y,z), *ptrs_end = ptrs0 + _width; ptrs0=64 && _height*_depth>=16 && pwhd>=16) +#pragma omp parallel for COLLAPSE(2) if (_width>=64 && _height*_depth>=16 && pwhd>=16) #endif cimg_forYZ(*this,y,z) { tuint *ptrd = res.data(0,y,z), *ptrd1 = ptrd + whd; for (const T *ptrs0 = data(0,y,z), *ptrs1 = ptrs0 + whd, *ptrs_end = ptrs0 + _width; ptrs0=64 && _height*_depth>=16 && pwhd>=16) +#pragma omp parallel for COLLAPSE(2) if (_width>=64 && _height*_depth>=16 && pwhd>=16) #endif cimg_forYZ(*this,y,z) { tuint *ptrd = res.data(0,y,z), *ptrd1 = ptrd + whd, *ptrd2 = ptrd1 + whd; for (const T *ptrs0 = data(0,y,z), *ptrs1 = ptrs0 + whd, *ptrs2 = ptrs1 + whd, @@ -19438,9 +19443,9 @@ namespace cimg_library_suffixed { } } break; default : // Generic version. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width>=64 && _height*_depth>=16 && pwhd>=16) +#pragma omp parallel for COLLAPSE(2) if (_width>=64 && _height*_depth>=16 && pwhd>=16) #endif cimg_forYZ(*this,y,z) { tuint *ptrd = res.data(0,y,z); for (const T *ptrs = data(0,y,z), *ptrs_end = ptrs + _width; ptrs=65536) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=65536) #endif for (int c = c0; c<(int)sc; c+=spectrum()) for (int z = z0; z<(int)sz; z+=depth()) for (int y = y0; y<(int)sy; y+=height()) @@ -21163,9 +21168,9 @@ namespace cimg_library_suffixed { curr+=fx; *(poff++) = (unsigned int)curr - (unsigned int)old; } #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (resx.size()>=65536) +#pragma omp parallel for COLLAPSE(3) if (resx.size()>=65536) #endif cimg_forYZC(resx,y,z,c) { const T *ptrs = data(0,y,z,c), *const ptrsmax = ptrs + (_width-1); T *ptrd = resx.data(0,y,z,c); @@ -21198,9 +21203,9 @@ namespace cimg_library_suffixed { curr+=fy; *(poff++) = sx*((unsigned int)curr-(unsigned int)old); } #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (resy.size()>=65536) +#pragma omp parallel for COLLAPSE(3) if (resy.size()>=65536) #endif cimg_forXZC(resy,x,z,c) { const T *ptrs = resx.data(x,0,z,c), *const ptrsmax = ptrs + (_height-1)*sx; T *ptrd = resy.data(x,0,z,c); @@ -21236,9 +21241,9 @@ namespace cimg_library_suffixed { curr+=fz; *(poff++) = sxy*((unsigned int)curr - (unsigned int)old); } #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (resz.size()>=65536) +#pragma omp parallel for COLLAPSE(3) if (resz.size()>=65536) #endif cimg_forXYC(resz,x,y,c) { const T *ptrs = resy.data(x,y,0,c), *const ptrsmax = ptrs + (_depth-1)*sxy; T *ptrd = resz.data(x,y,0,c); @@ -21275,9 +21280,9 @@ namespace cimg_library_suffixed { curr+=fc; *(poff++) = sxyz*((unsigned int)curr - (unsigned int)old); } #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (resc.size()>=65536) +#pragma omp parallel for COLLAPSE(3) if (resc.size()>=65536) #endif cimg_forXYZ(resc,x,y,z) { const T *ptrs = resz.data(x,y,z,0), *const ptrsmax = ptrs + (_spectrum-1)*sxyz; T *ptrd = resc.data(x,y,z,0); @@ -21388,9 +21393,9 @@ namespace cimg_library_suffixed { curr+=fx; *(poff++) = (unsigned int)curr - (unsigned int)old; } #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (resx.size()>=65536) +#pragma omp parallel for COLLAPSE(3) if (resx.size()>=65536) #endif cimg_forYZC(resx,y,z,c) { const T *const ptrs0 = data(0,y,z,c), *ptrs = ptrs0, *const ptrsmax = ptrs + (_width-2); T *ptrd = resx.data(0,y,z,c); @@ -21429,9 +21434,9 @@ namespace cimg_library_suffixed { curr+=fy; *(poff++) = sx*((unsigned int)curr-(unsigned int)old); } #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (resy.size()>=65536) +#pragma omp parallel for COLLAPSE(3) if (resy.size()>=65536) #endif cimg_forXZC(resy,x,z,c) { const T *const ptrs0 = resx.data(x,0,z,c), *ptrs = ptrs0, *const ptrsmax = ptrs + (_height-2)*sx; T *ptrd = resy.data(x,0,z,c); @@ -21473,9 +21478,9 @@ namespace cimg_library_suffixed { curr+=fz; *(poff++) = sxy*((unsigned int)curr - (unsigned int)old); } #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (resz.size()>=65536) +#pragma omp parallel for COLLAPSE(3) if (resz.size()>=65536) #endif cimg_forXYC(resz,x,y,c) { const T *const ptrs0 = resy.data(x,y,0,c), *ptrs = ptrs0, *const ptrsmax = ptrs + (_depth-2)*sxy; T *ptrd = resz.data(x,y,0,c); @@ -21518,9 +21523,9 @@ namespace cimg_library_suffixed { curr+=fc; *(poff++) = sxyz*((unsigned int)curr - (unsigned int)old); } #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (resc.size()>=65536) +#pragma omp parallel for COLLAPSE(3) if (resc.size()>=65536) #endif cimg_forXYZ(resc,x,y,z) { const T *const ptrs0 = resz.data(x,y,z,0), *ptrs = ptrs0, *const ptrsmax = ptrs + (_spectrum-2)*sxyz; T *ptrd = resc.data(x,y,z,0); @@ -21572,9 +21577,9 @@ namespace cimg_library_suffixed { curr+=fx; *(poff++) = (unsigned int)curr - (unsigned int)old; } #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (resx.size()>=65536) +#pragma omp parallel for COLLAPSE(3) if (resx.size()>=65536) #endif cimg_forYZC(resx,y,z,c) { const T *const ptrs0 = data(0,y,z,c), *ptrs = ptrs0, *const ptrsmin = ptrs0 + 1, *const ptrsmax = ptrs0 + (_width-2); @@ -21620,9 +21625,9 @@ namespace cimg_library_suffixed { curr+=fy; *(poff++) = sx*((unsigned int)curr-(unsigned int)old); } #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (resy.size()>=65536) +#pragma omp parallel for COLLAPSE(3) if (resy.size()>=65536) #endif cimg_forXZC(resy,x,z,c) { const T *const ptrs0 = resx.data(x,0,z,c), *ptrs = ptrs0, *const ptrsmin = ptrs0 + sx, *const ptrsmax = ptrs0 + (_height-2)*sx; @@ -21671,9 +21676,9 @@ namespace cimg_library_suffixed { curr+=fz; *(poff++) = sxy*((unsigned int)curr - (unsigned int)old); } #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (resz.size()>=65536) +#pragma omp parallel for COLLAPSE(3) if (resz.size()>=65536) #endif cimg_forXYC(resz,x,y,c) { const T *const ptrs0 = resy.data(x,y,0,c), *ptrs = ptrs0, *const ptrsmin = ptrs0 + sxy, *const ptrsmax = ptrs0 + (_depth-2)*sxy; @@ -21723,9 +21728,9 @@ namespace cimg_library_suffixed { curr+=fc; *(poff++) = sxyz*((unsigned int)curr - (unsigned int)old); } #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (resc.size()>=65536) +#pragma omp parallel for COLLAPSE(3) if (resc.size()>=65536) #endif cimg_forXYZ(resc,x,y,z) { const T *const ptrs0 = resz.data(x,y,z,0), *ptrs = ptrs0, *const ptrsmin = ptrs0 + sxyz, *const ptrsmax = ptrs + (_spectrum-2)*sxyz; @@ -22560,25 +22565,25 @@ namespace cimg_library_suffixed { case 0 : { // Dirichlet boundaries. switch (interpolation) { case 2 : { // Cubic interpolation. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=2048) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=2048) #endif cimg_forXYZC(res,x,y,z,c) { const Tfloat val = cubic_atXY(w2 + (x-dw2)*ca + (y-dh2)*sa,h2 - (x-dw2)*sa + (y-dh2)*ca,z,c,0); res(x,y,z,c) = (T)(valvmax?vmax:val); } } break; case 1 : { // Linear interpolation. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=2048) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=2048) #endif cimg_forXYZC(res,x,y,z,c) res(x,y,z,c) = (T)linear_atXY(w2 + (x-dw2)*ca + (y-dh2)*sa,h2 - (x-dw2)*sa + (y-dh2)*ca,z,c,0); } break; default : { // Nearest-neighbor interpolation. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=2048) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=2048) #endif cimg_forXYZC(res,x,y,z,c) res(x,y,z,c) = atXY((int)(w2 + (x-dw2)*ca + (y-dh2)*sa),(int)(h2 - (x-dw2)*sa + (y-dh2)*ca),z,c,0); } @@ -22587,25 +22592,25 @@ namespace cimg_library_suffixed { case 1 : { // Neumann boundaries. switch (interpolation) { case 2 : { // Cubic interpolation. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=2048) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=2048) #endif cimg_forXYZC(res,x,y,z,c) { const Tfloat val = _cubic_atXY(w2 + (x-dw2)*ca + (y-dh2)*sa,h2 - (x-dw2)*sa + (y-dh2)*ca,z,c); res(x,y,z,c) = (T)(valvmax?vmax:val); } } break; case 1 : { // Linear interpolation. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=2048) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=2048) #endif cimg_forXYZC(res,x,y,z,c) res(x,y,z,c) = (T)_linear_atXY(w2 + (x-dw2)*ca + (y-dh2)*sa,h2 - (x-dw2)*sa + (y-dh2)*ca,z,c); } break; default : { // Nearest-neighbor interpolation. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=2048) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=2048) #endif cimg_forXYZC(res,x,y,z,c) res(x,y,z,c) = _atXY((int)(w2 + (x-dw2)*ca + (y-dh2)*sa),(int)(h2 - (x-dw2)*sa + (y-dh2)*ca),z,c); } @@ -22614,9 +22619,9 @@ namespace cimg_library_suffixed { case 2 : { // Periodic boundaries. switch (interpolation) { case 2 : { // Cubic interpolation. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=2048) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=2048) #endif cimg_forXYZC(res,x,y,z,c) { const Tfloat val = _cubic_atXY(cimg::mod(w2 + (x-dw2)*ca + (y-dh2)*sa,(float)width()), cimg::mod(h2 - (x-dw2)*sa + (y-dh2)*ca,(float)height()),z,c); @@ -22624,17 +22629,17 @@ namespace cimg_library_suffixed { } } break; case 1 : { // Linear interpolation. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=2048) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=2048) #endif cimg_forXYZC(res,x,y,z,c) res(x,y,z,c) = (T)_linear_atXY(cimg::mod(w2 + (x-dw2)*ca + (y-dh2)*sa,(float)width()), cimg::mod(h2 - (x-dw2)*sa + (y-dh2)*ca,(float)height()),z,c); } break; default : { // Nearest-neighbor interpolation. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=2048) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=2048) #endif cimg_forXYZC(res,x,y,z,c) res(x,y,z,c) = (*this)(cimg::mod((int)(w2 + (x-dw2)*ca + (y-dh2)*sa),width()), cimg::mod((int)(h2 - (x-dw2)*sa + (y-dh2)*ca),height()),z,c); @@ -22686,25 +22691,25 @@ namespace cimg_library_suffixed { case 0 : { switch (interpolation) { case 2 : { #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=2048) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=2048) #endif cimg_forXYZC(res,x,y,z,c) { const Tfloat val = cubic_atXY(cx + (x-cx)*ca + (y-cy)*sa,cy - (x-cx)*sa + (y-cy)*ca,z,c,0); res(x,y,z,c) = (T)(valvmax?vmax:val); } } break; case 1 : { #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=2048) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=2048) #endif cimg_forXYZC(res,x,y,z,c) res(x,y,z,c) = (T)linear_atXY(cx + (x-cx)*ca + (y-cy)*sa,cy - (x-cx)*sa + (y-cy)*ca,z,c,0); } break; default : { #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=2048) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=2048) #endif cimg_forXYZC(res,x,y,z,c) res(x,y,z,c) = atXY((int)(cx + (x-cx)*ca + (y-cy)*sa),(int)(cy - (x-cx)*sa + (y-cy)*ca),z,c,0); } @@ -22713,25 +22718,25 @@ namespace cimg_library_suffixed { case 1 : { switch (interpolation) { case 2 : { #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=2048) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=2048) #endif cimg_forXYZC(res,x,y,z,c) { const Tfloat val = _cubic_atXY(cx + (x-cx)*ca + (y-cy)*sa,cy - (x-cx)*sa + (y-cy)*ca,z,c); res(x,y,z,c) = (T)(valvmax?vmax:val); } } break; case 1 : { #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=2048) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=2048) #endif cimg_forXYZC(res,x,y,z,c) res(x,y,z,c) = (T)_linear_atXY(cx + (x-cx)*ca + (y-cy)*sa,cy - (x-cx)*sa + (y-cy)*ca,z,c); } break; default : { #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=2048) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=2048) #endif cimg_forXYZC(res,x,y,z,c) res(x,y,z,c) = _atXY((int)(cx + (x-cx)*ca + (y-cy)*sa),(int)(cy - (x-cx)*sa + (y-cy)*ca),z,c); } @@ -22740,9 +22745,9 @@ namespace cimg_library_suffixed { case 2 : { switch (interpolation) { case 2 : { #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=2048) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=2048) #endif cimg_forXYZC(res,x,y,z,c) { const Tfloat val = _cubic_atXY(cimg::mod(cx + (x-cx)*ca + (y-cy)*sa,(float)width()), cimg::mod(cy - (x-cx)*sa + (y-cy)*ca,(float)height()),z,c); @@ -22750,17 +22755,17 @@ namespace cimg_library_suffixed { } } break; case 1 : { #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=2048) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=2048) #endif cimg_forXYZC(res,x,y,z,c) res(x,y,z,c) = (T)_linear_atXY(cimg::mod(cx + (x-cx)*ca + (y-cy)*sa,(float)width()), cimg::mod(cy - (x-cx)*sa + (y-cy)*ca,(float)height()),z,c); } break; default : { #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=2048) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=2048) #endif cimg_forXYZC(res,x,y,z,c) res(x,y,z,c) = (*this)(cimg::mod((int)(cx + (x-cx)*ca + (y-cy)*sa),width()), cimg::mod((int)(cy - (x-cx)*sa + (y-cy)*ca),height()),z,c); @@ -22808,50 +22813,50 @@ namespace cimg_library_suffixed { if (is_relative) { // Relative warp. if (interpolation==2) { // Cubic interpolation. if (boundary_conditions==2) // Periodic boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=4096) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=4096) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)_cubic_atX(cimg::mod(x - (float)*(ptrs0++),(float)_width),y,z,c); } else if (boundary_conditions==1) // Neumann boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=4096) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=4096) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)_cubic_atX(x - (float)*(ptrs0++),y,z,c); } else // Dirichlet boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=4096) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=4096) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)cubic_atX(x - (float)*(ptrs0++),y,z,c,0); } } else if (interpolation==1) { // Linear interpolation. if (boundary_conditions==2) // Periodic boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=1048576) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=1048576) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)_linear_atX(cimg::mod(x - (float)*(ptrs0++),(float)_width),y,z,c); } else if (boundary_conditions==1) // Neumann boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=1048576) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=1048576) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)_linear_atX(x - (float)*(ptrs0++),y,z,c); } else // Dirichlet boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=1048576) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=1048576) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)linear_atX(x - (float)*(ptrs0++),y,z,c,0); @@ -22876,50 +22881,50 @@ namespace cimg_library_suffixed { } else { // Absolute warp. if (interpolation==2) { // Cubic interpolation. if (boundary_conditions==2) // Periodic boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=4096) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=4096) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)_cubic_atX(cimg::mod((float)*(ptrs0++),(float)_width),0,0,c); } else if (boundary_conditions==1) // Neumann boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=4096) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=4096) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)_cubic_atX((float)*(ptrs0++),0,0,c); } else // Dirichlet boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=4096) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=4096) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)cubic_atX((float)*(ptrs0++),0,0,c,0); } } else if (interpolation==1) { // Linear interpolation. if (boundary_conditions==2) // Periodic boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=1048576) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=1048576) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)_linear_atX(cimg::mod((float)*(ptrs0++),(float)_width),0,0,c); } else if (boundary_conditions==1) // Neumann boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=1048576) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=1048576) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)_linear_atX((float)*(ptrs0++),0,0,c); } else // Dirichlet boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=1048576) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=1048576) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)linear_atX((float)*(ptrs0++),0,0,c,0); @@ -22947,52 +22952,52 @@ namespace cimg_library_suffixed { if (is_relative) { // Relative warp. if (interpolation==2) { // Cubic interpolation. if (boundary_conditions==2) // Periodic boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=4096) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=4096) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)_cubic_atXY(cimg::mod(x - (float)*(ptrs0++),(float)_width), cimg::mod(y - (float)*(ptrs1++),(float)_height),z,c); } else if (boundary_conditions==1) // Neumann boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=4096) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=4096) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)_cubic_atXY(x - (float)*(ptrs0++),y - (float)*(ptrs1++),z,c); } else // Dirichlet boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=4096) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=4096) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)cubic_atXY(x - (float)*(ptrs0++),y - (float)*(ptrs1++),z,c,0); } } else if (interpolation==1) { // Linear interpolation. if (boundary_conditions==2) // Periodic boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=1048576) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=1048576) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)_linear_atXY(cimg::mod(x - (float)*(ptrs0++),(float)_width), cimg::mod(y - (float)*(ptrs1++),(float)_height),z,c); } else if (boundary_conditions==1) // Neumann boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=1048576) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=1048576) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)_linear_atXY(x - (float)*(ptrs0++),y - (float)*(ptrs1++),z,c); } else // Dirichlet boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=1048576) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=1048576) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)linear_atXY(x - (float)*(ptrs0++),y - (float)*(ptrs1++),z,c,0); @@ -23018,52 +23023,52 @@ namespace cimg_library_suffixed { } else { // Absolute warp. if (interpolation==2) { // Cubic interpolation. if (boundary_conditions==2) // Periodic boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=4096) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=4096) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)_cubic_atXY(cimg::mod((float)*(ptrs0++),(float)_width), cimg::mod((float)*(ptrs1++),(float)_height),0,c); } else if (boundary_conditions==1) // Neumann boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=4096) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=4096) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)_cubic_atXY((float)*(ptrs0++),(float)*(ptrs1++),0,c); } else // Dirichlet boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=4096) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=4096) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)cubic_atXY((float)*(ptrs0++),(float)*(ptrs1++),0,c,0); } } else if (interpolation==1) { // Linear interpolation. if (boundary_conditions==2) // Periodic boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=1048576) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=1048576) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)_linear_atXY(cimg::mod((float)*(ptrs0++),(float)_width), cimg::mod((float)*(ptrs1++),(float)_height),0,c); } else if (boundary_conditions==1) // Neumann boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=1048576) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=1048576) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)_linear_atXY((float)*(ptrs0++),(float)*(ptrs1++),0,c); } else // Dirichlet boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=1048576) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=1048576) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)linear_atXY((float)*(ptrs0++),(float)*(ptrs1++),0,c,0); @@ -23092,9 +23097,9 @@ namespace cimg_library_suffixed { if (is_relative) { // Relative warp. if (interpolation==2) { // Cubic interpolation. if (boundary_conditions==2) // Periodic boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=4096) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=4096) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1), *ptrs2 = warp.data(0,y,z,2); T *ptrd = res.data(0,y,z,c); @@ -23103,9 +23108,9 @@ namespace cimg_library_suffixed { cimg::mod(z - (float)*(ptrs2++),(float)_depth),c); } else if (boundary_conditions==1) // Neumann boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=4096) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=4096) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1), *ptrs2 = warp.data(0,y,z,2); T *ptrd = res.data(0,y,z,c); @@ -23113,9 +23118,9 @@ namespace cimg_library_suffixed { *(ptrd++) = (T)_cubic_atXYZ(x - (float)*(ptrs0++),y - (float)*(ptrs1++),z - (float)*(ptrs2++),c); } else // Dirichlet boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=4096) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=4096) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1), *ptrs2 = warp.data(0,y,z,2); T *ptrd = res.data(0,y,z,c); @@ -23124,9 +23129,9 @@ namespace cimg_library_suffixed { } } else if (interpolation==1) { // Linear interpolation. if (boundary_conditions==2) // Periodic boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=1048576) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=1048576) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1), *ptrs2 = warp.data(0,y,z,2); T *ptrd = res.data(0,y,z,c); @@ -23135,9 +23140,9 @@ namespace cimg_library_suffixed { cimg::mod(z - (float)*(ptrs2++),(float)_depth),c); } else if (boundary_conditions==1) // Neumann boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=1048576) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=1048576) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1), *ptrs2 = warp.data(0,y,z,2); T *ptrd = res.data(0,y,z,c); @@ -23145,9 +23150,9 @@ namespace cimg_library_suffixed { *(ptrd++) = (T)_linear_atXYZ(x - (float)*(ptrs0++),y - (float)*(ptrs1++),z - (float)*(ptrs2++),c); } else // Dirichlet boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=1048576) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=1048576) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1), *ptrs2 = warp.data(0,y,z,2); T *ptrd = res.data(0,y,z,c); @@ -23179,9 +23184,9 @@ namespace cimg_library_suffixed { } else { // Absolute warp. if (interpolation==2) { // Cubic interpolation. if (boundary_conditions==2) // Periodic boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=4096) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=4096) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1), *ptrs2 = warp.data(0,y,z,2); T *ptrd = res.data(0,y,z,c); @@ -23190,18 +23195,18 @@ namespace cimg_library_suffixed { cimg::mod((float)*(ptrs2++),(float)_depth),c); } else if (boundary_conditions==1) // Neumann boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=4096) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=4096) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1), *ptrs2 = warp.data(0,y,z,2); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)_cubic_atXYZ((float)*(ptrs0++),(float)*(ptrs1++),(float)*(ptrs2++),c); } else // Dirichlet boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=4096) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=4096) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1), *ptrs2 = warp.data(0,y,z,2); T *ptrd = res.data(0,y,z,c); @@ -23209,9 +23214,9 @@ namespace cimg_library_suffixed { } } else if (interpolation==1) { // Linear interpolation. if (boundary_conditions==2) // Periodic boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=1048576) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=1048576) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1), *ptrs2 = warp.data(0,y,z,2); T *ptrd = res.data(0,y,z,c); @@ -23220,18 +23225,18 @@ namespace cimg_library_suffixed { cimg::mod((float)*(ptrs2++),(float)_depth),c); } else if (boundary_conditions==1) // Neumann boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=1048576) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=1048576) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1), *ptrs2 = warp.data(0,y,z,2); T *ptrd = res.data(0,y,z,c); cimg_forX(res,x) *(ptrd++) = (T)_linear_atXYZ((float)*(ptrs0++),(float)*(ptrs1++),(float)*(ptrs2++),c); } else // Dirichlet boundaries. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (res.size()>=1048576) +#pragma omp parallel for COLLAPSE(3) if (res.size()>=1048576) #endif cimg_forYZC(res,y,z,c) { const t *ptrs0 = warp.data(0,y,z,0), *ptrs1 = warp.data(0,y,z,1), *ptrs2 = warp.data(0,y,z,2); T *ptrd = res.data(0,y,z,c); @@ -24547,9 +24552,9 @@ namespace cimg_library_suffixed { const CImg _mask = mask.get_shared_channel(c%mask._spectrum); if (is_normalized) { // Normalized correlation. const Ttfloat _M = (Ttfloat)_mask.magnitude(2), M = _M*_M; #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (_width*_height*_depth>=32768) +#pragma omp parallel for COLLAPSE(3) if (_width*_height*_depth>=32768) #endif for (int z = mz1; z=256 && _height*_depth>=128) +#pragma omp parallel for COLLAPSE(2) if (_width>=256 && _height*_depth>=128) #endif cimg_forYZ(res,y,z) for (int x = 0; x=mye || z=mze)?++x:((x=mxe)?++x:(x=mxe))) { Ttfloat val = 0, N = 0; @@ -24582,9 +24587,9 @@ namespace cimg_library_suffixed { res(x,y,z,c) = (Ttfloat)(N?val/std::sqrt(N):0); } else #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width>=256 && _height*_depth>=128) +#pragma omp parallel for COLLAPSE(2) if (_width>=256 && _height*_depth>=128) #endif cimg_forYZ(res,y,z) for (int x = 0; x=mye || z=mze)?++x:((x=mxe)?++x:(x=mxe))) { Ttfloat val = 0, N = 0; @@ -24599,9 +24604,9 @@ namespace cimg_library_suffixed { res(x,y,z,c) = (Ttfloat)(N?val/std::sqrt(N):0); } } else { // Classical correlation. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (_width*_height*_depth>=32768) +#pragma omp parallel for COLLAPSE(3) if (_width*_height*_depth>=32768) #endif for (int z = mz1; z=256 && _height*_depth>=128) +#pragma omp parallel for COLLAPSE(2) if (_width>=256 && _height*_depth>=128) #endif cimg_forYZ(res,y,z) for (int x = 0; x=mye || z=mze)?++x:((x=mxe)?++x:(x=mxe))) { Ttfloat val = 0; @@ -24626,9 +24631,9 @@ namespace cimg_library_suffixed { res(x,y,z,c) = (Ttfloat)val; } else #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width>=256 && _height*_depth>=128) +#pragma omp parallel for COLLAPSE(2) if (_width>=256 && _height*_depth>=128) #endif cimg_forYZ(res,y,z) for (int x = 0; x=mye || z=mze)?++x:((x=mxe)?++x:(x=mxe))) { Ttfloat val = 0; @@ -24699,9 +24704,9 @@ namespace cimg_library_suffixed { const CImg _img = get_shared_channel(c%_spectrum); const CImg _mask = mask.get_shared_channel(c%mask._spectrum); if (is_normalized) { // Normalized erosion. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (_width*_height*_depth>=32768) +#pragma omp parallel for COLLAPSE(3) if (_width*_height*_depth>=32768) #endif for (int z = mz1; z=256 && _height*_depth>=128) +#pragma omp parallel for COLLAPSE(2) if (_width>=256 && _height*_depth>=128) #endif cimg_forYZ(res,y,z) for (int x = 0; x=mye || z=mze)?++x:((x=mxe)?++x:(x=mxe))) { Tt min_val = cimg::type::max(); @@ -24732,9 +24737,9 @@ namespace cimg_library_suffixed { res(x,y,z,c) = min_val; } else #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width>=256 && _height*_depth>=128) +#pragma omp parallel for COLLAPSE(2) if (_width>=256 && _height*_depth>=128) #endif cimg_forYZ(res,y,z) for (int x = 0; x=mye || z=mze)?++x:((x=mxe)?++x:(x=mxe))) { Tt min_val = cimg::type::max(); @@ -24749,9 +24754,9 @@ namespace cimg_library_suffixed { } } else { // Classical erosion. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (_width*_height*_depth>=32768) +#pragma omp parallel for COLLAPSE(3) if (_width*_height*_depth>=32768) #endif for (int z = mz1; z=256 && _height*_depth>=128) +#pragma omp parallel for COLLAPSE(2) if (_width>=256 && _height*_depth>=128) #endif cimg_forYZ(res,y,z) for (int x = 0; x=mye || z=mze)?++x:((x=mxe)?++x:(x=mxe))) { Tt min_val = cimg::type::max(); @@ -24780,9 +24785,9 @@ namespace cimg_library_suffixed { res(x,y,z,c) = min_val; } else #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width>=256 && _height*_depth>=128) +#pragma omp parallel for COLLAPSE(2) if (_width>=256 && _height*_depth>=128) #endif cimg_forYZ(res,y,z) for (int x = 0; x=mye || z=mze)?++x:((x=mxe)?++x:(x=mxe))) { Tt min_val = cimg::type::max(); @@ -24810,9 +24815,9 @@ namespace cimg_library_suffixed { if (sx>1 && _width>1) { // Along X-axis. const int L = width(), off = 1, s = (int)sx, _s1 = s/2, _s2 = s - _s1, s1 = _s1>L?L:_s1, s2 = _s2>L?L:_s2; CImg buf(L); #ifdef cimg_use_opemp -#pragma omp parallel for collapse(3) firstprivate(buf) if (size()>524288) +#pragma omp parallel for COLLAPSE(3) firstprivate(buf) if (size()>524288) #endif cimg_forYZC(*this,y,z,c) { T *const ptrdb = buf._data, *ptrd = buf._data, *const ptrde = buf._data + L - 1; const T *const ptrsb = data(0,y,z,c), *ptrs = ptrsb, *const ptrse = ptrs + L*off - off; @@ -24853,9 +24858,9 @@ namespace cimg_library_suffixed { const int L = height(), off = width(), s = (int)sy, _s1 = s/2, _s2 = s - _s1, s1 = _s1>L?L:_s1, s2 = _s2>L?L:_s2; CImg buf(L); #ifdef cimg_use_opemp -#pragma omp parallel for collapse(3) firstprivate(buf) if (size()>524288) +#pragma omp parallel for COLLAPSE(3) firstprivate(buf) if (size()>524288) #endif cimg_forXZC(*this,x,z,c) { T *const ptrdb = buf._data, *ptrd = ptrdb, *const ptrde = buf._data + L - 1; const T *const ptrsb = data(x,0,z,c), *ptrs = ptrsb, *const ptrse = ptrs + L*off - off; @@ -24897,9 +24902,9 @@ namespace cimg_library_suffixed { const int L = depth(), off = width()*height(), s = (int)sz, _s1 = s/2, _s2 = s - _s1, s1 = _s1>L?L:_s1, s2 = _s2>L?L:_s2; CImg buf(L); #ifdef cimg_use_opemp -#pragma omp parallel for collapse(3) firstprivate(buf) if (size()>524288) +#pragma omp parallel for COLLAPSE(3) firstprivate(buf) if (size()>524288) #endif cimg_forXYC(*this,x,y,c) { T *const ptrdb = buf._data, *ptrd = ptrdb, *const ptrde = buf._data + L - 1; const T *const ptrsb = data(x,y,0,c), *ptrs = ptrsb, *const ptrse = ptrs + L*off - off; @@ -24988,9 +24993,9 @@ namespace cimg_library_suffixed { const CImg _img = get_shared_channel(c%_spectrum); const CImg _mask = mask.get_shared_channel(c%mask._spectrum); if (is_normalized) { // Normalized dilation. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (_width*_height*_depth>=32768) +#pragma omp parallel for COLLAPSE(3) if (_width*_height*_depth>=32768) #endif for (int z = mz1; z=256 && _height*_depth>=128) +#pragma omp parallel for COLLAPSE(2) if (_width>=256 && _height*_depth>=128) #endif cimg_forYZ(res,y,z) for (int x = 0; x=mye || z=mze)?++x:((x=mxe)?++x:(x=mxe))) { Tt max_val = cimg::type::min(); @@ -25021,9 +25026,9 @@ namespace cimg_library_suffixed { res(x,y,z,c) = max_val; } else #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width>=256 && _height*_depth>=128) +#pragma omp parallel for COLLAPSE(2) if (_width>=256 && _height*_depth>=128) #endif cimg_forYZ(*this,y,z) for (int x = 0; x=mye || z=mze)?++x:((x=mxe)?++x:(x=mxe))) { Tt max_val = cimg::type::min(); @@ -25037,9 +25042,9 @@ namespace cimg_library_suffixed { res(x,y,z,c) = max_val; } } else { // Classical dilation. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (_width>=256 && _height*_depth>=128) +#pragma omp parallel for COLLAPSE(3) if (_width>=256 && _height*_depth>=128) #endif for (int z = mz1; z=256 && _height*_depth>=128) +#pragma omp parallel for COLLAPSE(2) if (_width>=256 && _height*_depth>=128) #endif cimg_forYZ(res,y,z) for (int x = 0; x=mye || z=mze)?++x:((x=mxe)?++x:(x=mxe))) { Tt max_val = cimg::type::min(); @@ -25068,9 +25073,9 @@ namespace cimg_library_suffixed { res(x,y,z,c) = max_val; } else #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width>=256 && _height*_depth>=128) +#pragma omp parallel for COLLAPSE(2) if (_width>=256 && _height*_depth>=128) #endif cimg_forYZ(res,y,z) for (int x = 0; x=mye || z=mze)?++x:((x=mxe)?++x:(x=mxe))) { Tt max_val = cimg::type::min(); @@ -25098,9 +25103,9 @@ namespace cimg_library_suffixed { if (sx>1 && _width>1) { // Along X-axis. const int L = width(), off = 1, s = (int)sx, _s2 = s/2 + 1, _s1 = s - _s2, s1 = _s1>L?L:_s1, s2 = _s2>L?L:_s2; CImg buf(L); #ifdef cimg_use_opemp -#pragma omp parallel for collapse(3) firstprivate(buf) if (size()>524288) +#pragma omp parallel for COLLAPSE(3) firstprivate(buf) if (size()>524288) #endif cimg_forYZC(*this,y,z,c) { T *const ptrdb = buf._data, *ptrd = ptrdb, *const ptrde = buf._data + L - 1; const T *const ptrsb = data(0,y,z,c), *ptrs = ptrsb, *const ptrse = ptrs + L*off - off; @@ -25142,9 +25147,9 @@ namespace cimg_library_suffixed { const int L = height(), off = width(), s = (int)sy, _s2 = s/2 + 1, _s1 = s - _s2, s1 = _s1>L?L:_s1, s2 = _s2>L?L:_s2; CImg buf(L); #ifdef cimg_use_opemp -#pragma omp parallel for collapse(3) firstprivate(buf) if (size()>524288) +#pragma omp parallel for COLLAPSE(3) firstprivate(buf) if (size()>524288) #endif cimg_forXZC(*this,x,z,c) { T *const ptrdb = buf._data, *ptrd = ptrdb, *const ptrde = buf._data + L - 1; const T *const ptrsb = data(x,0,z,c), *ptrs = ptrsb, *const ptrse = ptrs + L*off - off; @@ -25186,9 +25191,9 @@ namespace cimg_library_suffixed { const int L = depth(), off = width()*height(), s = (int)sz, _s2 = s/2 + 1, _s1 = s - _s2, s1 = _s1>L?L:_s1, s2 = _s2>L?L:_s2; CImg buf(L); #ifdef cimg_use_opemp -#pragma omp parallel for collapse(3) firstprivate(buf) if (size()>524288) +#pragma omp parallel for COLLAPSE(3) firstprivate(buf) if (size()>524288) #endif cimg_forXYC(*this,x,y,c) { T *const ptrdb = buf._data, *ptrd = ptrdb, *const ptrde = buf._data + L - 1; const T *const ptrsb = data(x,y,0,c), *ptrs = ptrsb, *const ptrse = ptrs + L*off - off; @@ -25507,33 +25512,33 @@ namespace cimg_library_suffixed { case 'x' : { const int N = _width; const unsigned long off = 1U; #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (_width>=256 && _height*_depth*_spectrum>=16) +#pragma omp parallel for COLLAPSE(3) if (_width>=256 && _height*_depth*_spectrum>=16) #endif cimg_forYZC(*this,y,z,c) { T *ptrX = data(0,y,z,c); _cimg_deriche_apply; } } break; case 'y' : { const int N = _height; const unsigned long off = (unsigned long)_width; #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (_width>=256 && _height*_depth*_spectrum>=16) +#pragma omp parallel for COLLAPSE(3) if (_width>=256 && _height*_depth*_spectrum>=16) #endif cimg_forXZC(*this,x,z,c) { T *ptrX = data(x,0,z,c); _cimg_deriche_apply; } } break; case 'z' : { const int N = _depth; const unsigned long off = (unsigned long)_width*_height; #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (_width>=256 && _height*_depth*_spectrum>=16) +#pragma omp parallel for COLLAPSE(3) if (_width>=256 && _height*_depth*_spectrum>=16) #endif cimg_forXYC(*this,x,y,c) { T *ptrX = data(x,y,0,c); _cimg_deriche_apply; } } break; default : { const int N = _spectrum; const unsigned long off = (unsigned long)_width*_height*_depth; #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (_width>=256 && _height*_depth*_spectrum>=16) +#pragma omp parallel for COLLAPSE(3) if (_width>=256 && _height*_depth*_spectrum>=16) #endif cimg_forXYZ(*this,x,y,z) { T *ptrX = data(x,y,z,0); _cimg_deriche_apply; } } } @@ -25663,31 +25668,31 @@ namespace cimg_library_suffixed { switch (naxis) { case 'x' : { #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (_width>=256 && _height*_depth*_spectrum>=16) +#pragma omp parallel for COLLAPSE(3) if (_width>=256 && _height*_depth*_spectrum>=16) #endif cimg_forYZC(*this,y,z,c) _cimg_recursive_apply<4>(data(0,y,z,c),filter,_width,1U,order,boundary_conditions); } break; case 'y' : { #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (_width>=256 && _height*_depth*_spectrum>=16) +#pragma omp parallel for COLLAPSE(3) if (_width>=256 && _height*_depth*_spectrum>=16) #endif cimg_forXZC(*this,x,z,c) _cimg_recursive_apply<4>(data(x,0,z,c),filter,_height,(unsigned long)_width,order,boundary_conditions); } break; case 'z' : { #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (_width>=256 && _height*_depth*_spectrum>=16) +#pragma omp parallel for COLLAPSE(3) if (_width>=256 && _height*_depth*_spectrum>=16) #endif cimg_forXYC(*this,x,y,c) _cimg_recursive_apply<4>(data(x,y,0,c),filter,_depth,(unsigned long)(_width*_height), order,boundary_conditions); } break; default : { #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (_width>=256 && _height*_depth*_spectrum>=16) +#pragma omp parallel for COLLAPSE(3) if (_width>=256 && _height*_depth*_spectrum>=16) #endif cimg_forXYZ(*this,x,y,z) _cimg_recursive_apply<4>(data(x,y,z,0),filter,_spectrum,(unsigned long)(_width*_height*_depth), order,boundary_conditions); @@ -25850,9 +25855,9 @@ namespace cimg_library_suffixed { *(pd3++) = (Tfloat)n; } #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width>=256 && _height*_depth>=2) firstprivate(val) +#pragma omp parallel for COLLAPSE(2) if (_width>=256 && _height*_depth>=2) firstprivate(val) #endif cimg_forXYZ(*this,x,y,z) { val.fill(0); const float @@ -26325,9 +26330,9 @@ namespace cimg_library_suffixed { default : { const int psize2 = (int)patch_size/2, psize1 = (int)patch_size - psize2 - 1; if (is_fast_approx) #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (res._width>=32 && res._height*res._depth>=4) private(P,Q) +#pragma omp parallel for COLLAPSE(2) if (res._width>=32 && res._height*res._depth>=4) private(P,Q) #endif cimg_forXYZ(res,x,y,z) { // Fast P = img.get_crop(x - psize1,y - psize1,z - psize1,x + psize2,y + psize2,z + psize2,true); const int x0 = x - rsize1, y0 = y - rsize1, z0 = z - rsize1, @@ -26345,9 +26350,9 @@ namespace cimg_library_suffixed { if (sum_weights>0) cimg_forC(res,c) res(x,y,z,c)/=sum_weights; else cimg_forC(res,c) res(x,y,z,c) = (Tfloat)((*this)(x,y,z,c)); } else #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (res._width>=32 && res._height*res._depth>=4) firstprivate(P,Q) +#pragma omp parallel for COLLAPSE(2) if (res._width>=32 && res._height*res._depth>=4) firstprivate(P,Q) #endif cimg_forXYZ(res,x,y,z) { // Exact P = img.get_crop(x - psize1,y - psize1,z - psize1,x + psize2,y + psize2,z + psize2,true); const int x0 = x - rsize1, y0 = y - rsize1, z0 = z - rsize1, @@ -26444,9 +26449,9 @@ namespace cimg_library_suffixed { const int hl = n/2, hr = hl - 1 + n%2; if (res._depth!=1) { // 3d if (threshold>0) #if cimg_use_openmp -#pragma omp parallel for collapse(3) if (_width>=16 && _height*_depth*_spectrum>=4) +#pragma omp parallel for COLLAPSE(3) if (_width>=16 && _height*_depth*_spectrum>=4) #endif cimg_forXYZC(*this,x,y,z,c) { // With threshold. const int x0 = x - hl, y0 = y - hl, z0 = z-hl, x1 = x + hr, y1 = y + hr, z1 = z+hr, @@ -26461,9 +26466,9 @@ namespace cimg_library_suffixed { res(x,y,z,c) = values.get_shared_points(0,nb_values-1).median(); } else #if cimg_use_openmp -#pragma omp parallel for collapse(3) if (_width>=16 && _height*_depth*_spectrum>=4) +#pragma omp parallel for COLLAPSE(3) if (_width>=16 && _height*_depth*_spectrum>=4) #endif cimg_forXYZC(*this,x,y,z,c) { // Without threshold. const int x0 = x - hl, y0 = y - hl, z0 = z-hl, x1 = x + hr, y1 = y + hr, z1 = z+hr, @@ -26475,9 +26480,9 @@ namespace cimg_library_suffixed { #define _cimg_median_sort(a,b) if ((a)>(b)) cimg::swap(a,b) if (res._height!=1) { // 2d if (threshold>0) #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width>=16 && _height*_spectrum>=4) +#pragma omp parallel for COLLAPSE(2) if (_width>=16 && _height*_spectrum>=4) #endif cimg_forXYC(*this,x,y,c) { // With threshold. const int x0 = x - hl, y0 = y - hl, x1 = x + hr, y1 = y + hr, @@ -26559,9 +26564,9 @@ namespace cimg_library_suffixed { } } break; default : { #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width>=16 && _height*_spectrum>=4) +#pragma omp parallel for COLLAPSE(2) if (_width>=16 && _height*_spectrum>=4) #endif cimg_forXYC(*this,x,y,c) { const int x0 = x - hl, y0 = y - hl, x1 = x + hr, y1 = y + hr, @@ -26645,9 +26650,9 @@ namespace cimg_library_suffixed { if (sharpen_type) { // Shock filters. CImg G = (alpha>0?get_blur(alpha).get_structure_tensors():get_structure_tensors()); if (sigma>0) G.blur(sigma); #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width>=32 && _height*_depth>=16) +#pragma omp parallel for COLLAPSE(2) if (_width>=32 && _height*_depth>=16) #endif cimg_forYZ(G,y,z) { Tfloat *ptrG0 = G.data(0,y,z,0), *ptrG1 = G.data(0,y,z,1), *ptrG2 = G.data(0,y,z,2), *ptrG3 = G.data(0,y,z,3); @@ -26864,9 +26869,9 @@ namespace cimg_library_suffixed { } } else switch (scheme) { // 2d. case -1 : { // Backward finite differences. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width*_height>=1048576 && _depth*_spectrum>=2) +#pragma omp parallel for COLLAPSE(2) if (_width*_height>=1048576 && _depth*_spectrum>=2) #endif cimg_forZC(*this,z,c) { const unsigned long off = c*_width*_height*_depth + z*_width*_height; Tfloat *ptrd0 = grad[0]._data + off, *ptrd1 = grad[1]._data + off; @@ -26878,9 +26883,9 @@ namespace cimg_library_suffixed { } } break; case 1 : { // Forward finite differences. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width*_height>=1048576 && _depth*_spectrum>=2) +#pragma omp parallel for COLLAPSE(2) if (_width*_height>=1048576 && _depth*_spectrum>=2) #endif cimg_forZC(*this,z,c) { const unsigned long off = c*_width*_height*_depth + z*_width*_height; Tfloat *ptrd0 = grad[0]._data + off, *ptrd1 = grad[1]._data + off; @@ -26892,9 +26897,9 @@ namespace cimg_library_suffixed { } } break; case 2 : { // Sobel scheme. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width*_height>=1048576 && _depth*_spectrum>=2) +#pragma omp parallel for COLLAPSE(2) if (_width*_height>=1048576 && _depth*_spectrum>=2) #endif cimg_forZC(*this,z,c) { const unsigned long off = c*_width*_height*_depth + z*_width*_height; Tfloat *ptrd0 = grad[0]._data + off, *ptrd1 = grad[1]._data + off; @@ -26906,9 +26911,9 @@ namespace cimg_library_suffixed { } } break; case 3 : { // Rotation invariant mask. #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width*_height>=1048576 && _depth*_spectrum>=2) +#pragma omp parallel for COLLAPSE(2) if (_width*_height>=1048576 && _depth*_spectrum>=2) #endif cimg_forZC(*this,z,c) { const unsigned long off = c*_width*_height*_depth + z*_width*_height; Tfloat *ptrd0 = grad[0]._data + off, *ptrd1 = grad[1]._data + off; @@ -26929,9 +26934,9 @@ namespace cimg_library_suffixed { grad[1] = get_vanvliet(0,1,'y'); } break; default : { // Central finite differences #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width*_height>=1048576 && _depth*_spectrum>=2) +#pragma omp parallel for COLLAPSE(2) if (_width*_height>=1048576 && _depth*_spectrum>=2) #endif cimg_forZC(*this,z,c) { const unsigned long off = c*_width*_height*_depth + z*_width*_height; Tfloat *ptrd0 = grad[0]._data + off, *ptrd1 = grad[1]._data + off; @@ -26994,9 +26999,9 @@ namespace cimg_library_suffixed { } } } else if (!cimg::strcasecmp(naxes,def_axes2d)) { // 2d #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width*_height>=1048576 && _depth*_spectrum>=2) +#pragma omp parallel for COLLAPSE(2) if (_width*_height>=1048576 && _depth*_spectrum>=2) #endif cimg_forZC(*this,z,c) { const unsigned long off = c*_width*_height*_depth + z*_width*_height; Tfloat *ptrd0 = res[0]._data + off, *ptrd1 = res[1]._data + off, *ptrd2 = res[2]._data + off; @@ -27014,9 +27019,9 @@ namespace cimg_library_suffixed { bool valid_axis = false; if (axis1=='x' && axis2=='x') { // Ixx valid_axis = true; #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width*_height>=1048576 && _depth*_spectrum>=2) +#pragma omp parallel for COLLAPSE(2) if (_width*_height>=1048576 && _depth*_spectrum>=2) #endif cimg_forZC(*this,z,c) { Tfloat *ptrd = res[l2].data(0,0,z,c); CImg_3x3(I,Tfloat); @@ -27025,9 +27030,9 @@ namespace cimg_library_suffixed { } else if (axis1=='x' && axis2=='y') { // Ixy valid_axis = true; #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width*_height>=1048576 && _depth*_spectrum>=2) +#pragma omp parallel for COLLAPSE(2) if (_width*_height>=1048576 && _depth*_spectrum>=2) #endif cimg_forZC(*this,z,c) { Tfloat *ptrd = res[l2].data(0,0,z,c); CImg_3x3(I,Tfloat); @@ -27047,9 +27052,9 @@ namespace cimg_library_suffixed { } else if (axis1=='y' && axis2=='y') { // Iyy valid_axis = true; #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width*_height>=1048576 && _depth*_spectrum>=2) +#pragma omp parallel for COLLAPSE(2) if (_width*_height>=1048576 && _depth*_spectrum>=2) #endif cimg_forZC(*this,z,c) { Tfloat *ptrd = res[l2].data(0,0,z,c); CImg_3x3(I,Tfloat); @@ -27290,9 +27295,9 @@ namespace cimg_library_suffixed { if (_depth>1) { // 3d get_structure_tensors().move_to(res).blur(sigma); #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if(_width>=256 && _height*_depth>=256) +#pragma omp parallel for COLLAPSE(2) if(_width>=256 && _height*_depth>=256) #endif cimg_forYZ(*this,y,z) { Tfloat *ptrd0 = res.data(0,y,z,0), *ptrd1 = res.data(0,y,z,1), *ptrd2 = res.data(0,y,z,2), @@ -27610,9 +27615,9 @@ namespace cimg_library_suffixed { cimg_forC(*this,c) { CImg g(_width), dt(_width), s(_width), t(_width); CImg img = get_shared_channel(c); #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_width>=512 && _height*_depth>=16) firstprivate(g,dt,s,t) +#pragma omp parallel for COLLAPSE(2) if (_width>=512 && _height*_depth>=16) firstprivate(g,dt,s,t) #endif cimg_forYZ(*this,y,z) { // Over X-direction. cimg_forX(*this,x) g[x] = (long)img(x,y,z,0,wh); _distance_scan(_width,g,sep,f,s,t,dt); @@ -27620,9 +27625,9 @@ namespace cimg_library_suffixed { } if (_height>1) { g.assign(_height); dt.assign(_height); s.assign(_height); t.assign(_height); #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_height>=512 && _width*_depth>=16) firstprivate(g,dt,s,t) +#pragma omp parallel for COLLAPSE(2) if (_height>=512 && _width*_depth>=16) firstprivate(g,dt,s,t) #endif cimg_forXZ(*this,x,z) { // Over Y-direction. cimg_forY(*this,y) g[y] = (long)img(x,y,z,0,wh); _distance_scan(_height,g,sep,f,s,t,dt); @@ -27631,9 +27636,9 @@ namespace cimg_library_suffixed { } if (_depth>1) { g.assign(_depth); dt.assign(_depth); s.assign(_depth); t.assign(_depth); #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if (_depth>=512 && _width*_height>=16) firstprivate(g,dt,s,t) +#pragma omp parallel for COLLAPSE(2) if (_depth>=512 && _width*_height>=16) firstprivate(g,dt,s,t) #endif cimg_forXY(*this,x,y) { // Over Z-direction. cimg_forZ(*this,z) g[z] = (long)img(x,y,z,0,wh); _distance_scan(_depth,g,sep,f,s,t,dt); @@ -27662,9 +27667,9 @@ namespace cimg_library_suffixed { #endif cimg_forC(*this,c) { CImg img = get_shared_channel(c); #ifdef cimg_use_openmp -#pragma omp parallel for collapse(3) if (_width*_height*_depth>=1024) +#pragma omp parallel for COLLAPSE(3) if (_width*_height*_depth>=1024) #endif cimg_forXYZ(metric_mask,dx,dy,dz) { const t weight = metric_mask(dx,dy,dz); if (weight) { @@ -35380,9 +35385,9 @@ namespace cimg_library_suffixed { _y0 = y0<0?0:y0>=height()?height()-1:y0, _x1 = x1<0?1:x1>=width()?width()-1:x1, _y1 = y1<0?1:y1>=height()?height()-1:y1; #ifdef cimg_use_openmp -#pragma omp parallel for collapse(2) if ((1+_x1-_x0)*(1+_y1-_y0)>=2048) +#pragma omp parallel for COLLAPSE(2) if ((1+_x1-_x0)*(1+_y1-_y0)>=2048) #endif for (int q = _y0; q<=_y1; ++q) for (int p = _x0; p<=_x1; ++p) { unsigned int iteration = 0; Index: gmic-1.6.0.0/src/gmic.cpp =================================================================== --- gmic-1.6.0.0.orig/src/gmic.cpp +++ gmic-1.6.0.0/src/gmic.cpp @@ -41,8 +41,17 @@ # knowledge of the CeCILL license and that you accept its terms. # */ +#ifdef cimg_use_openmp +#include +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) +#define _COLLAPSE(x) collapse(x) +#else +#define _COLLAPSE(x) +#endif +#endif + // Add G'MIC-specific methods to the CImg library. //------------------------------------------------ #ifdef cimg_plugin @@ -78,9 +87,9 @@ CImg get_gmic_invert_endianness(const } template CImg& operator_eq(const t val) { -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=131072) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)(*ptrd == (T)val); return *this; @@ -101,9 +110,9 @@ CImg& operator_eq(const char *const e if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for _COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)(*ptrd == (T)lmp(x,y,z,c)); ++ptrd; } } @@ -138,9 +147,9 @@ CImg& operator_eq(const CImg& img) } template CImg& operator_neq(const t val) { -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=131072) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)(*ptrd != (T)val); return *this; @@ -161,9 +170,9 @@ CImg& operator_neq(const char *const if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for _COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)(*ptrd != (T)lmp(x,y,z,c)); ++ptrd; } } @@ -198,9 +207,9 @@ CImg& operator_neq(const CImg& img } template CImg& operator_gt(const t val) { -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=131072) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)(*ptrd > (T)val); return *this; @@ -221,9 +230,9 @@ CImg& operator_gt(const char *const e if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for _COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)(*ptrd > (T)lmp(x,y,z,c)); ++ptrd; } } @@ -258,9 +267,9 @@ CImg& operator_gt(const CImg& img) } template CImg& operator_ge(const t val) { -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=131072) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)(*ptrd >= (T)val); return *this; @@ -281,9 +290,9 @@ CImg& operator_ge(const char *const e if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for _COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)(*ptrd >= (T)lmp(x,y,z,c)); ++ptrd; } } @@ -318,9 +327,9 @@ CImg& operator_ge(const CImg& img) } template CImg& operator_lt(const t val) { -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=131072) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)(*ptrd < (T)val); return *this; @@ -341,9 +350,9 @@ CImg& operator_lt(const char *const e if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for _COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)(*ptrd < (T)lmp(x,y,z,c)); ++ptrd; } } @@ -378,9 +387,9 @@ CImg& operator_lt(const CImg& img) } template CImg& operator_le(const t val) { -#ifdef cimg_use_openmp +#if defined(cimg_use_openmp) && !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) #pragma omp parallel for if (size()>=131072) #endif cimg_rof(*this,ptrd,T) *ptrd = (T)(*ptrd <= (T)val); return *this; @@ -401,9 +410,9 @@ CImg& operator_le(const char *const e if (_width>=512 && _height*_depth*_spectrum>=2 && std::strlen(expression)>=6) #pragma omp parallel { _cimg_math_parser _mp = omp_get_thread_num()?mp:_cimg_math_parser(), &lmp = omp_get_thread_num()?_mp:mp; -#pragma omp for collapse(3) +#pragma omp for _COLLAPSE(3) cimg_forYZC(*this,y,z,c) { T *ptrd = data(0,y,z,c); cimg_forX(*this,x) { *ptrd = (T)(*ptrd <= (T)lmp(x,y,z,c)); ++ptrd; } }