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)
|
|
|
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)
|
|
|
stackview.insight(channel2)
|
|
|
stackview.insight(channel3)
|
|
|
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])
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")
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.