httomolib.misc.rescale

Contents

httomolib.misc.rescale#

Module for data rescaling.

httomolib.misc.rescale.rescale_to_int(data: <np.ndarray>, perc_range_min: float = 0.0, perc_range_max: float = 100.0, bits: ~typing.Literal[8, 16, 32] = 8, glob_stats: ~typing.Tuple[float, float, float, int] | None = None) <np.ndarray>[source]#

Rescales the data given as float32 type and converts it into the range of an unsigned integer type with the given number of bits. See more information in https://diamondlightsource.github.io/httomolibgpu/reference/methods_list/rescale/rescale_to_int.html

Parameters:
  • data (np.ndarray) – Input data as a 3D numpy array

  • perc_range_min (float, optional) – The lower cutoff point in the input data, in percent of the data range (defaults to 0). The lower bound is computed as min + perc_range_min/100*(max-min)

  • perc_range_max (float, optional) – The upper cutoff point in the input data, in percent of the data range (defaults to 100). The upper bound is computed as min + perc_range_max/100*(max-min)

  • bits (Literal[8, 16, 32], optional) – The number of bits in the output integer range (defaults to 8). Allowed values are: - 8 -> uint8 - 16 -> uint16 - 32 -> uint32

  • glob_stats (tuple, optional) – Global statistics of the full dataset (beyond the data passed into this call). It’s a tuple with (min, max, sum, num_items). If not given, the min/max is computed from the given data.

Returns:

The original data, clipped to the range specified with the perc_range_min and perc_range_max, and scaled to the full range of the output integer type

Return type:

np.ndarray