Generates a synthetic confrontation (or control) plate that reproduces the difficulties of real photographs: grey, wrinkled fungal colonies with irregular lobed outlines, a whitish central bacterium with a diffuse yellow halo that overlaps the colonies in brightness, satellite micro-colonies, a bright dish wall, vignetting, exposure errors and sensor noise. Because every pixel's true class and colour are known, the simulator is used to validate MycoHalo's accuracy (see the unit tests and the vignette) and to test new settings before applying them to real data.

simulate_plate(
  width = 900,
  height = 1200,
  dish_r_frac = 0.47,
  dish_diameter_mm = 90,
  layout = plate_layout(),
  colony_radius_mm = 7,
  colony_L = c(52, 46, 40, 58),
  colony_ab = c(0.5, -1),
  edge_lightening = 4,
  facing_darkening = 0,
  texture_sd = 5,
  bacteria = NULL,
  bacteria_radius_mm = 6,
  halo_radius_mm = 17,
  bacteria_lab = c(86, 0, 9),
  halo_lab = c(42, -2, 22),
  agar_lab = c(22, -1, -4),
  background_lab = c(8, 0, 1),
  satellite = TRUE,
  vignetting = 0.25,
  exposure = 1,
  noise_sd = 0.012,
  grey_card = FALSE,
  seed = 1
)

Arguments

width, height

Image size (px).

dish_r_frac

Dish outer radius as a fraction of the image height.

dish_diameter_mm

Physical dish diameter (sets the true scale).

layout

A plate_layout() defining colony positions.

colony_radius_mm

Mean colony radius (mm), recycled per colony.

colony_L

Mean \(L^*\) of each colony (the melanization truth; lower = darker), recycled.

colony_ab

\(a^*, b^*\) of the colonies.

edge_lightening

\(L^*\) units by which the outer 1.5 mm margin is lighter than the interior (age gradient).

facing_darkening

\(L^*\) units by which the colony half facing the centre is darker (simulated localized melanization response).

texture_sd

SD (\(L^*\)) of the wrinkle texture.

bacteria

Include a central bacterium (default: from layout).

bacteria_radius_mm, halo_radius_mm

Radii of bacterium and halo.

bacteria_lab, halo_lab

CIELAB of bacterium and of the halo core.

agar_lab, background_lab

CIELAB of agar and photographic background.

satellite

Add a small satellite colony next to the first colony.

vignetting

Relative light fall-off at the dish edge (0 = none).

exposure

Multiplicative exposure error in linear light.

noise_sd

Gaussian sensor noise (sRGB units, 0-1).

grey_card

Add an 18 % grey card (L* = 50) in the lower-left corner.

seed

Random seed. The user's random-number stream is restored afterwards.

Value

A list with image (H x W x 3 sRGB array) and truth (dish circle, mm_per_px, per-colony true area and mean \(L^*\) before illumination effects, label matrix, bacteria and halo masks, grey-card region).

Examples

sim <- simulate_plate(width = 300, height = 400, seed = 1)
show <- function(a) { plot(as.raster(a)) }
show(sim$image)

sim$truth$colonies
#>   colony_id         x        y area_mm2   L_mean  MI_mean
#> 1        TL  90.67877 140.6788 154.2355 52.95687 47.04313
#> 2        TR 210.32123 140.6788 154.4074 47.11511 52.88489
#> 3        BR 210.32123 260.3212 154.2355 42.20366 57.79634
#> 4        BL  90.67877 260.3212 154.5220 59.18494 40.81506