[英]How can I fit a folder of images into one matrix in R?
I have a folder of letter images.我有一个字母图像文件夹。 it contains 182 image, each image can be represented in a 12 by 12 matrix.
它包含 182 张图像,每张图像都可以用 12 x 12 的矩阵表示。 I'm performing a fuzzy c means algorithm.
我正在执行模糊 c 均值算法。 I want to create a loop to fit all images into one matrix or create a loop to fit each image into one matrix.
我想创建一个循环来将所有图像放入一个矩阵中,或者创建一个循环来将每个图像放入一个矩阵中。 what is the most easy way to do it ?!
最简单的方法是什么?!
If get_mat() is your function to convert image to matrix.如果 get_mat() 是您将图像转换为矩阵的函数。 For fit each image in an individual matrix
将每个图像拟合到一个单独的矩阵中
## Set working directory to where images are located
setwd("folder location")
## List files
img_list <- list.files()
## Read files into a list of matrix
img_mat_list <- lapply(img_list,get_mat())
## To join all those matrix rowbind or columnbind
do.call(rbind,img_mat_list)
do.call(cbind,img_mat_list)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.