    CImg<T> get_closing(const unsigned int sx, const unsigned int sy, const unsigned int sz=1) const {
      if (is_empty() || (sx<=1 && sy<=1 && sz<=1)) return *this;
      const int sx1 = (int)(sx - 1)/2, sy1 = (int)(sy - 1)/2, sz1 = (int)(sz - 1)/2;
      CImg<T> res;
      if (_depth>1) { // 3D
        get_resize(width() + sx + 1,height() + sy + 1,depth() + sz + 1,spectrum(),0,1,0.5,0.5,0.5).
          dilate(sx,sy,sz).erode(sx,sy,sz).
          crop(sx1 + 1,sy1 + 1,sz1 + 1,sx1 + width(),sy1 + height(),sz1 + depth()).move_to(res);
      } else if (_height>1) { // 2D
        get_resize(width() + sx + 1,height() + sy + 1,1,spectrum(),0,1,0.5,0.5).
          dilate(sx,sy).erode(sx,sy).
          crop(sx1 + 1,sy1 + 1,sx1 + width(),sy1 + height()).move_to(res);
      } else if (_width>1) { // 1D
        get_resize(width() + sx + 1,1,1,spectrum(),0,1,0.5).
          dilate(sx,1).erode(sx,1).
          crop(sx1 + 1,sx1 + width()).move_to(res);
      }
      return res;
    }
    CImg<T> get_closing(const unsigned int sx, const unsigned int sy, const unsigned int sz=1) const {
      if (is_empty() || (sx<=1 && sy<=1 && sz<=1)) return *this;
      const int sx1 = (int)(sx - 1)/2, sy1 = (int)(sy - 1)/2, sz1 = (int)(sz - 1)/2;
      CImg<T> res;
      if (_depth>1) {  
        get_resize(width() + sx + 1,height() + sy + 1,depth() + sz + 1,spectrum(),0,1,0.5,0.5,0.5).
          dilate(sx,sy,sz).erode(sx,sy,sz).
          crop(sx1 + 1,sy1 + 1,sz1 + 1,sx1 + width(),sy1 + height(),sz1 + depth()).move_to(res);
      } else if (_height>1) {  
        get_resize(width() + sx + 1,height() + sy + 1,1,spectrum(),0,1,0.5,0.5).
          dilate(sx,sy).erode(sx,sy).
          crop(sx1 + 1,sy1 + 1,sx1 + width(),sy1 + height()).move_to(res);
      } else if (_width>1) {  
        get_resize(width() + sx + 1,1,1,spectrum(),0,1,0.5).
          dilate(sx,1).erode(sx,1).
          crop(sx1 + 1,sx1 + width()).move_to(res);
      }
      return res;
    }