Hi all,
I'd used CollectionViewer from skimage.viewer before for viewing microscopy Z stacks. However, I personally felt it was a bit of a pain to use. For instance, before passing in an array of images, the image has to be stretched, otherwise, most of the time, one would end up with a "black" series of images.
So, I wrote a simple function using matplotlib to view image collections, which works quite well, and I think it can be extended to display nD images with multiple sliders.
def ddd(images):
def _update_image(num):
num = int(num)
image = np.squeeze(images[num:num+1])
img_ax.set_data(image)
fig.canvas.draw_idle()
if images.ndim is not 3:
raise ValueError("Not a 3D image.")
Z, _, _ = images.shape
fig, ax = plt.subplots()
img_ax = ax.imshow(np.squeeze(images[0]), cmap="gray")
ax.axis("off")
sliderax = plt.axes([0.19, 0.05, 0.65, 0.03],
facecolor="lightgoldenrodyellow")
img_slider = Slider(sliderax, "Z", 0, Z-1,
valfmt='%d', valinit=0)
img_slider.on_changed(_update_image)
plt.show()
This might be a bit redundant, but I would like your thoughts on whether this might be useful for scikit-image. Some of the plugins of CollectionViewer can be rewritten for this matplotlib based approach in a much more readable fashion -- for instance, the line profile plugin.
Best,