Image stack (source code)

= Image stack

An <image stack> is an ordered collection of related two-dimensional images treated as one dataset. Its index may denote cutting depth, time or another acquisition coordinate: stacking images does not by itself establish a spatial <volume>. The <ImageJ> guide distinguishes ordinary stacks from datasets with several independent axes and requires equal image dimensions and bit depth within an ordinary stack.<ImageJ User Guide by Tiago Ferreira and Wayne Rasband>[IJ1.46r, section8, Stacks and Hyperstacks]{ref}

For an original spatial example, store 100 grayscale images as an <array> $I[k,j,i]$ with shape $(100,512,512)$, where $k$ indexes sections and $i,j$ index pixels. If each value occupies two <bytes>, the raw data require
$$
100\cdot512\cdot512\cdot2=52428800\;\text{bytes}=50\;\text{MiB}.
$$
This excludes metadata and compression. Define the <image stack axis calibration> explicitly: at lateral <pixel pitch> $p=5\,\mathrm{nm}$ and section spacing $\Delta z=40\,\mathrm{nm}$, a zero-origin convention is
$$
x=ip,\qquad y=jp,\qquad z=k\Delta z.
$$
The first and last section centers are $99\Delta z=3.96\,\mathrm{\mu m}$ apart. Array shape alone does not contain that information.

An index permutation can preserve every stored intensity yet exchange depth and lateral coordinates, giving the wrong geometry if the spacing metadata are not permuted too. <Image registration> estimates alignment between slices; <image segmentation> assigns structural labels. Neither operation supplies a missing section's observations. For datasets exceeding memory, an <image stack> can also be read a slice at a time; the guide's virtual-stack representation keeps the image sequence on disk.<ImageJ User Guide by Tiago Ferreira and Wayne Rasband>[Section8, Virtual Stacks]{ref}