Reputation: 556
I have a dataset of RGB images as a numpy array
of shape (n, height, width, 3)
. I want to wrap the data into a hv.Dataset
and visualize it (with bokeh
) such that:
n
images.I'm primarily interested in a solution without xarray
.
Upvotes: 1
Views: 335
Reputation: 3255
Something like this should work, though I think there's probably a cleaner approach declaring an hv.Dataset
wrapping the input array:
import numpy as np, holoviews as hv
hv.extension('bokeh')
x,y = np.mgrid[-50:51, -100:101] * 0.1
def ms(k):
r = 0.5*np.sin(np.pi +k*x**2+y**2)+0.5
g = 0.5*np.sin(x**2+k*y**2)+0.5
b = 0.5*np.sin(np.pi/k+x**2+y**2)+0.5
return np.dstack([r,g,b])
a = np.stack([ms(i) for i in [1,2,3,4]])
hv.HoloMap({i:hv.RGB(a[i-1,:,:,:], bounds=(-1,-0.5,1,0.5)).opts(data_aspect=1) for i in [1,2,3,4]})
Upvotes: 1