Detects round, convex, and overlapping objects (e.g. seeds, cells, nuclei, spores) by predicting radial star-convex polygons and object probability using StarDist.
Usage
image_stardist_dl(
img,
model = "stardist",
prob_threshold = 0.5,
nms_threshold = 0.3,
type = c("segment", "mask", "polygons"),
col_highlight = "salmon",
border = "white",
lwd = 2,
threads = 0,
engine = c("gpu", "cpu"),
device_id = -1,
verbose = TRUE,
plot = TRUE,
dir = pliman_model_dir(),
...
)Arguments
- img
An
Imageobject, a 2D/3D numeric array, a path to an image file, or a list of images.- model
Model name or path to a custom ONNX file. Defaults to
"stardist".- prob_threshold
Probability threshold for detecting object centers (default 0.5).
- nms_threshold
Polygon IoU threshold for Non-Maximum Suppression (default 0.3).
- type
Output type:
"segment"(highlight overlay),"mask"(integer labels), or"polygons".- col_highlight
Fill color for overlay polygons (default
"salmon").- border
Border color for polygon contours (default
"white").- lwd
Line width for polygon contours (default 2).
- threads
Number of CPU threads (default 0 for auto-tuning).
- engine
Execution engine:
"cpu"or"gpu"(DirectML).- device_id
GPU device ID (default -1 for auto).
- verbose
Logical. Whether to show progress messages.
- plot
Logical. Whether to plot the results.
- dir
Model directory (default
pliman_model_dir()).- ...
Additional arguments passed to
graphics::plot().
Value
A list containing:
boxes: Bounding boxes data frame with centers and scores.polygons_x,polygons_y: Coordinates of radial polygon vertices for each object.labels: Integer matrix with instance IDs.mask: Logical foreground mask.
Examples
if (FALSE) { # interactive()
library(pliman)
img <- image_import("grains.png")
res <- image_stardist_dl(img)
}
