简体   繁体   English

在 R 中打开 .jpg 文件:如果文件位于 R 包中,您只能打开 JPEG 文件吗?

[英]Opening .jpg files in R: can you only open JPEG files if the file lies in an R packages?

I noticed that if you are trying to use "system.file()" to source the image for "readJPEG()", then you have to include a package name in order to open the image.我注意到如果您尝试使用“system.file()”来获取“readJPEG()”的图像,那么您必须包含一个包名才能打开图像。 But what if I wanted to open a .jpg file from say, my pictures folder?但是,如果我想从我的图片文件夹中打开 .jpg 文件怎么办? Is this possible?这可能吗? Is R only able to open images using system.file() to source .jpg files? R 是否只能使用 system.file() 打开图像以获取 .jpg 文件?

install jpeg library and load it and then call readJPEG function with the .jpg file.安装jpeg库并加载它,然后使用 .jpg 文件调用readJPEG函数。

library('jpeg')
myjpeg_array <- jpeg::readJPEG(source = "myjpeg.jpg")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM