# NOT RUN {
if(requireNamespace("IFCdata", quietly = TRUE)) {
## use a cif file
file_cif <- system.file("extdata", "example.cif", package = "IFCdata")
cif_offs <- getOffsets(fileName = file_cif, fast = TRUE)
## extract infomation
info <- getInfo(fileName = file_cif, from = "analysis")
## retrieve number of objects stored
nobj <- as.integer(info$objcount)
## randomly subset the offsets of at most 5 "img" objects
sel = sample(0:(nobj-1), min(5, nobj))
sub_offs <- subsetOffsets(cif_offs, objects = sel, image_type = "img")
## read IFDs from these "img" objects
IFDs <- getIFD(fileName = file_cif, offsets = sub_offs)
## extract raw data of these"img" objects to matrix
raw = objectExtract(ifd = IFDs, info = info, mode = "raw",
export = "matrix")
## extract base64 "rgb" colorized version of these "img" objects to base64
b64 = objectExtract(ifd = IFDs, info = info, mode = "rgb",
export = "base64", base64_id = TRUE,
write_to = "example_%o_%c.png")
## use DisplayGallery to show the first "img" objects and play with ... extra parameters
## force_range, add_noise, selection, composite, see objectParam
DisplayGallery(info = info, offsets = cif_offs, objects = sel,
base64_id = TRUE, write_to = "example_%o_%c.png",
force_range = c(FALSE,TRUE,FALSE,TRUE), add_noise = FALSE,
selection = c(1,2,4,6), composite = "1.7/4.3")
} else {
message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
'https://gitdemont.github.io/IFCdata/',
'to install extra files required to run this example.'))
}
# }
Run the code above in your browser using DataLab