(img_data, downsample=1)
return final_image
Convert RGB image to two-dimensional array of RGBA values (encoded as 32-bit integers)
    (required by Bokeh). The functionality is currently not available in Bokeh.
    An issue was raised here: https://github.com/bokeh/bokeh/issues/1699 and this function is a
    modified version of the suggested solution.

    Arguments:
        img_data: img (ndarray, shape: [N, M, 3], dtype: uint8): image data
        dh: height of image
        dw: width of image

    Returns:
        img (ndarray): 2D image array of RGBA values
Convert RGB image to two-dimensional array of RGBA values (encoded as 32-bit integers)
    (required by Bokeh). The functionality is currently not available in Bokeh.
    An issue was raised here: https://github.com/bokeh/bokeh/issues/1699 and this function is a
    modified version of the suggested solution.
Convert RGB image to two - dimensional array of RGBA values ( encoded as 32 - bit integers ) ( required by Bokeh ) . The functionality is currently not available in Bokeh . An issue was raised here : https : // github . com / bokeh / bokeh / issues / 1699 and this function is a modified version of the suggested solution .
def convert_rgb_to_bokehrgba(img_data, downsample=1):
    """
    Convert RGB image to two-dimensional array of RGBA values (encoded as 32-bit integers)
    (required by Bokeh). The functionality is currently not available in Bokeh.
    An issue was raised here: https://github.com/bokeh/bokeh/issues/1699 and this function is a
    modified version of the suggested solution.

    Arguments:
        img_data: img (ndarray, shape: [N, M, 3], dtype: uint8): image data
        dh: height of image
        dw: width of image

    Returns:
        img (ndarray): 2D image array of RGBA values
    """
    if img_data.dtype != np.uint8:
        raise NotImplementedError

    if img_data.ndim != 3:
        raise NotImplementedError

    # downsample for render performance, v-flip since plot origin is bottom left
    # img_data = np.transpose(img_data, (1,2,0))
    img_data = img_data[::-downsample, ::downsample, :]
    img_h, img_w, C = img_data.shape

    # add an alpha channel to the image and recast from pixels of u8u8u8u8 to u32
    bokeh_img = np.dstack([img_data, 255 * np.ones((img_h, img_w), np.uint8)])
    final_image = bokeh_img.reshape(img_h, img_w * (C + 1)).view(np.uint32)

    return final_image
def convert_rgb_to_bokehrgba ( img_data , downsample = 1 ) : if img_data . dtype != np . uint8 : raise NotImplementedError if img_data . ndim != 3 : raise NotImplementedError # downsample for render performance, v-flip since plot origin is bottom left # img_data = np.transpose(img_data, (1,2,0)) img_data = img_data [ : : - downsample , : : downsample , : ] img_h , img_w , C = img_data . shape # add an alpha channel to the image and recast from pixels of u8u8u8u8 to u32 bokeh_img = np . dstack ( [ img_data , 255 * np . ones ( ( img_h , img_w ) , np . uint8 ) ] ) final_image = bokeh_img . reshape ( img_h , img_w * ( C + 1 ) ) . view ( np . uint32 ) return final_image