turicreate.SArray.pixel_array_to_image¶
-
SArray.
pixel_array_to_image
(width, height, channels, undefined_on_failure=True, allow_rounding=False)¶ Create a new SArray with all the values cast to
turicreate.image.Image
of uniform size.Parameters: - width: int
The width of the new images.
- height: int
The height of the new images.
- channels: int.
Number of channels of the new images.
- undefined_on_failure: bool , optional , default True
If True, return None type instead of Image type in failure instances. If False, raises error upon failure.
- allow_rounding: bool, optional , default False
If True, rounds non-integer values when converting to Image type. If False, raises error upon rounding.
Returns: - out : SArray[turicreate.Image]
The SArray converted to the type ‘turicreate.Image’.
See also
Examples
The MNIST data is scaled from 0 to 1, but our image type only loads integer pixel values from 0 to 255. If we just convert without scaling, all values below one would be cast to 0.
>>> mnist_array = turicreate.SArray('https://static.turi.com/datasets/mnist/mnist_vec_sarray') >>> scaled_mnist_array = mnist_array * 255 >>> mnist_img_sarray = tc.SArray.pixel_array_to_image(scaled_mnist_array, 28, 28, 1, allow_rounding = True)