read.pnm()-尝试读取pgm图像时出错 [英] read.pnm() - error trying to read pgm image

查看:301
本文介绍了read.pnm()-尝试读取pgm图像时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在R中读取pgm文件.我将wd设置为图像所在的位置,然后尝试读取它:

I'm trying to read a pgm file in R. I set my wd to where the image is and then simply try to read it:

   setwd("~/3 Diplomado/5 Multivariado/lfwcrop_grey/faces")

   library(pixmap)

    x <- read.pnm(system.file("Aaron_Guiel_0001.pgm", package="pixmap")[1])

但是出现以下错误:

if(ch ==#"){时出错:参数的长度为零 另外:警告消息: 在file(file,open ="rb")中: file(")仅支持open ="w +"和open ="w + b":使用前者

Error in if (ch == "#") { : argument is of length zero In addition: Warning message: In file(file, open = "rb") : file("") only supports open = "w+" and open = "w+b": using the former

不确定是什么.我认为它根本找不到图像. 我究竟做错了什么?有什么提示吗?谢谢你!

Not sure what it is. I think it simply doesnt find the image. What am I doing wrong? any hints? Thank you in advanced!

J.

推荐答案

只需尝试以下一项:

x=read.pnm(file = "Aaron_Guiel_0001.pgm")

system.file()用于查找软件包中包含的文件的完整路径.打包示例中使用了它,但是在读取自己的文件时不需要使用它.

The system.file() is used to find the full path of the files included in packages. It is used in the package example, but you don't need to use it while reading your own file.

这篇关于read.pnm()-尝试读取pgm图像时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