Skip to contents

dl_extract_phenotypes() bridges deep learning inference with botanical, agronomic, and biological measurement. It extracts granular phenotypes for every detected instance (seeds, fruits, leaves, lesions, roots) predicted by image_detect_dl(), image_segment_dl(), or image_detect_sahi().

Extracted traits include:

  • Morphometry: Area (pixels and physical units like cm^2), perimeter, circularity, solidity, eccentricity, aspect ratio, and major/minor axes.

  • Spectral Color Profiles: Mean R, G, B channels and user-selected vegetation/color indices (e.g., VARI, NGRDI, GLI, BGI).

  • Texture Features: Haralick contrast, entropy, correlation, and homogeneity.

  • Phytopathology & Severity: Automated disease severity percentage ((Lesion Area / Host Area) * 100) grouped per leaf.

Usage

dl_extract_phenotypes(
  data,
  img = NULL,
  pixel_size = NULL,
  extract_indexes = c("R", "G", "B", "VARI", "NGRDI"),
  haralick = FALSE,
  severity = FALSE,
  host_class = "leaf",
  lesion_class = "lesion",
  verbose = TRUE
)

Arguments

data

A prediction object returned by image_detect_dl(), image_segment_dl(), or image_detect_sahi(), or a bounding box data.frame.

img

An optional image object. If NULL (default), extracted from attr(data, "image").

pixel_size

Optional numeric scalar representing physical size per pixel (e.g. 0.05 for 0.05 cm/px). If provided, physical areas and perimeters are automatically computed.

extract_indexes

Character vector of color indices to calculate per instance. Defaults to c("R", "G", "B", "VARI", "NGRDI").

haralick

Logical. Whether to extract Haralick texture features. Defaults to FALSE.

severity

Logical. Whether to calculate disease severity percentages. Defaults to FALSE.

host_class

Character string naming the host plant class (e.g., "leaf", "folha"). Defaults to "leaf".

lesion_class

Character string naming the symptom/lesion class (e.g., "lesion", "sintoma"). Defaults to "lesion".

verbose

Logical. Show progress messages. Defaults to TRUE.

Value

An S3 object of class c("dl_phenotypes", "data.frame") containing per-object phenotypic traits.

Examples

if (FALSE) { # interactive()
library(pliman)

# Segment leaves and lesions
res <- image_segment_dl("bean_rust.jpg", model = "bean_rust_yolo_seg.onnx")

# Extract comprehensive phenotypes & disease severity
pheno <- dl_extract_phenotypes(res, pixel_size = 0.02, severity = TRUE)
head(pheno)
}