Skip to contents

Create a spatial calibration from total pixel count and total physical distance. Useful when scanner metadata provides the scan length and the image dimensions are known.

Usage

hsi_calibration_from_dims(pixels, distance = 1000, units = "um")

Arguments

pixels

Numeric. Total number of pixels along the measured axis. Single positive value.

distance

Numeric. Total physical distance corresponding to those pixels. Single positive value. Default 1000.

units

Character. Units of the provided distance. One of "um" (micrometers), "mm", or "cm". Default "um".

Value

A named numeric with resolution in µm/px, named "um_per_px".

Examples

calibration <- hsi_calibration_from_dims(
  pixels = 2500,
  distance = 150,
  units = "mm")

if (FALSE) { # \dontrun{
raster <- terra::rast("scan.tif")

calibration <- hsi_calibration_from_dims(
  pixels = terra::nrow(raster),
  distance = 150,
  units = "mm"
)
} # }