Rescale to integers#
Description
This method is used to rescale the data before it gets saved into the images. The method allows you to rescale the data into 8, 16, or 32 bit of unsigned integer as well as to use the percentage scaling (explained bellow) to enhance contrast and remove outliers in the resulting images.
Where and how to use it:
The main purpose of this module is to help saving the data into images with rescaling. If the bit depth is reduced in the data, it can help to reduce the size of the saved images and in some situations simplify and accelerate of data analysis.
Warning
It is worth to note, however, that it is a lossy conversion when the bit depth of data is reduced. This can significantly alter the visual perception of the data as well as the quantitative side.
The rescaling module allows you to change the bit depth of a grayscale image, e.g., from 16-bit to 8-bit and also rescale the data in advance to avoid clipping of the data and therefore the loss of the information.
Note
The method does not save the data into images automatically, but only rescale the data. The user needs to take care of saving the data using an image saving method, e.g., the image saver of the HTTomolib library.
What are the adjustable parameters:
bits
defines the number of bits in the resulting data. The input can be any data type and will be rescaled into unsigned integer of 8, 16 or 32 bit type.perc_range_min
defines the lower cutoff point in the input data, in percent of the data range (defaults to 0). The lower bound is computed as \(\frac{\textrm{perc_range_min} * (\max-\min)}{100} + \min\). Note that \(\max\) and \(\min\) values will be automatically estimated from the input data, unless they are provided with the glob_stats optional parameter.perc_range_max
defines the upper cutoff point in the input data, in percent of the data range (defaults to 100). The higher bound is computed as \(\frac{\textrm{perc_range_max} * (\max-\min)}{100} + \min\).
Practical example:
In this example we demonstrate how to use the rescaling when saving the data from float 32-bit precision into rescaled 8-bit.