I might add more info in the coming weeks but filing this here before I forget.
Initially reported by @sara-bz, with some extra info based on our follow up discussion:
SpatialExperiment contains a imgData slot that contains the image stored as the SpatialImage virtual class.
It could be nice to increase the interoperability with other Bioconductor packages, such as EBImage, by providing an easy way to apply EBImage functions to the SpatialImage objects.
The easiest way to achieve this is probably by providing a method to convert SpatialImage objects from SpatialExperiment into Image objects from EBImage.
In practice, it will likely be necessary to write separate methods for each subclass of SpatialImage:
suppressPackageStartupMessages(library(SpatialExperiment))
example(read10xVisium, echo = FALSE)
#> Warning in read10xVisium(samples, sample_ids, type = "sparse", data = "raw", : 'read10xVisium' is deprecated.
#> Use 'VisiumIO::TENxVisium(List)' instead.
#> See help("Deprecated")
#> Warning in read10xVisium(samples2, sample_ids, type = "sparse", data = "raw", : 'read10xVisium' is deprecated.
#> Use 'VisiumIO::TENxVisium(List)' instead.
#> See help("Deprecated")
img <- getImg(spe)
class(img)
#> [1] "StoredSpatialImage"
#> attr(,"package")
#> [1] "SpatialExperiment"
plot(imgRaster(spe))

rgb_img <- img |>
imgRaster() |>
grDevices::col2rgb() |>
t()
ebimage_img <- array(rgb_img / 256, dim = c(rev(dim(img)), 3)) |>
EBImage::Image(colormode = "Color")
plot(ebimage_img)

Created on 2026-03-20 with reprex v2.1.1
I might add more info in the coming weeks but filing this here before I forget.
Initially reported by @sara-bz, with some extra info based on our follow up discussion:
SpatialExperiment contains a
imgDataslot that contains the image stored as theSpatialImagevirtual class.It could be nice to increase the interoperability with other Bioconductor packages, such as EBImage, by providing an easy way to apply EBImage functions to the
SpatialImageobjects.The easiest way to achieve this is probably by providing a method to convert
SpatialImageobjects from SpatialExperiment intoImageobjects from EBImage.In practice, it will likely be necessary to write separate methods for each subclass of
SpatialImage:LoadedSpatialImage:Created on 2026-03-20 with reprex v2.1.1