Medical & Scientific Vision

Whole-Slide Imaging

How slide scanners digitize glass microscope slides into gigapixel images, from tile and line scanning, stitching and focus to resolution in micrometers per pixel, pyramidal vendor, DICOM and OME-TIFF files, compression, color calibration and image quality, and how vision code reads them.

intermediate

Whole-slide imaging (WSI) is the digitization of an entire glass microscope slide, or a selected part of it, into a single high-resolution image by an automated slide scanner. The scanner moves the slide under a microscope objective, images it piece by piece, and assembles the pieces into one image of billions of pixels, stored at several resolutions so that it can be viewed and analyzed like a map. Zarella et al. (2019), in a white paper from the Digital Pathology Association, describe the comparison pathologists make: navigating a virtual slide much as they navigate Google Maps.

Digital Pathology introduces whole-slide images, their size, the tiled pyramid and the DICOM extension for them, and the analysis built on top. This article treats the scanner and the file in more depth: how a slide is scanned, focused and stitched; what resolution means in micrometers per pixel; how vendor formats, DICOM and OME-TIFF store the pyramid; how compression, color and focus affect the pixels a model sees; and how analysis code reads regions from a file far too large to load. Scanners and formats change, so facts about them are dated and attributed to their makers’ or maintainers’ documents; no product is ranked here.

How It Works

A slide scanner, in the white paper’s summary, has four main components: a light source, a slide stage, objective lenses and a high-resolution camera (Zarella et al., 2019). The FDA’s special controls for whole-slide imaging systems list a finer breakdown that submissions must describe and bench-test, as appropriate: slide feeder, light source, imaging optics, mechanical scanner movement, digital imaging sensor, image processing software, image composition techniques, image file formats, image review manipulation software, computer environment and display system (Food and Drug Administration, 2018). The list is a useful map of where the pixels of a whole-slide image come from.

Finding the tissue

Most scanners first take a low-magnification overview of the whole slide and detect the tissue on it, so that only the tissue area is scanned at high resolution (Zarella et al., 2019). Vendors use the same detection to discard blank regions from the file and to shorten scans. The overview usually survives in the file as an associated image: OpenSlide, an open-source library that reads most vendor formats, calls it the macro image, alongside a label image of the slide’s paper or barcode label and a downsampled thumbnail (OpenSlide format pages, as of October 2026). DICOM defines the same roles as image flavors and notes that one purpose of the overview is quality control, to check that no tissue fragment was left out when the areas to scan were selected (NEMA, 2026, Section C.8.12.4).

Tile scanning, line scanning and stitching

The scanner cannot image a slide in one exposure, so it acquires many small images. The white paper distinguishes two designs: scanners that capture the tissue tile by tile with an area camera, and scanners that capture it in a line-scanning fashion as the stage moves; either way, the tiles or lines are then digitally assembled (“stitched”) into one image of the slide (Zarella et al., 2019). When neighboring pieces are joined imperfectly, the error shows in the image: the white paper lists “compensation lines” from improper stitching among scanning artifacts, and stitching error is one of the system-level bench tests named in the FDA’s special controls (Food and Drug Administration, 2018).

Several formats keep evidence of the acquisition rather than a perfectly stitched mosaic. OpenSlide’s documentation describes MIRAX scanners as taking overlapping photos and recording the position of each one in a slide position file, so that overlaps remain between images from different photos; Trestle, Ventana and Zeiss files also store overlapping tiles, with Zeiss CZI tiles placed at arbitrary pixel positions and typically large, such as 2,056 × 2,464 pixels (OpenSlide format pages, as of October 2026). A reader that assumes a regular grid of non-overlapping tiles would misplace pixels in such files, which is one reason format support is detailed work.

Focus

A tissue section is not flat at the scale of a high-power objective’s depth of field, and focusing is the main time–quality trade-off in scanning. According to the white paper, strategies range from focusing every tile, which is slowest and potentially gives the best images, through focusing every nth tile, to a focus map: a network of focus points placed over the surface of the tissue, chosen manually or automatically. Focus maps give the fastest scans at the highest potential error rate; line scanning uses them exclusively, tile scanning can use them, and newer scanners refocus continuously during the scan (Zarella et al., 2019).

Kohlberger et al. (2019, arXiv version) classify out-of-focus (OOF) artifacts by extent. Global OOF can come from the scanner focusing on debris on the coverslip; regional OOF can affect particular tissue types, such as fat, or a whole scan lane; and local OOF is common because sections of about 5 µm are thicker than the depth of field of scanners at high magnification. Scanning several focal planes would address local OOF, but in their assessment it increases scan time and file size too much for routine use.

DICOM records how focus was handled. Every whole-slide image states whether focus was automatic or manually adjusted or verified, and whether its pixels come from extended depth of field, that is, from combining acquisitions at several focal planes into one; if so, it records how many planes were combined and their spacing in micrometers. Separately encoded focal planes (z-planes) are a different thing, recorded as a dimension of the pixel matrix (NEMA, 2026, Section C.8.12.4). Supplement 145 defines a z-plane’s position as the nominal height of focus above a reference surface of the slide (NEMA, 2010).

