R/utils.R

Defines functions convert_to_rgba

convert_to_rgba <- function(img) {

  if(dim(img)[4] == 1) {
    img <- imager::add.color(img, simple = FALSE)
  }

  if(dim(img)[4] == 3) {
    img2 <- imager::imfill(imager::width(img), imager::height(img), val = c(1, 1, 1, 1))
    img2[ , , , 1:3] <- img
    img <- img2
  }

  img
}
rdinnager/immosaic documentation built on July 2, 2023, 1:52 a.m.