ImageFile.convert¶
- ImageFile.convert(dtype, force_copy=False, uniform=False, normalise=True)¶
Convert an image to the requested data-type.
Warnings are issued in case of precision loss, or when negative values are clipped during conversion to unsigned integer types (sign loss).
Floating point values are expected to be normalized and will be clipped to the range [0.0, 1.0] or [-1.0, 1.0] when converting to unsigned or signed integers respectively.
Numbers are not shifted to the negative side when converting from unsigned to signed integer types. Negative values will be clipped when converting to unsigned integers.
- imagendarray
Input image.
- dtypedtype
Target data-type.
- force_copybool
Force a copy of the data, irrespective of its current dtype.
- uniformbool
Uniformly quantize the floating point range to the integer range. By default (uniform=False) floating point values are scaled and rounded to the nearest integers, which minimizes back and forth conversion errors.
- normalisebool
When converting from int types to float normalise the resulting array by the maximum allowed value of the int type.
DirectX data conversion rules. http://msdn.microsoft.com/en-us/library/windows/desktop/dd607323%28v=vs.85%29.aspx
Data Conversions. In “OpenGL ES 2.0 Specification v2.0.25”, pp 7-8. Khronos Group, 2010.
Proper treatment of pixels as integers. A.W. Paeth. In “Graphics Gems I”, pp 249-256. Morgan Kaufmann, 1990.
Dirty Pixels. J. Blinn. In “Jim Blinn’s corner: Dirty Pixels”, pp 47-57. Morgan Kaufmann, 1998.