Interactive Image Visualization with Stackview#

This notebook demonstrates how to visualize images, segmented objects in images and how to explore measurements interactively.

import numpy as np
import pandas as pd
import stackview
from skimage.io import imread
from skimage.measure import regionprops_table
import matplotlib.pyplot as plt

Step 1: Load Image Data#

We load both the original image a corresponding label image and measurements from these labels.

# Load the original image
image = imread('data/blobs.tif')

# Load the label image
labels = imread('data/blobs_labels.tif')

# load measurements
df = pd.read_csv("data/blobs_measurements.csv")

This quick image visualization also shows descriptive statistics of the image.

stackview.insight(image)
shape(254, 256)
dtypeuint8
size63.5 kB
min8
max248

Step 3: Interactive Histogram Visualization#

We create an interactive histogram to explore the intensity in regions in the image.

stackview.histogram(image)

Step 4: Curtain View - Compare Image and Labels#

The curtain view allows us to interactively compare the original image with the label image using a moveable divider.

# Show curtain view to compare image and labels
stackview.curtain(image, labels)

Step 5: Interactive Clusterplot#

The clusterplot allows us to create scatter plots of measurements while being able to see the corresponding objects in the label image. This is powerful for exploring relationships between measurements and spatial context.

stackview.clusterplot(image=image, 
                     labels=labels, 
                     df=df, 
                     column_x='area', 
                     column_y='mean_intensity')

Exercise#

stackview has a function to hover over an image and read pixel intensities. Find out how this function is called and try it out. You can write stackview. and hit TAB or read the documentation to achieve this.