Converts a centre in physical units (for example micrometres) to pixels
and reads a square window of round(size / pixel_size) pixels in each
requested channel. The top-left pixel is
round(centre / pixel_size) - n %/% 2, so a field is reproducible from
its centre, size and pixel size alone.
Value
A list of class sg_field with channels (named list of
n x n matrices), x0, y0, n, pixel_size, centre, size and
extent (c(xmin, xmax, ymin, ymax) of the pixel edges in physical
units).
Examples
f <- tempfile(fileext = ".tif")
planes <- list(matrix(1:100, 10, 10), matrix(101:200, 10, 10))
invisible(tiff::writeTIFF(lapply(planes, function(p) p / 255), f,
bits.per.sample = 8L))
fld <- sg_read_field(f, c("ch1", "ch2"), centre = c(2.5, 2.5), size = 2,
pixel_size = 0.5)
fld$channels$ch2
#> [,1] [,2] [,3] [,4]
#> [1,] 134 144 154 164
#> [2,] 135 145 155 165
#> [3,] 136 146 156 166
#> [4,] 137 147 157 167