Image.cast#
- Image.cast(value: int | float | ndarray) Any[source][source]#
Cast value to same type as image
- Parameters:
value (scalar, ndarray) – value to cast
- Returns:
value cast to same type as image
- Return type:
numpy type, ndarray
The value, scalar or integer, is cast to the same type as the image. The result has the same numeric value, but the type is changed.
Example:
>>> from machinevisiontoolbox import Image >>> img = Image.Read('flowers1.png') >>> x = img.cast(12.5) >>> x np.uint8(12) >>> type(x) <class 'numpy.uint8'>
Note
Scalars are cast to NumPy types not native Python types.
- Seealso: