Image Type Conversion

hugheslab.im_tools.to8bit(img, minVal=None, maxVal=None)

Returns an 8 bit representation of image. If min and max are specified, these pixel values in the original image are mapped to 0 and 255 respectively, otherwise the smallest and largest values in the whole image are mapped to 0 and 255, respectively.

Arguments:
imgndarray

input image as 2D numpy array

Keyword Arguments:
minValfloat

optional, pixel value to scale to 0

maxValfloat

optional, pixel value to scale to 255

hugheslab.im_tools.to16bit(img, minVal=None, maxVal=None)

Returns an 16 bit representation of image. If min and max are specified, these pixel values in the original image are mapped to 0 and 2^16 respectively, otherwise the smallest and largest values in the whole image are mapped to 0 and 2^16 - 1, respectively.

Arguments:
imgndarray

input image as 2D numpy array

Keyword Arguments:
minValfloat

optional, pixel value to scale to 0

maxValfloat

optional, pixel value to scale to 2^16 - 1

Returns:

ndarray, 16 bit image