norm_dtype

imagepypelines.norm_dtype(img, dtype=<class 'numpy.uint8'>)[source]

Normalize img to the range [dtype_min, dtype_max].

Can be used to prepare images for file output. Equivalent to a 0% histogram stretch. Works by converting to float64, then stretching/shifting, then quantizing.

Parameters:
  • img (np.ndarray) – image to normalize, can be any dtype.
  • dtype (np dtype) – integer datatype to normalize to.
Returns:

normalized image, dtype=dtype

Return type:

np.ndarray