Imports a plate image (JPEG, PNG, TIFF, HEIC ... anything ImageMagick reads), applies the EXIF orientation, optionally down-samples it to a working resolution and converts it to CIELAB.

read_plate(path, max_dim = 2000, id = NULL)

Arguments

path

Path to an image file, or a numeric H x W x 3 array with sRGB values in [0, 1] (e.g. from simulate_plate()).

max_dim

Maximum size (px) of the longest image side used for analysis. Default 2000.

id

Optional plate identifier; defaults to the file name without extension.

Value

An object of class mycohalo_plate: a list with

rgb

H x W x 3 array of sRGB values in [0, 1].

lab

H x W x 3 array of CIELAB values.

id, path

Identifier and source path.

original_dim

Width and height of the file (px).

resize_factor

Working px per original px.

clipped_fraction

Fraction of pixels with a channel at 255.

Details

Working resolution. Segmentation and colour statistics are computed on an image whose longest side is at most max_dim pixels. For a 90 mm dish photographed so that it fills the frame, max_dim = 2000 gives roughly 0.05 mm per pixel, i.e. a 1 cm colony is described by ~30 000 pixels — far more than needed for sub-percent precision of mean colour and ~1 % precision of area. Down-sampling uses an anti-aliasing (area-averaging) filter, so it reduces JPEG block noise without biasing mean colour. Use max_dim = Inf to keep the native resolution.

Clipping. Pixels with any channel at 255 carry no colour information (the sensor was saturated). Their fraction is stored and analyze_plate() warns if colonies contain clipped pixels. Photograph with manual exposure so that the brightest bacterial growth stays below ~ 245.

Examples

sim <- simulate_plate(width = 300, height = 400, seed = 1)
plate <- read_plate(sim$image, id = "sim1")
plate
#> <mycohalo_plate> "sim1"
#> • Working size: 300 x 400 px (resize factor 1)
#> • Source: NA
#> • Over-exposed pixels: 0 %
#> • Colour calibration: none