library("rplatypus")
images <- read_images(list.files("test/", full.names = TRUE), size = c(256, 256))
# A label map stored wide, whose values are classes rather than brightness.
values <- read_images("seg.png", channels = 1, nearest = TRUE, label_map = TRUE)Read images as the model sees them
Description
Reads through the engine’s own pipeline rather than a separate decoder, so what you plot is what the model was given. A picture drawn from a differently resized copy is a picture of something the model never saw, and the disagreements it appears to show may be nothing but the resizing.
Usage
read_images(
paths,
size = NULL,
channels = 3,
nearest = FALSE,
label_map = FALSE
)
Arguments
paths
|
Image files. |
size
|
c(height, width) to read at, or NULL to keep each image’s own size - which only works if they all agree.
|
channels
|
3 for colour, 1 for greyscale. |
nearest
|
Use nearest-neighbour resizing. Required for masks: interpolating one invents colours belonging to no class, which then quietly become background. |
label_map
|
The file holds class identities rather than brightness, so read it at full integer width. A 16-bit PNG or a 32-bit TIFF label map is otherwise read through 8-bit greyscale, where every value above 255 arrives as 255 - two classes then merge into one with nothing unmatched to say so. One channel only, because a label map has one, and never for an image: a picture is divided by 255 later. For a volume this argument does nothing andnearest is what matters, which is the engine’s own rule rather than this package’s: a NIfTI or a DICOM series never went through an 8-bit conversion, so there is no width to widen, and the flag that says these numbers are classes on that route is nearest. Passing label_map = TRUE alone on a volume returns the values divided by the largest one. Pass both.
|
Value
An image x height x width x channels array of 0-255 values - or of the file’s own integer values with label_map = TRUE and, for a volume, nearest = TRUE. A volume read with label_map = TRUE and nearest = FALSE comes back rescaled to 0-1, and this function warns when it is asked for that combination.