Multi-channel image data#

Beyond two dimensional images which can be expressed as 2-D matrix, also higher dimensional, multi-channel images are quite common. For example let’s import the hela-cells.tif image:

from skimage.io import imread
import stackview
image = imread('data/hela-cells-8bit.tif')
stackview.insight(image)
shape(512, 672, 3)
dtypeuint8
size1008.0 kB
min0
max255

The image has a 3-dimensional shape:

image.shape
(512, 672, 3)

We see that instead of just pixel rows and columns, we now have an additional number that tells us we have three planes in our data. In this case each image corresponds to a channel but for other data they could be z-planes, time points etc.

Splitting channels#

We can also visualize these three channels independently by splitting them. Furthermore, we can arrange multiple images side-by-side using matplotlib subplots:

channel1 = image[:,:,0]
channel2 = image[:,:,1]
channel3 = image[:,:,2]

stackview.insight(channel1)
shape(512, 672)
dtypeuint8
size336.0 kB
min0
max255
stackview.insight(channel2)
shape(512, 672)
dtypeuint8
size336.0 kB
min0
max166
stackview.insight(channel3)
shape(512, 672)
dtypeuint8
size336.0 kB
min0
max255
import matplotlib.pyplot as plt

fig, axs = plt.subplots(1, 3, figsize=(15,15))

stackview.imshow(channel1, plot=axs[0])
stackview.imshow(channel2, plot=axs[1])
stackview.imshow(channel3, plot=axs[2])
_images/8829fbf5b5fefe0a9822b381ab44b1085d047331b671f162a3c31c1b30ac922d.png
import matplotlib.pyplot as plt

fig, axs = plt.subplots(1, 3, figsize=(15,15))

stackview.imshow(channel1, plot=axs[0], colormap="pure_magenta")
stackview.imshow(channel2, plot=axs[1], colormap="pure_green")
stackview.imshow(channel3, plot=axs[2], colormap="pure_blue")
_images/708192424dbdacc63dca9c6c3ba0dd59a59221895353ab7ea0bc905ada82ab91.png
stackview.switch(images={"Lysosomes":channel1, 
                         "Mitochondria":channel2, 
                         "Nuclei":channel3}, 
                 toggleable=True,
                 colormap=['pure_magenta', 
                           'pure_green', 
                           'pure_blue'])

Exercise#

Visualize the image with nuclei in cyan, lysosomes in red. Check out the documentation of Matplotlib’s colourmaps which can be used in stackview.