简体   繁体   English

如何在R中将图像转换为数值(0-1)像素矩阵

[英]how to convert image to numerical (0-1) pixel matrix in R

i found the code to convert the image and got 480*288 numbers of data, because the pixel of the image is that. 我找到了转换图像的代码,并得到480 * 288的数据,因为图像的像素就是那个。 however, the matrix i want is just much less number matrix like: 19*12 or something. 但是,我想要的矩阵要少得多:19 * 12之类的数字。 so how can i do that in the R? 那我该如何在R中做到这一点呢? thanks a lot!. 非常感谢!。

library("EBImage")
img <- readImage("sample.jpg")
img <- channel(img, "grey")
write.csv(t(img), "sample.csv", row.names=FALSE)

为了减小所得矩阵的大小,您需要先使用resize来缩放图像,然后再将其保存到.csv文件中,请参阅我对R中调整图像大小的回答。

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

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