Skip to contents

Draws the detected dish boundary, colony outline, and any detected crack segments on top of the original plate photograph, using EBImage::readImage() and EBImage's drawing primitives. This lets you visually verify that automated segmentation and crack detection were computed as expected, rather than trusting the summary statistics alone.

Usage

plot_grayleafspot_overlay(
  run,
  id = NULL,
  image_path = NULL,
  show_dish = TRUE,
  show_colony = TRUE,
  show_cracks = TRUE,
  dish_col = "yellow",
  colony_col = "red",
  crack_col = "cyan"
)

Arguments

run

A grayleafspot_run object (see grayleafspot_analyze(), read_grayleafspot_results()), a plain list of per-image raw result records, or a single record (a list with a rawAnalysis element, as produced internally by the analysis engines).

id

Optional character. id or filename of the image to overlay, matched against the records in run. Defaults to the first record.

image_path

Optional character. Explicit path to the source image. Falls back to the record's stored imageUrl, which is only a resolvable local file path for runs produced by the pure-R fallback engine; for runs produced by the Python/basilisk pipeline, pass this explicitly (e.g. a file inside the original input_dir).

show_dish, show_colony, show_cracks

Logical. Which overlays to draw.

dish_col, colony_col, crack_col

Character. Colors for each overlay, passed to grDevices::col2rgb().

Value

An EBImage::Image with the requested overlays drawn on it. Display with EBImage::display() or save with EBImage::writeImage().

Examples

image_file <- tempfile(fileext = ".png")
png::writePNG(matrix(seq(0, 1, length.out = 32^2), 32), image_file)
decoder_available <- tryCatch({
  EBImage::readImage(image_file)
  TRUE
}, error = function(e) FALSE)
if (decoder_available) {
  record <- list(
    imageUrl = image_file,
    rawAnalysis = list(
      dish_center = list(x = 500, y = 500),
      dish_radius = 400
    )
  )
  overlay <- plot_grayleafspot_overlay(record)
}
unlink(image_file)