| Title: | ImageArray: 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 either HDF5 files or Zarr stores. |
| 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: | 0.99.6 |
| Built: | 2026-06-01 09:55:40 UTC |
| Source: | https://github.com/Artur-man/ImageArray |
as.raster method for ImageArray object
## S4 method for signature 'ImageArray' as.raster(x, level = NULL, max.pixel.size = NULL, min.pixel.size = NULL)## S4 method for signature 'ImageArray' as.raster(x, level = NULL, max.pixel.size = NULL, min.pixel.size = NULL)
x |
an ImageArray object |
level |
level |
max.pixel.size |
maximum pixel size |
min.pixel.size |
minimum pixel size |
A raster array
# get image library(EBImage) img.file <- system.file("images", "sample.png", package="EBImage") # create ImageArray dir.create(td <- tempfile()) output_h5ad <- file.path(td, "h5test") imgarray <- writeImageArray(img.file, output = output_h5ad, name = "image", format = "HDF5ImageArray", replace = TRUE, verbose = FALSE) imgarray_raster <- as.raster(imgarray)# get image library(EBImage) img.file <- system.file("images", "sample.png", package="EBImage") # create ImageArray dir.create(td <- tempfile()) output_h5ad <- file.path(td, "h5test") imgarray <- writeImageArray(img.file, output = output_h5ad, name = "image", format = "HDF5ImageArray", replace = TRUE, verbose = FALSE) imgarray_raster <- as.raster(imgarray)
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)
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_h5ad <- file.path(td, "h5test") imgarray <- writeImageArray(img.file, output = output_h5ad, name = "image", format = "HDF5ImageArray", replace = TRUE, 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_h5ad <- file.path(td, "h5test") imgarray <- writeImageArray(img.file, output = output_h5ad, name = "image", format = "HDF5ImageArray", replace = TRUE, 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,numeric,numeric,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' rotate(object, degrees) ## 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(object) ## S4 method for signature 'ImageArray' flop(object) ## S4 method for signature 'ImageArray' crop(object, ind) ## S4 method for signature 'ImageArray' axes(object)## S4 method for signature 'ImageArray,numeric,numeric,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' rotate(object, degrees) ## 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(object) ## S4 method for signature 'ImageArray' flop(object) ## S4 method for signature 'ImageArray' crop(object, ind) ## S4 method for signature 'ImageArray' axes(object)
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 |
degrees |
value between 0 and 360 for how many degrees to rotate |
perm |
perm |
brightness |
the brightness of the new image in percentage, e.g. 120 |
ind |
index list |
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
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
# 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 <- rotate(imgarray, degrees = 90) imgarray <- flip(imgarray) imgarray <- flop(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 <- rotate(imgarray, degrees = 90) imgarray <- flip(imgarray) imgarray <- flop(imgarray)
path of ImageArray image
## S4 method for signature 'ImageArray' path(object)## S4 method for signature 'ImageArray' path(object)
object |
an ImageArray object |
the path to ImageArray object store
path of ImageArray image
## S4 replacement method for signature 'ImageArray' path(object) <- value## S4 replacement method for signature 'ImageArray' path(object) <- value
object |
an ImageArray object |
value |
the new path |
does not return a value, updates the path of the ImageArray object
as.array method for ImageArray object
## S4 method for signature 'ImageArray' realize(x, level = NULL, max.pixel.size = NULL, min.pixel.size = NULL)## S4 method for signature 'ImageArray' realize(x, level = NULL, max.pixel.size = NULL, min.pixel.size = NULL)
x |
an ImageArray object |
level |
level |
max.pixel.size |
maximum pixel size |
min.pixel.size |
minimum pixel size |
An array object
# get image library(EBImage) img.file <- system.file("images", "sample.png", package="EBImage") # create ImageArray dir.create(td <- tempfile()) output_h5ad <- file.path(td, "h5test") imgarray <- writeImageArray(img.file, output = output_h5ad, name = "image", format = "HDF5ImageArray", replace = TRUE, verbose = FALSE) imgarray <- realize(imgarray)# get image library(EBImage) img.file <- system.file("images", "sample.png", package="EBImage") # create ImageArray dir.create(td <- tempfile()) output_h5ad <- file.path(td, "h5test") imgarray <- writeImageArray(img.file, output = output_h5ad, name = "image", format = "HDF5ImageArray", replace = TRUE, verbose = FALSE) imgarray <- realize(imgarray)
Writing image arrays on disk
writeImageArray( image, output = "my_image", name = "", format = c("InMemoryImageArray", "HDF5ImageArray", "ZarrImageArray"), replace = FALSE, n.levels = NULL, chunkdim = NULL, level = NULL, engine = "EBImage", verbose = FALSE, ... )writeImageArray( image, output = "my_image", name = "", format = c("InMemoryImageArray", "HDF5ImageArray", "ZarrImageArray"), replace = FALSE, n.levels = NULL, chunkdim = NULL, level = NULL, engine = "EBImage", verbose = FALSE, ... )
image |
image |
output |
output file name |
name |
name of the group |
format |
on disk format |
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_h5ad <- file.path(td, "h5test") imgarray <- writeImageArray(img.file, output = output_h5ad, name = "image", format = "HDF5ImageArray", replace = TRUE, 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_h5ad <- file.path(td, "h5test") imgarray <- writeImageArray(img.file, output = output_h5ad, name = "image", format = "HDF5ImageArray", replace = TRUE, verbose = FALSE) imgarray_raster <- as.raster(imgarray) plot(imgarray_raster)
get information of an ImgArray object
zarrcreateGroup(store, name) open_zarr(dir, name)zarrcreateGroup(store, name) open_zarr(dir, name)
store |
the location of (zarr) store |
name |
name of the zarr store or group |
dir |
directory/location of zarr store |
does not return anything, creates a zarr group in the store instead
does not return anything, opens a zarr store instead
zarrcreateGroup(): create zarr group
open_zarr(): open zarr stores
# zarr store path dir.create(td <- tempfile()) zarr_name <- "test.zarr" output_zarr <- file.path(td, zarr_name) # open zarr store open_zarr(dir = td, name = zarr_name) # create group zarrcreateGroup(store = output_zarr, name = "sample")# zarr store path dir.create(td <- tempfile()) zarr_name <- "test.zarr" output_zarr <- file.path(td, zarr_name) # open zarr store open_zarr(dir = td, name = zarr_name) # create group zarrcreateGroup(store = output_zarr, name = "sample")