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.
from stackview import insight, jupyter_displayable_output
from skimage.io import imread, imshow
from skimage.filters import gaussian
from skimage.measure import label
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.
insight(image[60])
|
|
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.
sv_image = insight(image[60])
type(sv_image)
stackview._static_view.StackViewNDArray
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.
result = gaussian(sv_image, sigma=6)
type(result)
numpy.ndarray
insight(result)
|
|
When implementing custom image processing functions, those can be annotated so that the result becomes an insight
image automatically.
@jupyter_displayable_output
def my_gaussian(image, sigma):
return gaussian(image, sigma)
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.
@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)
cle_gaussian(image[60], 1)
|
clesperanto made image
|