Brightfield, fluorescence and multispectral scanning

Brightfield scanning, which images stained tissue with transmitted white light, is the most common and cost-effective mode; fluorescence scanning digitizes fluorescently labeled slides, such as fluorescent immunohistochemistry or fluorescence in situ hybridization, and in the white paper’s account fluorescence scanners always capture images as tiles; multispectral imaging records more spectral information than three color channels and applies to both (Zarella et al., 2019).

The modes produce different data. A simple color image typically has three 8-bit channels, stored as RGB or transformed to YCbCr, while a multispectral image may encode one band per frame with up to 16 bits per sample; in DICOM a band is stored as a monochrome frame, or up to three bands in a color frame (NEMA, 2010). An optical path describes the illumination and detection for it: illuminator, illumination wavelength or color, filters, lenses, objective power and numerical aperture, with an optional palette lookup table giving the band a display color (NEMA, 2026, Section C.8.12.5). Supplement 145 leaves it to the viewer to decide how to blend several bands for display (NEMA, 2010). Vendor formats differ again: OpenSlide’s documentation describes Leica fluorescence slides as storing each channel in its own TIFF directory, and CZI files as carrying a channel dimension and possibly 16-bit color samples; OpenSlide itself rejects Leica fluorescence images (OpenSlide format pages, as of October 2026). Fluorescence whole-slide images are therefore usually read with microscopy tools such as those described in Bioimage Analysis rather than as RGB pictures.

Data It Produces

Resolution in micrometers per pixel

The physical size of a pixel in the specimen, in micrometers per pixel (mpp), is the quantity that matters for analysis. Magnification is quoted alongside it by the convention, which Digital Pathology records from Supplement 145, that 0.25 mpp is called 40× and 0.5 mpp 20×. The convention is approximate. Kohlberger et al. (2019, arXiv version) scanned their test slides at 40× on two scanners whose pixels were 0.251 µm and 0.230 µm, the first about 9% larger than the second, and Digital Pathology lists the pixel sizes of CAMELYON16’s two scanners. A model trained on “40×” tiles from one scanner therefore sees tissue at a slightly different scale on another unless tiles are resampled to a common mpp.

Each vendor stores the pixel size differently. OpenSlide normalizes it into the properties openslide.mpp-x and openslide.mpp-y: from the MPP key in an Aperio file’s TIFF description, from MICROMETER_PER_PIXEL_X in a MIRAX slide’s metadata, from 10,000 divided by the TIFF resolution in a Leica file when the resolution unit is centimeters, from a scaling value times 10610^6 in a Zeiss file, from the DICOM-style pixel spacing in millimeters times 1,000 in a Philips file, and from the Pixel Spacing attribute in a DICOM file. The nominal objective power is normalized into openslide.objective-power in the same way (OpenSlide format pages, as of October 2026). It follows that a slide whose mpp is missing cannot safely be given the pixel size its nominal magnification suggests.

How fine the sampling needs to be depends on the optics. In a purely optical system the resolution is set by the objective’s numerical aperture, while in a scanner the camera can also limit it: a sensor that samples more coarsely than the objective resolves loses information that no display can restore (Zarella et al., 2019). By the Rayleigh criterion, which Optical Microscopy explains with the sampling it requires, two points in the specimen can be resolved when they are at least 0.61 λ/NA0.61\,\lambda/\mathrm{NA} apart, for wavelength λ\lambda and numerical aperture NA (Mualla et al., 2018, Eq. 5.14). For green light at 550 nm and an objective of NA 0.75, this gives about 0.45 µm; the practical rule of at least two pixels per resolvable distance, an application of the sampling theorem, then asks for pixels of about 0.22 µm or less, and the stricter Nyquist pitch that Optical Microscopy derives from Abbe’s limit, λ/(4 NA)\lambda/(4\,\mathrm{NA}), for about 0.18 µm. The worked numbers are ours, as an illustration of why 40× scans are made at pixel sizes near 0.25 µm, not a specification of any scanner. The white paper’s practical guidance points the same way: 20× is usually adequate for routine viewing and analysis of H&E and immunohistochemistry slides, while in situ hybridization slides should be scanned at 40× to resolve features less than about 0.5 µm apart, and higher magnifications under oil, such as 60×, 63× or 100×, are typically recommended only for specific uses such as blood smears (Zarella et al., 2019).

File sizes

The uncompressed size of a scan follows from its area, pixel size and bit depth. For an area AA scanned at pixel size pp with bb bits per pixel,

bytes=Ap2⋅b8.\text{bytes} = \frac{A}{p^2} \cdot \frac{b}{8} .

