Exports IFC objects to numpy array [objects,height,width,channels]
ExportToNumpy(
...,
objects,
offsets,
image_type = "img",
size = c(64, 64),
force_width = FALSE,
display_progress = TRUE,
python = Sys.getenv("RETICULATE_PYTHON"),
dtype = c("uint8", "int16", "uint16", "double")[3],
mode = c("raw", "gray")[1],
export = c("file", "matrix")[2],
write_to,
overwrite = FALSE
)
arguments to be passed to objectExtract
with the exception of 'ifd' and 'bypass'(=TRUE).
If 'param' is provided the above parameters will be overwritten.
If 'offsets' are not provided extra arguments can also be passed with ... getOffsets
.
/!\ If not any of 'fileName', 'info' and 'param' can be found in ... then attr(offsets, "fileName_image") will be used as 'fileName' input parameter to pass to objectParam
.
integer vector, IDEAS objects ids numbers to use. This argument is not mandatory, if missing, the default, all objects will be used.
object of class `IFC_offset`. This argument is not mandatory but it may allow to save time for repeated image export on same file.
image_type of desired offsets. Either "img" or "msk". Default is "img".
a length 2 integer vector of final dimensions of the image, height 1st and width 2nd. Default is c(64,64).
whether to use information in 'info' to fill size. Default is FALSE. When set to TRUE, width of 'size' argument will be overwritten.
whether to display a progress bar. Default is TRUE.
path to python. Default is Sys.getenv("RETICULATE_PYTHON"). Note that this numpy should be available in this python to be able to export to numpy array file, otherwise 'export' will be forced to "matrix".
desired array?s data-type. Default is "double". Allowed are "uint8", "int16", "uint16" or "double". If 'mode' is "raw", this parameter will be forced to "int16".
(objectParam
argument) color mode export. Either "raw", "gray" . Default is "raw".
export format. Either "file", "matrix". Default is "matrix". Note that you will need 'reticulate' package installed to be able to export to numpy array file, otherwise 'export' will be forced to "matrix".
used when 'export' is "file" to compute respectively filename. Exported type will be deduced from this pattern. Allowed export are '.npy'. Placeholders, if found, will be substituted: -%d: with full path directory -%p: with first parent directory -%e: with extension of (without leading .) -%s: with shortname (i.e. basename without extension) -%o: with objects (at most 10, will be collapse with "_", if more than one). -%c: with channel_id (will be collapse with "_", if more than one, composite in any will be bracketed). A good trick is to use: -"%d/%s_Obj[%o]_Ch[%c].npy", when 'export' is "file"
whether to overwrite file or not. Default is FALSE.
Depending on 'export': -"matrix", an array whose dimensions are [object, height, width, channel]. -"file", it invisibly returns path of .npy exported file.
arguments of objectExtract
will be deduced from ExportToNumpy
input arguments.
Please note that size parameter has to be supplied and could not be set to (0,) when 'object' length is not equal to one
ExportToNumpy
requires reticulate package, python and numpy installed to create npy file.
If one of these is missing, 'export' will be set to "matrix".