library("rplatypus")
masks <- predict(fit, "unet", split = "test")
save_masks(masks, "predictions", binary_colormap, suffix = "_unet")Write masks to files
Description
Predictions are only half useful while they are an array in a session. This writes them as ordinary PNGs that open in anything - ImageJ, QuPath, a viewer, a colleague’s machine - and returns the paths, so it can sit at the end of a pipeline.
Usage
save_masks(masks, dir, colormap, names = NULL, suffix = "")
Arguments
masks
|
Class indices from For volumes use save_class_masks(). A prediction where some pixel is in two classes at once is refused here rather than reduced: one pixel gets one colour, so writing it as a colour map would mean choosing one of the classes it is in and leaving nothing in the file to say that happened.
|
dir
|
Directory to write into; created if it does not exist. |
colormap
|
A list of RGB triples, one per class. |
names
|
File names, or the source image paths to take names from. Defaults to mask_0001.png and so on.
|
suffix
|
Added before the extension, so predictions from different models can sit in one directory without overwriting each other. |
Details
Files go where you say, not beside the images they came from. Writing into somebody’s dataset directory is a surprising thing for a function to do, and a second run against a different model would quietly mix its results in with the first.
Value
The paths written, invisibly.