[R] converting image formats
Vivek Sutradhara
v|vek@utr@ @end|ng |rom gm@||@com
Wed Mar 24 19:05:08 CET 2021
Hi,
I have made a few corrections to my previous message in the naming of my
objects.
I would like to have help in converting from one image format to another
(between the packages EBImage, magick and imager). The magick package has
functions for this. But the EBImage and imager packages do not have
in-built functions for the conversion. It is, of course, possible to save
the images and then open with the other packages. But I am looking for more
direct options. I do not know how to assign data to the "slots" in the
functions.
### convert image formats
library(magick)
nuc_MAG_o <- image_read(system.file("images", "nuclei.tif",
package="EBImage"))
nuc_MAG_to_EB <- as_EBImage(nuc_MAG_o)
nuc_MAG_to_IMG <- magick2cimg(nuc_MAG_o,alpha="flatten")
# convert from EBImage
library(EBImage)
nuc_EB_o <- readImage(system.file("images", "nuclei.tif",
package="EBImage"))
writeImage(nucEBo, "C:/Rfiles/nuclei-3.jpg")
# to convert nuc_EB_o
nucEB_to_IMG <-
nucEB_to_MAG <-
#convert from imager
library(imager)
nuc_IMG_o <- load.image("C:/Rfiles/nuclei-3.jpg")
# to convert nuc_IMG_o
nuc_IMG_to_EB <-
nuc_IMG_to_MAG <-
Thanks,
Vivek
Den ons 24 mars 2021 kl 18:54 skrev Vivek Sutradhara <viveksutra using gmail.com>:
> Hi,
> I would like to have help in converting from one image format to another
> (between the packages EBImage, magick and imager). The magick package has
> functions for this. But the EBImage and imager packages do not have
> in-built functions for the conversion. It is, of course, possible to save
> the images and then open with the other packages. But I am looking for more
> direct options. I do not know how to assign data to the "slots" in the
> functions.
>
> ### convert image formats
> library(magick)
> nuc_MAG_o <- image_read(system.file("images", "nuclei.tif",
> package="EBImage"))
> nuc_MAG_to_EB <- as_EBImage(manMAG)
> nuc_MAG_to_IMG <- magick2cimg(manMAG,alpha="flatten")
>
> # convert from EBImage
> library(EBImage)
> nucEBo <- readImage(system.file("images", "nuclei.tif",
> package="EBImage"))
> writeImage(nucEBo, "C:/Rfiles/nuclei-3.jpg")
> nucEB_to_IMG <-
> nucEB_to_MAG <-
>
> #convert from imager
> library(imager)
> nuc_IMG_o <- load.image("C:/Rfiles/nuclei-3.jpg")
> nuc_IMG_to_EB <-
> nuc_IMG_to_MAG <-
>
> All help is appreciated.
> Thanks,
> Vivek
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list