The white paper’s example is 1 mm² at 0.25 mpp and 24-bit color: 16 million pixels, 384 million bits, about 48 MB (Zarella et al., 2019). A 1 cm² section at the same settings is therefore about 4.8 GB, and halving the pixel size quadruples the size. Each additional focal plane or spectral band multiplies it again. Supplement 145’s extreme example, a 50 mm × 25 mm sample at 0.1 mpp with 10 focal planes, comes to 3.75 TB uncompressed, and it notes that multispectral imaging may capture up to 10 bands at 16 bits (NEMA, 2010). Even after compression, a single whole-slide image often exceeds 1 GB in practice, and scan times range mainly from 30 seconds to several minutes per slide, increasing with magnification, tissue area and fluorescence (Zarella et al., 2019).

Pyramids and associated images

The file stores the scan as a tiled image pyramid. The white paper’s example is an Aperio file acquired at 40× that also holds the image at 10×, 2.5× and 1.25×, downsampling factors of 4, 4 and 2, plus a thumbnail of about one megapixel; it gives 3 or 4 levels as typical and notes that more levels make the file larger but let a viewer pick a closer scale (Zarella et al., 2019). Formats differ in the factor. OpenSlide’s documentation describes MIRAX levels as each downsampled by 2 from the previous one, Leica levels as generally downsampled by 4, and Sakura levels as power-of-two downsamples (OpenSlide format pages, as of October 2026). DICOM marks a level computed from a higher-resolution one as RESAMPLED (NEMA, 2026, Section C.8.12.4).

The label image deserves care in any dataset built from slides. DICOM requires each whole-slide image to state whether the specimen label appears in it, which must be the case for label and overview images, and separately whether it contains enough burned-in annotation to identify the patient; a label may carry only a specimen identifier (NEMA, 2026, Section C.8.12.4). It follows that a dataset release should check the associated images, not only the pixel pyramid, before slides are shared.

Vendor formats

There is no universal vendor format, and OpenSlide’s project page observes that vendors typically do not document their formats, and that even documented ones omit important details. The library reads the formats below, and since version 4.0.1 (June 2026) also ARGOS (.avs) and Huron (.tif) files; its support is not endorsed by the vendors and may be incomplete (OpenSlide home page, news and format pages, OpenSlide 4.0.1, as of October 2026).

Format (extension) Container, as OpenSlide describes it Details that matter when reading it
Aperio (.svs) Single-file pyramidal tiled TIFF Base level usually in 240 × 240 tiles; second image a stripped thumbnail; label and macro at the end; some files use JPEG 2000 (TIFF compression 33003 or 33005)
Hamamatsu (.vms, .vmu, .ndpi) Multi-file JPEG or uncompressed images with index files, or one TIFF-like file Large levels stored as JPEGs with restart markers, read as oddly shaped tiles such as 4,096 × 8; only focal plane 0 read
Leica (.scn) Single-file pyramidal tiled BigTIFF Main images and macro positioned in nanometers; levels usually a factor 4 apart; fluorescence rejected
MIRAX (.mrxs) Multi-file, with proprietary index and data files Overlapping camera photos with recorded positions; JPEG, PNG or BMP pieces
Philips (.tiff) Single-file pyramidal tiled TIFF or BigTIFF, an export format Level sizes include tile padding, so downsamples must come from the pixel spacings; tiles outside regions of interest may be empty
Sakura (.svslide) SQLite database Separate grayscale JPEG tiles for each color channel
Ventana (.bif, .tif) Single-file pyramidal tiled BigTIFF Overlapping tiles; metadata in XML
Zeiss (.czi) Single-file binary format Overlapping tiles at arbitrary positions, often JPEG XR compressed, also uncompressed or Zstandard; some color images stored without gamma correction
DICOM (.dcm) Standard multi-file format One series per slide; levels and associated images identified by image flavor
Generic tiled TIFF (.tif) Single-file pyramidal tiled TIFF Reduced-resolution images marked by the TIFF reduced-resolution bit; missing tiles rendered transparent

Philips’s native format, iSyntax, is a separate multi-file format that OpenSlide does not read (OpenSlide Philips page, as of October 2026). Zarella et al. (2019) name OpenSlide and Bio-Formats as libraries that read many proprietary formats from common programming environments.

DICOM whole-slide images

DICOM stores each pyramid level as a multi-frame image whose frames are tiles; Digital Pathology describes the tiling, the total pixel matrix and the two tile layouts. A few further attributes of the current standard bear directly on analysis (NEMA, 2026, Sections A.32.8, C.8.12.4 and C.8.12.5):

  • Roles. The third value of Image Type, the image flavor, is VOLUME for pyramid levels, THUMBNAIL for a low-resolution view of the specimen without the label, LABEL for the label alone, and OVERVIEW for an image of the whole glass slide including at least part of the label. OpenSlide uses these flavors to find the levels and associated images among the files of a series (OpenSlide DICOM page).
  • Physical extent. Imaged Volume Width and Height give the scanned area in millimeters and Imaged Volume Depth its thickness in micrometers; each frame’s pixel spacing gives its mpp.
  • Pixel encoding. Samples are 8 or 16 bits, unsigned; color images use RGB or one of the YCbCr encodings that go with JPEG and JPEG 2000 compression, and monochrome images hold one band each.
  • Color. For color images, each optical path must carry an ICC profile, which maps stored pixel values into the ICC Profile Connection Space (see Calibration below).
  • Compression history. Lossy Image Compression records whether an image has ever been lossy-compressed; once set it shall not be reset, and the approximate ratio and method must be given.
  • Missing regions. An optional recommended color, in CIELab, tells a viewer how to display parts of the total pixel matrix that are not encoded, which sparse scans leave.

