| Title: | A framework for on-disk and in-memory image arrays |
|---|---|
| Description: | ImageArray provides a framework for on-disk and in-memory image arrays, specifically for pyramidal images stored in HDF5, Zarr and life sciences image file formats (OME Bio-Formats). |
| Authors: | Artür Manukyan [aut, cre, fnd] (ORCID: <https://orcid.org/0000-0002-0441-9517>) |
| Maintainer: | Artür Manukyan <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.1.2 |
| Built: | 2026-05-30 10:09:21 UTC |
| Source: | https://github.com/bioc/ImageArray |
A function for creating objects of BFArray class
BFArray(image.file, series, resolution) ## S4 method for signature 'BFArraySeed' dim(x) ## S4 method for signature 'BFArraySeed' type(x)BFArray(image.file, series, resolution) ## S4 method for signature 'BFArraySeed' dim(x) ## S4 method for signature 'BFArraySeed' type(x)
image.file |
the path to the image read by RBioFormats |
series |
the series IDs of the pyramidal image, typical an integer starting from 1 |
resolution |
the resolution IDs of the pyramidal image, typical an integer starting from 1 |
x |
A BFArray object |
A BFArray object
dim(BFArraySeed): dim function for BFArray objects
type(BFArraySeed): type function for BFArray objects
# get image library(RBioFormats) img.file <- system.file("extdata", "xy_12bit__plant.ome.tiff", package = "ImageArray") bfa <- BFArray(img.file, series = 1, resolution = 2) dim(bfa) type(bfa)# get image library(RBioFormats) img.file <- system.file("extdata", "xy_12bit__plant.ome.tiff", package = "ImageArray") bfa <- BFArray(img.file, series = 1, resolution = 2) dim(bfa) type(bfa)
Create zarr store
create_zarr(store, version = "v2")create_zarr(store, version = "v2")
store |
the location of zarr store |
version |
zarr version |
'NULL'
store <- tempfile(fileext = ".zarr") create_zarr(store)store <- tempfile(fileext = ".zarr") create_zarr(store)
Create a zarr group
create_zarr_group(store, name, version = "v2")create_zarr_group(store, name, version = "v2")
store |
the location of (zarr) store |
name |
name of the group |
version |
zarr version |
'NULL'
store <- tempfile(fileext = ".zarr") create_zarr(store) create_zarr_group(store, "gp")store <- tempfile(fileext = ".zarr") create_zarr(store) create_zarr_group(store, "gp")
creates an object of ImageArray class
createImageArray( image, n.levels = NULL, series = NULL, resolution = NULL, max.pixel.threshold = 700, engine = "EBImage", verbose = FALSE )createImageArray( image, n.levels = NULL, series = NULL, resolution = NULL, max.pixel.threshold = 700, engine = "EBImage", verbose = FALSE )
image |
the image |
n.levels |
the number of levels of the pyramidal image, typical an integer starting from 1 |
series |
the series IDs of the pyramidal image, typical an integer starting from 1. |
resolution |
the resolution IDs of the pyramidal image, typical an integer starting from 1. |
max.pixel.threshold |
the maximum width
and height pixel dimension that the lowest level of the image pyramid
should have, thus the image will be downscaled two folds until both width
and height is below the threshold. Default is 700 pixels.
If |
engine |
the package to use for each image layer: either
|
verbose |
verbose |
An ImageArray object
# get image library(EBImage) img.file <- system.file("images", "sample.png", package="EBImage") # create ImageArray imgarray <- createImageArray(img.file, n.levels = 3) imgarray_raster <- as.raster(imgarray, max.pixel.size = 300) plot(imgarray_raster)# get image library(EBImage) img.file <- system.file("images", "sample.png", package="EBImage") # create ImageArray imgarray <- createImageArray(img.file, n.levels = 3) imgarray_raster <- as.raster(imgarray, max.pixel.size = 300) plot(imgarray_raster)
get information of an ImageArray object
getImageInfo(object)getImageInfo(object)
object |
an ImageArray object |
a data frame of width and height info
# get image library(EBImage) img.file <- system.file("images", "sample.png", package="EBImage") # create ImageArray dir.create(td <- tempfile()) output_h5 <- tempfile(fileext = ".h5") imgarray <- writeImageArray(img.file, output = output_h5, name = "image", verbose = FALSE) getImageInfo(imgarray) # create ImageArray imgarray <- createImageArray(img.file, n.levels = 3) imgarray_raster <- as.raster(imgarray, max.pixel.size = 300) getImageInfo(imgarray)# get image library(EBImage) img.file <- system.file("images", "sample.png", package="EBImage") # create ImageArray dir.create(td <- tempfile()) output_h5 <- tempfile(fileext = ".h5") imgarray <- writeImageArray(img.file, output = output_h5, name = "image", verbose = FALSE) getImageInfo(imgarray) # create ImageArray imgarray <- createImageArray(img.file, n.levels = 3) imgarray_raster <- as.raster(imgarray, max.pixel.size = 300) getImageInfo(imgarray)
Methods for ImageArray objects
## S4 method for signature 'ImageArray,ANY,ANY,ANY' x[i, j, ..., drop = FALSE] ## S4 method for signature 'ImageArray,numeric' x[[i]] ## S4 replacement method for signature 'ImageArray,numeric' x[[i, j, ...]] <- value ## S4 method for signature 'ImageArray' dim(x) ## S4 method for signature 'ImageArray' type(x) ## S4 method for signature 'ImageArray' length(x) ImageArray(meta, levels) ## S4 method for signature 'ImageArray' realize(x, level = NULL, max.pixel.size = NULL, min.pixel.size = NULL) ## S3 method for class 'ImageArray' as.raster(x, level = NULL, max.pixel.size = NULL, min.pixel.size = NULL, ...) ## S4 method for signature 'ImageArray' rotate(x, angle) ## S4 method for signature 'ImageArray' aperm(a, perm) ## S4 method for signature 'ImageArray' negate(object) ## S4 method for signature 'ImageArray' modulate(object, brightness) ## S4 method for signature 'ImageArray' flip(x) ## S4 method for signature 'ImageArray' flop(x) ## S4 method for signature 'ImageArray' crop(object, index) ## S4 method for signature 'ImageArray' axes(object) ## S4 method for signature 'ImageArray' meta(object) ## S4 method for signature 'ImageArray' path(object) ## S4 replacement method for signature 'ImageArray' path(object) <- value## S4 method for signature 'ImageArray,ANY,ANY,ANY' x[i, j, ..., drop = FALSE] ## S4 method for signature 'ImageArray,numeric' x[[i]] ## S4 replacement method for signature 'ImageArray,numeric' x[[i, j, ...]] <- value ## S4 method for signature 'ImageArray' dim(x) ## S4 method for signature 'ImageArray' type(x) ## S4 method for signature 'ImageArray' length(x) ImageArray(meta, levels) ## S4 method for signature 'ImageArray' realize(x, level = NULL, max.pixel.size = NULL, min.pixel.size = NULL) ## S3 method for class 'ImageArray' as.raster(x, level = NULL, max.pixel.size = NULL, min.pixel.size = NULL, ...) ## S4 method for signature 'ImageArray' rotate(x, angle) ## S4 method for signature 'ImageArray' aperm(a, perm) ## S4 method for signature 'ImageArray' negate(object) ## S4 method for signature 'ImageArray' modulate(object, brightness) ## S4 method for signature 'ImageArray' flip(x) ## S4 method for signature 'ImageArray' flop(x) ## S4 method for signature 'ImageArray' crop(object, index) ## S4 method for signature 'ImageArray' axes(object) ## S4 method for signature 'ImageArray' meta(object) ## S4 method for signature 'ImageArray' path(object) ## S4 replacement method for signature 'ImageArray' path(object) <- value
x, a, object
|
An ImageArray object |
i, j, value
|
Depends on the usage
|
... |
Arguments passed to other methods |
drop |
ignored |
meta |
the metadata of the ImageArray object. |
levels |
levels of the pyramid image, typically a vector of integers starting with 1 |
level |
level |
max.pixel.size |
maximum pixel size |
min.pixel.size |
minimum pixel size |
angle |
value between 0 and 360 for degrees to rotate |
perm |
perm |
brightness |
the brightness of the new image in percentage, e.g. 120 |
index |
a named or unnamed list of indices for cropping/subsetting the |
dim of the first level of the ImageArray object
type of ImageArray object
length of ImageArray object
An ImageArray object
x[i: subset and crop
for ImageArray objects
x[[i: Layer access
for ImageArray objects
`[[`(x = ImageArray, i = numeric) <- value: Layer access
for ImageArray objects
dim(ImageArray): dimensions of an ImageArray
type(ImageArray): dimensions of an ImageArray
length(ImageArray): length of an ImageArray
ImageArray(): ImageArray constructor method
A function for creating objects of ImageArray class
realize(ImageArray): realize the array
as.raster(ImageArray): create a raster object
rotate(ImageArray): rotate image array to 90, 180, 270 degrees
aperm(ImageArray): permute image
negate(ImageArray): negate image
modulate(ImageArray): modulate image
flip(ImageArray): vertical flipping image
flop(ImageArray): horizontal flipping image
crop(ImageArray): cropping image
axes(ImageArray): get axes metadata of the ImageArray object
meta(ImageArray): get metadata of the ImageArray object
path(ImageArray): path of an ImageArray object
path(ImageArray) <- value: replace method for path(ImageArray)
# get image library(EBImage) img.file <- system.file("images", "sample.png", package="EBImage") # create ImageArray imgarray <- createImageArray(img.file, n.levels = 3) # access layers imgarray[[1]] imgarray[[2]] # dimensions and length dim(imgarray) length(imgarray) # manipulate images imgarray <- crop(imgarray, ind = list(100:200, 100:200)) imgarray <- crop(imgarray, ind = list(x = 10:20, y = 10:20)) imgarray <- rotate(imgarray, angle = 90) imgarray <- flip(imgarray) imgarray <- flop(imgarray) # create ImageArray on disk as HDF5 format dir.create(td <- tempfile()) output_h5 <- tempfile(fileext = ".h5") imgarray <- writeImageArray(img.file, output = output_h5, name = "image", verbose = FALSE) # as.raster imgarray_raster <- as.raster(imgarray) # realize imgarray <- realize(imgarray)# get image library(EBImage) img.file <- system.file("images", "sample.png", package="EBImage") # create ImageArray imgarray <- createImageArray(img.file, n.levels = 3) # access layers imgarray[[1]] imgarray[[2]] # dimensions and length dim(imgarray) length(imgarray) # manipulate images imgarray <- crop(imgarray, ind = list(100:200, 100:200)) imgarray <- crop(imgarray, ind = list(x = 10:20, y = 10:20)) imgarray <- rotate(imgarray, angle = 90) imgarray <- flip(imgarray) imgarray <- flop(imgarray) # create ImageArray on disk as HDF5 format dir.create(td <- tempfile()) output_h5 <- tempfile(fileext = ".h5") imgarray <- writeImageArray(img.file, output = output_h5, name = "image", verbose = FALSE) # as.raster imgarray_raster <- as.raster(imgarray) # realize imgarray <- realize(imgarray)
Writing image arrays on disk
writeImageArray( image, output = "my_image", name = "", format = NULL, replace = FALSE, n.levels = NULL, chunkdim = NULL, level = NULL, engine = "EBImage", verbose = FALSE, ... )writeImageArray( image, output = "my_image", name = "", format = NULL, replace = FALSE, n.levels = NULL, chunkdim = NULL, level = NULL, engine = "EBImage", verbose = FALSE, ... )
image |
an Image object (EBImage), a magick object or the path to an image file, |
output |
output file name |
name |
name of the group |
format |
on disk format, either "h5" for HDF5 format, "zarr" for zarr format, or "in-memory" for in-memory ImageArray object. If not provided, the format will be inferred from the file extension of the output path. |
replace |
Should the existing file be removed or not |
n.levels |
the number of levels if the image supposed to be pyramidal. |
chunkdim |
The dimensions of the chunks to use for writing the data to disk. |
level |
The compression level to use for writing the data to disk. |
engine |
the package to use for each image layer: either
|
verbose |
verbose |
... |
additional parameters passed to createImageArray. |
An ImageArray object
# get image library(EBImage) img.file <- system.file("images", "sample.png", package="EBImage") # create ImageArray dir.create(td <- tempfile()) output_h5 <- tempfile(fileext = ".h5") imgarray <- writeImageArray(img.file, output = output_h5, name = "image", verbose = FALSE) imgarray_raster <- as.raster(imgarray) plot(imgarray_raster)# get image library(EBImage) img.file <- system.file("images", "sample.png", package="EBImage") # create ImageArray dir.create(td <- tempfile()) output_h5 <- tempfile(fileext = ".h5") imgarray <- writeImageArray(img.file, output = output_h5, name = "image", verbose = FALSE) imgarray_raster <- as.raster(imgarray) plot(imgarray_raster)