#!/usr/bin/env python # coding: utf-8 # # Zoom # In[1]: import stackview from skimage.io import imread, imshow from skimage.filters import gaussian, threshold_otsu, sobel from skimage.measure import label # In[2]: image = imread('data/Haase_MRT_tfl3d1.tif')[:,80:120,:40] # In[3]: stackview.insight(image) # When working with small images, the view may be suboptimal. # In[4]: stackview.slice(image) # Thus, you can provide a `zoom_factor`. # In[5]: stackview.slice(image, zoom_factor=10) # This also works with other tools such as the `picker`. # In[6]: stackview.picker(image, zoom_factor=10) # If you don't like the neareast-neighbor interpolation, you can also specify a higher order of the spline-interpolation used under the hood. # In[7]: stackview.picker(image, zoom_factor=10, zoom_spline_order=3) # Some more zoomed views to check if `stackview` tools work. # In[8]: stackview.curtain(image, 256-image, zoom_factor=10, continuous_update=True) # In[9]: blobs = imread('data/blobs.tif') stackview.picker(label(blobs > 120), zoom_factor=2) # In[10]: stackview.side_by_side(blobs, label(blobs > 120), zoom_factor=0.5, continuous_update=True) # In[11]: def my_custom_code(image, sigma:float = 1, show_labels: bool = True): sigma = abs(sigma) blurred_image = gaussian(image, sigma=sigma) binary_image = blurred_image > threshold_otsu(blurred_image) edge_image = sobel(binary_image) if show_labels: return label(binary_image) else: return edge_image * image.max() + image stackview.interact(my_custom_code, blobs, zoom_factor=2) # In[ ]: