docs: def gray2qimage(gray, normalize = False):
      """Convert the 2D numpy array `gray` into a 8-bit, indexed QImage_
      with a gray colormap.  The first dimension represents the vertical
      image axis.
  
      The parameter `normalize` can be used to normalize an image's
      value range to 0..255:
  
      `normalize` = (nmin, nmax):
        scale & clip image values from nmin..nmax to 0..255
  
      `normalize` = nmax:
        lets nmin default to zero, i.e. scale & clip the range 0..nmax
        to 0..255
  
      `normalize` = True:
        scale image values to 0..255 (same as passing (gray.min(),
        gray.max()))
  
      If the source array `gray` contains masked values, the result will
      have only 255 shades of gray, and one color map entry will be used
      to make the corresponding pixels transparent.
  
      A full alpha channel cannot be supported with indexed images;
      instead, use `array2qimage` to convert into a 32-bit QImage.
  
      :param gray: image data which should be converted (copied) into a QImage_
      :type gray: 2D or 3D numpy.ndarray_ or `numpy.ma.array <masked arrays>`_
      :param normalize: normalization parameter (see above, default: no value changing)
      :type normalize: bool, scalar, or pair
      :rtype: QImage_ with RGB32 or ARGB32 format"""
      if _np.ndim(gray) != 2:
          raise ValueError("gray2QImage can only convert 2D arrays" +
                           " (try using array2qimage)" if _np.ndim(gray) == 3 else "")
  
      h, w = gray.shape
      result = _qt.QImage(w, h, _qt.QImage.Format_Indexed8)
  
      if not _np.ma.is_masked(gray):
          for i in range(256):
              result.setColor(i, _qt.qRgb(i,i,i))
  
          _qimageview(result)[:] = _normalize255(gray, normalize)
      else:
          # map gray value 1 to gray value 0, in order to make room for
          # transparent colormap entry:
          result.setColor(0, _qt.qRgb(0,0,0))
          for i in range(2, 256):
              result.setColor(i-1, _qt.qRgb(i,i,i))
  
          _qimageview(result)[:] = _normalize255(gray, normalize, clip = (1, 255)) - 1
  
          result.setColor(255, 0)
          _qimageview(result)[gray.mask] = 255
  
      return result