Images are diverse
We typically intuitively think of an image file as a digital photograph like a JPEG similar in appearance to human vision, containing a matrix of RGB pixels (three interdependent channels), or perhaps grayscale photographs (single channel).
In reality, images come in much more diverse form:
- They may be three-dimensions.
- They may contain multiple images indexed by time (time series, like movies or animated gifts), or other variables (location, modality).
- They may have independent or dependent channels of any number.
- The pixel color depth varies: 8-bit (as per RGB), 12-bit, 16-bit, floating point, color maps etc.
- Their pixel-sizes may not be physically uniform in X, Y and Z dimensions (anisotropy).
- Rather than pixels, they may be vectors or point-cloud images (neither supported in Anchor).
- They may be non-rectangular or support transparency (neither supported in Anchor).
Image file formats
And when encoded onto a filesystem:
- A single image may span several files; or a single file may contain several images.
- Formats vary widely and are often propietary.
- Compression or color-space encoding may introduce artefacts.
- Metadata is often included, text, numbers, shapes (annotations).
- Pyramid formats may introduce additional structure (multiple scaled-down version of the original) for quick access.
Supported in Anchor
Anchor supports much of this diversity:
- 2D/3D rectangular images with arbitrary number of channels and pixel-size, and 8-bit/16-bit color depths (some limited support for other depths). This is sufficient to include conventional photography, and many forms of biomedical, geospatial or scientific images.
- Time-series and other indexed forms of images (in a limited way).
- Certain forms of metadata (pixel size, channel names) but not others.
- Anchor-specific data structures for object-segmentations (pixel subregions, encoded into HDF5) and geometric shapes (useful for shape annotations and certain kinds of processing).
Image file formats
The drivers for reading images in Anchor are termed readers and all inherit from org.anchoranalysis.image.io.bean.rasterreader.RasterReader
Default Reader - Bioformats
The default reader, org.anchoranalysis.plugin.io.bean.rasterreader.BioformatsReader, employs Bioformats a popular open source library for reading microscopy and digital pathology images - as well as conventional photographs.
Please see the full list of Bioformat’s 150 supported formats - with varying degrees of support.
Another driver, the org.anchoranalysis.plugin.io.bean.rasterreader.MultiFileReader virtually combines different files into a single image (as varying channels, or varying z-stacks in a 3D image, or varying timepoints in a time-series). A regular-expression is used to match file-paths.
Helper utility drivers
Other drivers in
org.anchoranalysis.plugin.io.bean.rasterreader provide useful utility functions:
|FlattenAsChannel||Converts indexed/time-series images into different channels.|
|ImposeResolution||Imposes a specific physical pixel size (across X,Y,Z dimensions).|
|ReadVoxelExtentXml||Reads physical pixel-size from an accompanying
|ThreeWayBranchXYResolution||Uses different readers for different ranges of X,Y physical pixel size.|
|RejectIfConditionXYResolution||Rejects images if a condition is filled on the X-Y resolution.|
Drivers for a wider range of formats are architecturally easily possible, but not currently implemented in the standard Anchor distribution.
Changing the default driver
RasterReader is set in a configuration-file:
$ANCHOR_HOME/config/defaultBeans.xmlin the main Anchor distribution, and
$USER_HOME/.anchor/defaultBeans.xmloptionally, taking precedence.