Extracts side length of pixel sides depending on the resolution of the chosen image.

getPixelScaleFactor(object, ...)

# S4 method for class 'SPATA2'
getPixelScaleFactor(
  object,
  unit,
  img_name = activeImage(object),
  switch = FALSE,
  add_attr = TRUE,
  verbose = NULL,
  ...
)

# S4 method for class 'SpatialData'
getPixelScaleFactor(
  object,
  unit,
  img_name = activeImage(object),
  switch = FALSE,
  add_attr = TRUE,
  verbose = NULL,
  ...
)

# S4 method for class 'HistoImage'
getPixelScaleFactor(
  object,
  unit,
  switch = FALSE,
  add_attr = TRUE,
  verbose = TRUE,
  ...
)

Arguments

object

An object of class SPATA2 or, in case of S4 generics, objects of classes for which a method has been defined.

...

Used to absorb deprecated arguments or functions.

unit

Character value. The SI-unit of interest. Determines the reference unit for the pixel size.

img_name

Character value. The name of the image of interest. If NULL, the active image is chosen by default. Either way, must be one of getImageNames().

switch

Logical value. If TRUE, the unit of the output is switched. See details for more.

verbose

Logical. If TRUE, informative messages regarding the computational progress will be printed.

(Warning messages will always be printed.)

Value

A single numeric value with the unit defined in attribute unit.

Details

If switch is FALSE, the default, the output is to be interpreted as unit/pixel. E.g. with unit = 'um' an output of 15 'um/px' means that under the current resolution of the image height and width one pixel corresponds to 15 um in height and width in the original tissue.

If switch is TRUE, the output is to be interpreted as pixel/unit. E.g. an output value of 0.07 'px/um' means that under the current image resolution one micrometer corresponds to 0.07 pixel in the image.