#!/usr/bin/env python # coding: utf-8 # # Static views # In this notebook we demonstrate how to create static views of images with additional information such as shape, data type and size of the pixel array, minimum and maximum intensity and histograms. # In[1]: from stackview import insight, jupyter_displayable_output from skimage.io import imread, imshow from skimage.filters import gaussian from skimage.measure import label # In[2]: image = imread('data/Haase_MRT_tfl3d1.tif') # The `insight` function turns a numpy-array into a numpy-compatible array that has an image-display in jupyter notebooks. # In[3]: insight(image[60]) # In[4]: blobs = imread('data/blobs.tif') labels = label(blobs > 120) insight(labels) # The function `insight` returns a variable that can be post-processed using common libraries, it aims to be just a numpy-array with some extras. # In[5]: sv_image = insight(image[60]) type(sv_image) # In[6]: sv_image # After processing the `insight` generated image, e.g. using the `gaussian` function from scikit-image, the result must be converted again to have the display. # In[7]: result = gaussian(sv_image, sigma=6) type(result) # In[8]: insight(result) # ## Custom functions # When implementing custom image processing functions, those can be annotated so that the result becomes an `insight` image automatically. # In[9]: @jupyter_displayable_output def my_gaussian(image, sigma): return gaussian(image, sigma) # In[10]: my_gaussian(image[60], 2) # It is recommended to add a library name of your library and a link to the documentation so that users can click the link right in the `insight` display. # In[11]: @jupyter_displayable_output(library_name="clesperanto", help_url="https://github.com/clesperanto") def cle_gaussian(image, sigma): import pyclesperanto_prototype as cle return cle.gaussian_blur(image, sigma_x=sigma, sigma_y=sigma) # In[12]: cle_gaussian(image[60], 1) # In[ ]: