美文网首页
R语言: 读入并展示图片

R语言: 读入并展示图片

作者: LET149 | 来源:发表于2023-07-13 09:32 被阅读0次

https://blog.csdn.net/weixin_45534890/article/details/108089035

1. 读入并展示PNG

读入图片:
readPNG(source=)
source= : 图片绝对路径和图片名

展示图片:
rasterImage(image=, xleft=, ybottom=, xright=, ytop=, angle=)

    1. image= : 读入图片后生成的图片数据
    1. xleft= : 图片左下角横坐标
    1. ybottom= : 图片左下角纵坐标
    1. xright= : 图片右上角横坐标
    1. ytop= : 图片右上角纵坐标
    1. angle= : 图片旋转角度
pp <- readPNG(source="/home/zhiyong/Pictures/14.png")  '#读入.png格式的图片,生成的变量是三维数组

r <- nrow(pp)/ncol(pp)  #计算图片的长宽比

plot(c(0,1),c(0,r),type = "n",asp=1)  #绘制坐标轴,示例一

rasterImage(pp,0,0,1,0.6, angle = 0)  #绘制图片,示例二
示例一
示例二

相关文章

网友评论

      本文标题:R语言: 读入并展示图片

      本文链接:https://www.haomeiwen.com/subject/vdmvaltx.html