class_docstr: **Bases:** :class:`GraphicsObject <pyqtgraph.GraphicsObject>`
class_docstr_tok: ["*","*","Bases",":","*","*",":","class",":","`","GraphicsObject","<","pyqtgraph.GraphicsObject",">","`"]
code: def _try_rescale_float(self, image, levels, lut):
      xp = self._xp
      augmented_alpha = False
  
      can_handle = False
      while True:
          if levels is None or levels.ndim != 1:
              # float images always need levels
              # can't handle multi-channel levels
              break
  
          # awkward, but fastest numpy native nan evaluation
          if self._imageHasNans is None:
              self._imageHasNans = xp.isnan(image.min())
  
          if self._imageHasNans:
              # don't handle images with nans
              # this should be an uncommon case
              break
  
          can_handle = True
          break
  
      if not can_handle:
          return image, levels, lut, augmented_alpha
  
      # Decide on maximum scaled value
      if lut is not None:
          scale = lut.shape[0]
          num_colors = lut.shape[0]
      else:
          scale = 255.0
          num_colors = 256
      dtype = xp.min_scalar_type(num_colors - 1)
  
      minVal, maxVal = levels
      if minVal == maxVal:
          maxVal = xp.nextafter(maxVal, 2 * maxVal)
      rng = maxVal - minVal
      rng = 1 if rng == 0 else rng
  
      fn_numba = fn.getNumbaFunctions()
      if (
          xp == numpy
          and image.flags.c_contiguous
          and dtype == xp.uint16
          and fn_numba is not None
      ):
          lut, augmented_alpha = self._convert_2dlut_to_1dlut(lut)
          image = fn_numba.rescale_and_lookup1d(
              image, scale / rng, minVal, lut
          )
          if image.dtype == xp.uint32:
              image = image[..., xp.newaxis].view(xp.uint8)
          return image, None, None, augmented_alpha
      else:
          image = fn.rescaleData(
              image,
              scale / rng,
              offset=minVal,
              dtype=dtype,
              clip=(0, num_colors - 1),
          )
  
          levels = None
  
          if image.dtype == xp.uint16 and image.ndim == 2:
              image, augmented_alpha = self._apply_lut_for_uint16_mono(
                  image, lut
              )
              lut = None
  
          # image is now of type uint8
          return image, levels, lut, augmented_alpha
  
imports: import warnings
  from collections.abc import Callable
  import numpy
  from ..None import colormap
  from ..None import debug
  from ..None import functions
  from ..None import getConfigOption
  from ..Point import Point
  from ..Qt import QtCore, QtGui, QtWidgets
  from ..util.cupy_helper import getCupy
  from .GraphicsObject import GraphicsObject
label_desc: Use image node_id 28 for calling the ImageItem obj's underlying member method code with example usage: obj._try_rescale_float(image, levels, lut) and returns: image,  levels,  lut,  augmented_alpha, image,  None,  None,  augmented_alpha, image,  levels,  lut,  augmented_alpha