用bokeh显示jpgs最有效的方法? Image_rgba令人惊讶地慢

时间:2015-11-26 23:18:02

标签: bokeh

我尝试使用散景image_rgba方法,但发现它非常慢,我只是显示一个1000 * 500像素的图像,并且html需要大约5秒才能加载(这里没有基于网络的东西,我拥有一切在本地运行/存储)

同样,代码本身运行得很快,只是显示图像的速度很慢。我一直在尝试散景画廊的例子,速度很好。

我想知道我能为html加载更快做些什么吗? image_rgba是使用散景显示图像的最佳方式吗?

这是我使用的代码:

    pic = PIL.Image.open('/Users/blabla/eiffelTower.jpg')

    self.imgArray = np.array(pic)

    N1 = imgArray.shape[0]
    N2 = imgArray.shape[1]

    img = np.zeros((N1,prolongatedN2), dtype=np.uint32)
    view = img.view(dtype=np.uint8).reshape((N1, N2, 4))

    view[:N1,:N2,0] = self.imgArray[range(N1-1,-1,-1),:N2,0]
    view[:N1,:N2,1] = self.imgArray[range(N1-1,-1,-1),:N2,1]
    view[:N1,:N2,2] = self.imgArray[range(N1-1,-1,-1),:N2,2]

    fig = bokeh.plotting.figure(plot_width = plot_width, plot_height=plot_height)

    fig.image_rgba(image=[img], x=[0], y=[0],
                        dw=[plot_width], dh=[plot_height])
    script, div = bokeh.embed.components(p.fig, INLINE)

    output_file('testBokeh.html')

    show(fig)

再次,我很惊讶显示本地存储的1000 * 500像素会非常慢。

1 个答案:

答案 0 :(得分:2)

FWIW,我这样做,而且速度非常快。

<xsl:for-each>
相关问题