writetiff: Tiff Writer

View source: R/writetiff.R

writetiffR Documentation

Tiff Writer

Description

Writes TIFF from [0-1] Normalized Image.

Usage

writetiff(image, ..., what = "uint8")

Arguments

image

a matrix or array or representing the image:
-2D matrix [h,w] will be written as single grayscale [h,w] IFD (Image Field Directory),
-3D array [h,w,c] will be written as single IFD of multichannel [h,w,c] grayscale or RGB if rgb = TRUE,
-4D array [h,w,c,f] will be written as multiple (multiframe) IFD of multichannel [h,w,c] grayscale or RGB if rgb = TRUE,
with h=height, w=width, c=channel, f=frame.

...

other arguments to be passed to writemulti.

what

bits mode used to store image. Default is "uint8". Allowed are "uint8", "int8", "uint16", "int16", "uint32", "int32", "float" and "double".

Details

it is aimed to simplify the use of writemulti by requiring minimal input from user.
/!\ Note that image should range from 0 to 1. /!\ Note that as.rgb that will be automatically filled with TRUE if image is 3D array with 3rd dimension being of length 3. So, if an RGB output is not desired, you should provide a 4D array.

Value

It invisibly returns full path of exported file or a raw vector when write_to = raw(0) otherwise.

Examples

## Not run: 
if(requireNamespace("IFCdata", quietly = TRUE)) {
  ## use a cif file
  file_cif <- system.file("extdata", "example.cif", package = "IFCdata")
  ## extract image values from cif file as [0-1] RGB 3D array
  img = ExtractImages_toMatrix(fileName = file_cif, mode = "rgb", objects = 3, selection = 3,
                               force_width = FALSE, size = c(0,0))
  ## create RGB tiff file
  file_tif = writetiff(image = img[[1]][[1]], write_to = tempfile(fileext = ".tif"))
  ## inspect exported file
  IFD = getIFD(file_tif)
  sapply(IFD[[1]]$tags, FUN = function(x) x)
} 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.'))
}

## End(Not run)

gitdemont/IFC documentation built on Feb. 20, 2025, 12:55 a.m.