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.

from import imread, imshow
image = imread('../../data/hela-cells.tif')

/Users/haase/opt/anaconda3/envs/bio_39/lib/python3.9/site-packages/skimage/io/_plugins/ UserWarning: Low image data range; displaying image with stretched contrast.
  lo, hi, cmap = _get_display_range(image)
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
<matplotlib.image.AxesImage at 0x173bfd400>

This visualization is not perfect as discussed here. We need to normalize the image first. Normalization in this context means distributing all pixel intensities between 0 and 1. We can do this by dividing the image by its maximum intensity.

imshow(image / image.max())
<matplotlib.image.AxesImage at 0x173d7ffa0>

To understand what we see, we should take a look at the image’s shape. The image is abviously 672 pixels wide, 512 pixels high and has 3 channels:

(512, 672, 3)

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

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

import matplotlib.pyplot as plt

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

<matplotlib.image.AxesImage at 0x173e65ca0>

Furthermore, imshow from matplotlib also takes lookup tables / color maps as parameter. See all color maps supported by matplotlib.

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

axs[0].imshow(channel1, cmap='plasma')
axs[1].imshow(channel2, cmap='hsv')
axs[2].imshow(channel3, cmap='cool')
<matplotlib.image.AxesImage at 0x173f8a040>


Explore look-up tables, a.k.a. colormaps in matplotlib and visualize the three channels above as similar as possible to how the image is visualized in ImageJ.