OME-TIFF

OME-TIFF is the open microscopy format of the Open Microscopy Environment; Bioimage Analysis describes its OME-XML metadata block and OME-Zarr, its chunked successor for cloud access. Pyramids were added in version 6.0.0 of the specification as sub-resolutions. Each pyramid level must be a downsampling of the full-resolution plane in X and Y, and the factor should be an integer, the same in X and Y and the same between consecutive levels; the sub-resolution images are stored as TIFF SubIFDs of the full-resolution plane, ordered from largest to smallest, rather than in the main chain of images. The largest planes should be tiled, the levels may use different compression (for example lossless at full resolution and lossy below it), and BigTIFF is recommended for large images (OME-TIFF specification, as of October 2026).

Compression

Compression is part of nearly every whole-slide image. Supplement 145 states that lossless compression typically reduces size 3–5× and that JPEG and JPEG 2000 are the most frequently used lossy methods, JPEG 2000 giving higher compression and fewer artifacts at a higher computational cost (NEMA, 2010); its reported ratios at which pathologists found no loss of diagnostic information are summarized in Digital Pathology. The white paper adds that vendors use JPEG, JPEG 2000 or LZW, often reducing size by a factor of 7 or more. Its Figure 1 shows an H&E image compressed 15.9-fold at a JPEG quality factor of 0.8 and 108.3-fold at 0.1, the second with visible artifacts. It notes that densitometric measurements are more sensitive than morphologic assessment to this loss, and discourages compressing the same image repeatedly with JPEG (Zarella et al., 2019). The table above shows the range of codecs in vendor files; the DICOM registry, as of release 2026d, also lists transfer syntaxes for High-Throughput JPEG 2000 and JPEG XL (NEMA, 2026, PS3.6).

For vision, compression settings are one more property of the scanner pipeline that differs between sites. Kohlberger et al. (2019, arXiv version) found that real out-of-focus regions in their slides, scanned with JPEG quality settings of 70 to 90, still showed JPEG block artifacts and pixel noise that synthetic blur removes, and they added both back to their synthetic training data.

Image Quality and Calibration

What is tested

The FDA’s special controls require system-level bench testing, as appropriate, of color reproducibility, spatial resolution, focusing, whole-slide tissue coverage, stitching error and turnaround time (Food and Drug Administration, 2018). The list names the properties a scanner can get wrong, and each has a counterpart in analysis: color shifts change what a model sees, missed tissue removes evidence, and focus and stitching errors create artifacts in the tiles. The final order, published on 2 January 2018 and codified as 21 CFR 864.3700, also requires precision and reproducibility studies with multiple systems, sites and readers, and a clinical study comparing diagnosis on digital images with the optical microscope. This summary is taken from the order alone, as of October 2026; the device type’s classification history is in Digital Pathology, and no legal conclusion is drawn here.

Color

The white paper traces color differences to every link of the chain: laboratory protocols for fixation, processing and staining; the scanner, since two scanners can render the same slide very differently; the viewer’s lookup tables; and the display, including the mismatch between the scanner’s and the display’s color gamuts and the aging of displays (Zarella et al., 2019). Stain variation itself is the subject of stain normalization, which Digital Pathology introduces with color deconvolution.

The scanner’s part can be calibrated with the International Color Consortium (ICC) framework. In the procedure the white paper describes, the scanner scans a calibration slide of semitransparent colored patches with known color attributes; the relation between the known colors and the scanned values is stored as an ICC source profile and attached to later scans, and a destination profile characterizes the display, so that a viewer can match the two (Zarella et al., 2019). The formats carry the profile: DICOM requires an ICC profile for color whole-slide images, and Supplement 145 describes it as correcting the color characteristics of an RGB image for the illumination (NEMA, 2010; NEMA, 2026, Section C.8.12.5). OpenSlide reads the embedded profile from formats that carry one, among them Aperio, DICOM, generic TIFF and Ventana files, and exposes it to Python as color_profile (OpenSlide format pages and Python documentation, as of October 2026). For fluorescence, the white paper notes that absolute color reproduction can reduce gamut, contrast and luminance, and that maximizing the visibility of color differences may serve better (Zarella et al., 2019).

