Create a new SArray with all the values cast to :py:class:`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
        --------
        astype, str_to_datetime, datetime_to_str

        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)

def pixel_array_to_image(self, width, height, channels, undefined_on_failure=True, allow_rounding=False):
        """
        Create a new SArray with all the values cast to :py:class:`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
        --------
        astype, str_to_datetime, datetime_to_str

        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)

        """
        if(self.dtype != array.array):
            raise TypeError("array_to_img expects SArray of arrays as input SArray")

        num_to_test = 10

        num_test = min(len(self), num_to_test)

        mod_values = [val % 1 for x in range(num_test) for val in self[x]]

        out_of_range_values = [(val > 255 or val < 0) for x in range(num_test) for val in self[x]]

        if sum(mod_values) != 0.0 and not allow_rounding:
            raise ValueError("There are non-integer values in the array data. Images only support integer data values between 0 and 255. To permit rounding, set the 'allow_rounding' parameter to 1.")

        if sum(out_of_range_values) != 0:
            raise ValueError("There are values outside the range of 0 to 255. Images only support integer data values between 0 and 255.")


        from .. import extensions
        return extensions.vector_sarray_to_image_sarray(self, width, height, channels, undefined_on_failure)