multipagetiff
is a python module that simplifies working with multipage images (stacks). Image stacks are often found as multi-page tiff files.
With this module one can read/write, manipulate and display multi-page tiff files and apply depth color-coding by max-projection, like the Z-projection functions of ImageJ.
instal with pip
pip install multipagetiff
Have a look at the cookbook, it contains examples and explications for a quick start.
The following is a very short example of a depth colored z max-projection of an image stack:
import multipagetiff as mtif
from matplotlib import pyplot as plt
# load the stack
s = mtif.read_stack("spiral.tif", units='um')
s
Multi-Page Stack of 101 pages. (dx=dy=1um, dz=1um, crop=[0, 301, 0, 301]], page limits=[0, 101])
# plot the pages separately
mtif.plot_pages(s)
# plot the z-max-projection
mtif.plot_flatten(s)
(101, 301, 301, 3)
# set a crop
s.crop_horizontal = 25,245
s.crop_vertical = 25,225
mtif.plot_selection(s)
mtif.plot_flatten(s)
(101, 200, 220, 3)
mtif.plot_flatten(s, axis=1)
# Plot orthogonal views of the stack.
# i.e. 3 orthogona; slices intersecting at a specified point (stack's center by default)
mtif.plot.orthogonal_views(s, cmap="gray")