简体   繁体   中英

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. however, the matrix i want is just much less number matrix like: 19*12 or something. so how can i do that in the 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中调整图像大小的回答。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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