Whether a dataset’s pixels have had their profile applied is a practical question for training: if some slides are converted to a standard color space and others are not, the difference becomes one more source of color shift between them. The OpenSlide documentation gives an example of a raw-data convention that a reader must handle: color images from at least Axioscan 7 scanners appear dark because they seem not to be gamma corrected before storage, and a gamma value in the file’s metadata may be the one recommended for display (OpenSlide Zeiss page, as of October 2026).

Focus

Scanners evaluate focus internally, but Kohlberger et al. (2019, arXiv version) note that focus problems remain despite autofocus, that focus metrics differ between scanners, and that they are rarely exported with their spatial distribution. They trained a network, ConvFocus, on in-focus patches blurred synthetically and evaluated it on whole-slide images of three tissue types and three stains from two scanners, a Leica Aperio AT2 and a Hamamatsu NanoZoomer S360, against a pathologist’s focus grades for about 37,700 patches of 35 × 35 µm (seven slides per scanner). They report Spearman rank correlations with those grades of 0.81 and 0.94 on the two scanners (0.808 and 0.936 in their Table 2), and note that a direct comparison between the scanners is not possible because each digitized different regions out of focus. They also stratified the patch-level AUC of their lymph node metastasis detector, LYNA, on the CAMELYON16 test set (80 slides without and 48 with tumor, with pixel-level tumor annotations) by predicted focus class and found it decreased as focus worsened, in real out-of-focus patches and with synthetic blur added to all patches; they cite an earlier study in which out-of-focus germinal centers were mistaken for metastases by an algorithm.

Processing the Data

Analysis code reads a whole-slide image through a library that hides the format. OpenSlide’s interface illustrates the conventions most tools share (OpenSlide Python 1.4.7 documentation and v4.0.1 source, as of October 2026):

  • Levels. A slide has levels numbered from 0, the highest resolution, each with its dimensions and its downsample factor relative to level 0. The factors are floating-point numbers; in Philips files, for example, they must be computed from the levels’ pixel spacings.
  • Coordinates. read_region(location, level, size) takes the top-left corner in level-0 pixel coordinates, whatever level is read, and the region size in pixels of the chosen level. It returns an RGBA image; regions outside the scanned area are transparent, and in the Python binding the color data are not premultiplied by alpha.
  • Level choice. get_best_level_for_downsample(d) returns the level with the largest downsample factor not greater than dd, so that the region is read at or above the resolution needed and then scaled down.
  • Tiles for viewers. A Deep Zoom generator in the Python binding cuts the slide into tiles for web viewers.

Analysis pipelines build on these calls. A common sequence, which Digital Pathology describes for slide-level learning, is to detect the tissue on a low-resolution level, choose the tile grid at a target resolution, and read only the tiles that contain tissue. Choosing tiles by physical size rather than by level index follows from the resolution section: for a target pixel size ptp_t and a base pixel size p0p_0, the needed downsample is d=pt/p0d = p_t / p_0, and the tile is read from the best level for dd and resized by the remaining factor. A pipeline must also decide what to do with transparent pixels; it follows from the RGBA output that a conversion to RGB which drops the alpha channel without filling those pixels can hand a tissue detector colors that are not glass.

Example: a pyramid, tiles and a tissue mask

The script below builds a synthetic whole-slide image with a known tissue mask and measures what the pyramid and the tissue mask save. Tissue is rendered by the Beer–Lambert law with scikit-image’s standard hematoxylin and eosin absorbance vectors: eosin throughout the tissue and hematoxylin in randomly placed nuclei, on bright glass, with a little sensor noise. The slide is 6,144 × 4,096 pixels at an assumed 0.5 mpp (about 3.1 × 2.0 mm, smaller than a real section), stored as a pyramid with factor 2 between levels and 256 × 256 tiles. A function in the style of OpenSlide’s read_region takes level-0 coordinates and counts the tiles a read touches, and the level is chosen by OpenSlide’s rule. Nothing is downloaded and no slide library is needed; the script runs in a few seconds with NumPy 2.3.5, SciPy 1.16.3 and scikit-image 0.25.2, and gives identical output on repeated runs.

import numpy as np
from scipy import ndimage as ndi
from skimage.color import rgb_from_hed
from skimage.draw import disk
from skimage.filters import threshold_otsu
from skimage.transform import downscale_local_mean, resize

rng = np.random.default_rng(0)
H, W, MPP0, TILE = 4096, 6144, 0.5, 256    # level 0: 2.0 x 3.1 mm at 0.5 um/px

