    static T __cimg_blur_box_apply(T *ptr, const int N, const ulongT off,
                                   const unsigned int boundary_conditions, const int x) {
      switch (boundary_conditions) {
      case 0 : // Dirichlet
        return x<0 || x>=N?(T)0:ptr[x*off];
      case 1 : { // Neumann
        const int nx = x<0?0:x>=N?N - 1:x;
        return ptr[nx*off];
      }
      case 2 : { // Periodic
        const int nx = cimg::mod(x,N);
        return ptr[nx*off];
      }
      default : { // Mirror
        const int
          N2 = 2*N,
          tx = cimg::mod(x,N2),
          nx = tx<N?tx:N2 - tx - 1;
        return ptr[nx*off];
      }
      }
      return (T)0;
    }
    static T __cimg_blur_box_apply(T *ptr, const int N, const ulongT off,
                                   const unsigned int boundary_conditions, const int x) {
      switch (boundary_conditions) {
      case 0 :  
        return x<0 || x>=N?(T)0:ptr[x*off];
      case 1 : {  
        const int nx = x<0?0:x>=N?N - 1:x;
        return ptr[nx*off];
      }
      case 2 : {  
        const int nx = cimg::mod(x,N);
        return ptr[nx*off];
      }
      default : {  
        const int
          N2 = 2*N,
          tx = cimg::mod(x,N2),
          nx = tx<N?tx:N2 - tx - 1;
        return ptr[nx*off];
      }
      }
      return (T)0;
    }