【问题标题】:Displaying images in R in version 3.1.0在 3.1.0 版本的 R 中显示图像
【发布时间】:2014-05-25 23:45:23
【问题描述】:

我遇到过类似 this one 的旧 stackoverflow 帖子,这些帖子使用了 ReadImages 和 biOps 等包,这些包现在在 R 3.1.0 中已弃用,不再可用。

谁能告诉我如何在 R 3.1.0 中显示图像? (特别是 jpeg 和 png 图像)

【问题讨论】:

    标签: r image


    【解决方案1】:

    正如 Simon Urbanek 在the comments of the linked question 中指出的那样,您可以这样做:

    library("jpeg")
    jj <- readJPEG("myfile.jpg",native=TRUE)
    plot(0:1,0:1,type="n",ann=FALSE,axes=FALSE)
    rasterImage(jj,0,0,1,1)
    

    或(对于 PNG)

    library("png")
    pp <- readPNG("myfile.png")
    plot.new() 
    rasterImage(pp,0,0,1,1)
    

    png 的 0.1.7 版,jpeg 的 0.1.8 版

    【讨论】:

      【解决方案2】:

      imager 包可以加载 png、jpeg 和 bmp 图像。

      library(imager)
      im<-load.image("myimage")
      plot(im)
      

      它还具有许多用于处理和绘图的功能。通过安装额外的库(ffmpeg 和 ImageMagick),它甚至可以加载视频和其他图像格式。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-10-03
        • 1970-01-01
        • 2020-12-29
        • 2015-11-22
        • 2017-10-19
        • 2016-05-01
        相关资源
        最近更新 更多