# --- a synthetic H&E slide with a known tissue mask --------------------------
low = ndi.gaussian_filter(rng.standard_normal((H // 64, W // 64)), 4)
tissue = ndi.zoom(low / low.std(), 64, order=1) > 0.5   # large fragments
for _ in range(40):                                 # small detached fragments
    rr, cc = disk((rng.integers(H), rng.integers(W)), rng.uniform(15, 40), shape=(H, W))
    tissue[rr, cc] = True                           # tissue: ground-truth mask
eosin = np.where(tissue, 0.35, 0.0).astype(np.float32)
eosin *= 1 + 0.3 * ndi.zoom(ndi.gaussian_filter(
    rng.standard_normal((H // 32, W // 32)), 2), 32, order=1).astype(np.float32)
hema = np.zeros((H, W), np.float32)
ys, xs = np.nonzero(tissue[::8, ::8])              # candidate nucleus sites
pick = rng.choice(len(ys), size=len(ys) // 6, replace=False)
for y, x in zip(ys[pick] * 8, xs[pick] * 8):
    rr, cc = disk((y, x), rng.uniform(4, 7), shape=(H, W))
    hema[rr, cc] = rng.uniform(0.5, 0.9)
od = 0.02 + hema[..., None] * rgb_from_hed[0] + eosin[..., None] * rgb_from_hed[1]
slide = 255 * 10 ** -od + rng.normal(0, 2, (H, W, 3)).astype(np.float32)
del od, hema, eosin
pyr = [np.clip(np.rint(slide), 0, 255).astype(np.uint8)]   # Beer-Lambert render
del slide
while max(pyr[-1].shape[:2]) > TILE:                # factor-2 pyramid
    pyr.append(np.rint(downscale_local_mean(pyr[-1], (2, 2, 1))).astype(np.uint8))
print("level  downsample  um/px      size     tiles")
for k, im in enumerate(pyr):
    nt = -(-im.shape[0] // TILE) * -(-im.shape[1] // TILE)
    print(f"{k:5d}  {2**k:10d}  {MPP0 * 2**k:5.1f}  {im.shape[1]:5d} x {im.shape[0]:<5d}  {nt:5d}")

def stored(factor):                                 # tiled storage, padding included
    tot, h, w = 0, H, W
    while True:
        tot += -(-h // TILE) * -(-w // TILE) * TILE * TILE
        if max(h, w) <= TILE: return tot
        h, w = h // factor, w // factor
base = -(-H // TILE) * -(-W // TILE) * TILE * TILE
print(f"pyramid overhead: factor 2 {stored(2) / base - 1:.1%}, factor 4 {stored(4) / base - 1:.1%}")

# --- reading regions: OpenSlide-style coordinates (level 0) and level choice ---
def best_level(ds):                                 # rule of openslide_get_best_level_for_downsample
    return max(k for k in range(len(pyr)) if 2**k <= ds)

def read_region(x0, y0, level, w, h):               # x0, y0 in level-0 pixels
    d = 2**level
    x, y = x0 // d, y0 // d
    tiles = (((x + w - 1) // TILE - x // TILE + 1) * ((y + h - 1) // TILE - y // TILE + 1))
    return pyr[level][y:y + h, x:x + w], tiles

VW, VH = 400, 300                                   # a viewer window, in screen pixels
print("\nview 400x300   from level 0           from best level")
print("downsample     tiles  decoded MB      level  tiles  decoded MB  mean |diff|")
for ds in (1, 2, 3, 4, 8, 12):
    w0, h0 = VW * ds, VH * ds
    x0, y0 = (W - w0) // 2, (H - h0) // 2
    full, t_full = read_region(x0, y0, 0, w0, h0)
    ref = resize(full, (VH, VW), anti_aliasing=True, preserve_range=True)
    k = best_level(ds)
    part, t_best = read_region(x0, y0, k, w0 // 2**k, h0 // 2**k)
    view = resize(part, (VH, VW), anti_aliasing=True, preserve_range=True)
    mb = lambda t: t * TILE * TILE * 3 / 1e6
    print(f"{ds:10d}  {t_full:8d}  {mb(t_full):10.1f}  {k:9d}  {t_best:5d}  {mb(t_best):10.1f}"
          f"  {np.abs(view - ref).mean():11.2f}")

# --- a tissue mask from a low level, used to select level-0 tiles ------------
gt = downscale_local_mean(tissue.astype(np.float32), (TILE, TILE)) # true tissue fraction
true_tiles = gt > 0.05
print(f"\nlevel-0 tiles: {true_tiles.size}, with tissue (>5% of area): {true_tiles.sum()}")
print("mask level  mask px   Otsu  kept  missed  (their tissue)  extra  tissue in dropped tiles")
for k in range(2, len(pyr)):
    gray = pyr[k].mean(axis=2)
    t = threshold_otsu(gray)
    mask = gray < t                                 # tissue absorbs, glass is bright
    s = TILE // 2**k                                # mask pixels per tile side
    hm, wm = mask.shape[0] // s * s, mask.shape[1] // s * s
    frac = mask[:hm, :wm].reshape(hm // s, s, wm // s, s).mean(axis=(1, 3))
    keep = frac > 0.05
    lost = (tissue.reshape(H // TILE, TILE, W // TILE, TILE).sum(axis=(1, 3))[~keep]).sum()
    miss = gt[true_tiles & ~keep]
    span = f"{miss.min():.1%}-{miss.max():.1%}" if miss.size else "-"
    print(f"{k:10d}  {mask.shape[1]:4d}x{mask.shape[0]:<4d}  {t:5.1f}  {keep.sum():4d}"
          f"  {miss.size:6d}  {span:>14}  {(keep & ~true_tiles).sum():5d}"
          f"  {lost / tissue.sum():22.2%}")
level  downsample  um/px      size     tiles
    0           1    0.5   6144 x 4096     384
    1           2    1.0   3072 x 2048      96
    2           4    2.0   1536 x 1024      24
    3           8    4.0    768 x 512        6
    4          16    8.0    384 x 256        2
    5          32   16.0    192 x 128        1
pyramid overhead: factor 2 33.6%, factor 4 7.0%

view 400x300   from level 0           from best level
downsample     tiles  decoded MB      level  tiles  decoded MB  mean |diff|
         1         4         0.8          0      4         0.8         0.00
         2        16         3.1          1      4         0.8         0.68
         3        24         4.7          1      8         1.6         0.67
         4        48         9.4          2      4         0.8         0.93
         8       140        27.5          3      6         1.2         1.18
        12       320        62.9          3      6         1.2         1.42

level-0 tiles: 384, with tissue (>5% of area): 187
mask level  mask px   Otsu  kept  missed  (their tissue)  extra  tissue in dropped tiles
         2  1536x1024  203.0   187       0               -      0                   0.50%
         3   768x512   203.3   186       1       5.1%-5.1%      0                   0.55%
         4   384x256   203.4   184       3       5.1%-5.2%      0                   0.63%
         5   192x128   203.4   179       8       5.1%-6.4%      0                   0.88%

The pyramid costs a third more storage with levels a factor 2 apart and 7% with a factor of 4. Without tiles these would be the geometric sums 1/31/3 and 1/151/15; padding the edge tiles of each level adds the rest. Both agree with Supplement 145’s estimates quoted in Digital Pathology.

The viewer table is the reason the pyramid exists. A 400 × 300 window at a downsample of 12 covers 4,800 × 3,600 level-0 pixels; read from level 0, that is 320 tiles and about 63 MB of decoded pixels for an image of 0.36 megapixels. Read from the best level, the cost stays at 4 to 8 tiles at every zoom, because the level is chosen so that its pixels are at most twice as fine as the screen’s. A downsample of 3 has no level of its own, so level 1 is read and resized by 1.5, which costs twice the tiles of downsamples 1, 2 and 4. The last column compares the two renderings: they differ by about one gray level on average, since the pyramid was built with a box filter and the reference with scikit-image’s anti-aliasing filter, and each level was rounded to 8 bits. In a real file each level is also compressed separately, which we expect makes them differ more.

The tissue mask decides how much of level 0 is processed at all. Here 187 of 384 tiles hold more than 5% tissue, so tiling only those halves the work; on real slides the fraction depends on how much of the scanned area is glass. Otsu’s threshold on the gray level separates absorbing tissue from bright glass at every level, with almost the same threshold, but coarser masks start to drop tiles. The dropped tiles are all borderline, holding barely more tissue than the 5% cutoff, whose sliver the coarse mask blurs below the cutoff; the tissue lost in dropped tiles rises from 0.50% (the tiles below the cutoff by definition) to 0.88% with a mask of 192 × 128 pixels. The mask finds no extra tiles because this synthetic slide has nothing dark on the glass. Real slides do, such as pen marks, debris and dust, and an intensity threshold counts them as tissue, so practical tissue detectors add color and size rules; that is our expectation for real slides, not something this example shows.

Strengths

  • The whole section, calibrated. A scan keeps every region of the tissue at diagnostic resolution with a recorded pixel size, so analysis is not limited to fields an operator chose and measurements in micrometers are possible when the metadata are right.
  • Cheap access at any scale. Tiles and pyramids make any region at any zoom inexpensive to read, as the example shows.
  • Standards exist. DICOM’s whole-slide objects let slides be exchanged with other medical images; OME-TIFF and OME-Zarr serve research microscopy.

Limitations

  • Size forces compromises: lossy compression in most files and few z-stacks in routine work (Kohlberger et al., 2019, arXiv version).
  • Artifacts persist: out-of-focus regions and stitching seams survive autofocus and are rarely reported with their location.
  • Formats are fragmented: vendor formats are often undocumented, open readers support them unofficially and sometimes partially, and each stores mpp differently.
  • Color and “magnification” are device-dependent: color depends on the scanner unless profiles are applied consistently, and “40×” scans differ in pixel size.

Typical Applications

Whole-slide images are the input of computational pathology, which Digital Pathology surveys: nucleus and tissue segmentation, slide-level prediction from tiles (whole-slide image classification), stain normalization, and pathology foundation models trained on millions of tiles. Outside diagnosis, the white paper describes uses in education, telepathology and research, including serial-section 3-D reconstruction and multispectral imaging for multi-labeling studies (Zarella et al., 2019). Fluorescence and multiplexed slides lead into the microscopy methods of Bioimage Analysis.

Comparison with Other Sensors

  • A microscope with a camera. A conventional microscope camera captures one field of view at a time, chosen by an operator; a slide scanner automates the stage, focus and stitching to capture all fields, and its pixel size is fixed by its optics and sensor rather than by an eyepiece.
  • Radiology scanners. CT and MRI produce volumes of millions of voxels with intensities that have physical meaning; whole-slide images are larger by orders of magnitude, and are mostly color images of stained tissue.

Related

  • Bioimage Analysis

    How biologists turn microscopy images into measurements, covering the imaging modalities from brightfield to electron microscopy, the tasks of segmentation, tracking, classification, restoration and measurement, the open tools from ImageJ and CellProfiler to napari, deep learning and model zoos, open file formats, FAIR data and image archives, and the reporting practices that make an analysis reproducible.

  • Image Sensor

    How the chip behind a camera lens turns light into numbers, from photosites and quantum efficiency to CCD and CMOS readout, full-well capacity, noise, gain and the ADC, colour filters, rolling and global shutters, and EMVA 1288 measurements.

  • Sampling and Aliasing

    How a continuous image becomes a grid of samples, when the samples determine it completely, and how detail too fine for the grid turns into false, coarser patterns.

  • Color Spaces

    A color space assigns numbers to colors; choosing and converting between RGB, CIE XYZ, CIELAB, YCbCr, and HSV correctly matters for both image processing and learning.

  • Thresholding

    Segmenting an image by comparing each pixel's intensity with a threshold, chosen by hand, from the histogram as in Otsu's method, or from each pixel's neighborhood as in Sauvola's method.

  • Medical Computer Vision

    An overview of computer vision on medical images, from X-ray, CT, MRI, ultrasound and microscopy to the tasks of reconstruction, segmentation, registration, detection and slide-level prediction, and the problems that set the field apart from vision on photographs, namely scarce and disputed labels, privacy, shift between scanners and sites, evaluation against clinical reference standards, and regulation.

References

  1. Zarella, M. D., Bowman, D., Aeffner, F., Farahani, N., Xthona, A., Absar, S. F., Parwani, A., Bui, M. & Hartman, D. J. (2019). A Practical Guide to Whole Slide Imaging: A White Paper From the Digital Pathology Association. Archives of Pathology & Laboratory Medicine, 143(2), 222–234.
  2. National Electrical Manufacturers Association, DICOM Standards Committee, Working Group 26 (Pathology) (2010). Digital Imaging and Communications in Medicine (DICOM) Supplement 145: Whole Slide Microscopic Image IOD and SOP Classes. Final Text, 24 August 2010.
  3. National Electrical Manufacturers Association (2026). DICOM PS3.3 2026d: Information Object Definitions. Section A.32.8 (VL Whole Slide Microscopy Image IOD), Section C.8.12.4 (Whole Slide Microscopy Image Module) and Section C.8.12.5 (Optical Path Module).
  4. National Electrical Manufacturers Association (2026). DICOM PS3.6 2026d: Data Dictionary. Annex A, Registry of DICOM Unique Identifiers (Transfer Syntax UIDs).
  5. OpenSlide project. Home page, news page, "Virtual slide formats understood by OpenSlide" and the per-format pages (Aperio, DICOM, Generic tiled TIFF, Hamamatsu, Leica, MIRAX, Philips, Sakura, Trestle, Ventana, Zeiss) (OpenSlide 4.0.1; as of October 2026).
  6. OpenSlide project. OpenSlide Python 1.4.7 documentation (as of October 2026).
  7. OpenSlide project (2026). openslide_get_best_level_for_downsample, src/openslide.c, OpenSlide v4.0.1 source code.
  8. Open Microscopy Environment. OME-TIFF specification, section "Sub-resolutions" (OME Data Model and File Formats documentation; as of October 2026).
  9. Kohlberger, T., Liu, Y., Moran, M., Chen, P.-H. C., Brown, T., Hipp, J. D., Mermel, C. H. & Stumpe, M. C. (2019). Whole-Slide Image Focus Quality: Automatic Assessment and Impact on AI Cancer Detection. Journal of Pathology Informatics, 10(1), 39 (read in arXiv:1901.04619v2).
  10. Mualla, F., Aubreville, M. & Maier, A. (2018). Microscopy. In A. Maier, S. Steidl, V. Christlein & J. Hornegger (Eds.), Medical Imaging Systems: An Introductory Guide, Lecture Notes in Computer Science, 69–90. Springer (open access, CC BY 4.0).
  11. Food and Drug Administration (2018). Medical Devices; Hematology and Pathology Devices; Classification of the Whole Slide Imaging System. Final order. Federal Register, 83 FR 20 (2 January 2018).