Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 我有6000个字符的图像。我想创建一个包含所有图像的数组_Matlab - Fatal编程技术网

Matlab 我有6000个字符的图像。我想创建一个包含所有图像的数组

Matlab 我有6000个字符的图像。我想创建一个包含所有图像的数组,matlab,Matlab,我想创建一个mat文件。通过它我可以训练我的OCR神经网络。我有6200个大小为30*30的图像。如何创建一个包含所有图像的数组。大小将为6200*30*30,然后希望将图像展开为6200*900。plz帮助 目前,我可以读取文件,但无法处理我的操作。代码如下: for ii=1:6000 data(ii,:,:)=imread('yourfilename_ii.png'); %//this only works if they are FOR SURE 30x30 all end %

我想创建一个mat文件。通过它我可以训练我的OCR神经网络。我有6200个大小为30*30的图像。如何创建一个包含所有图像的数组。大小将为6200*30*30,然后希望将图像展开为6200*900。plz帮助
目前,我可以读取文件,但无法处理我的操作。代码如下:

for ii=1:6000
    data(ii,:,:)=imread('yourfilename_ii.png'); %//this only works if they are FOR SURE 30x30 all
end

% Now reshape!
data=reshape(data,[6000,30*30]);

代码将类似于:

for ii=1:6000
    data(ii,:,:)=imread('yourfilename_ii.png'); %//this only works if they are FOR SURE 30x30 all
end

% Now reshape!
data=reshape(data,[6000,30*30]);

我假设您在当前的工作文件夹中有某种格式的图像,并且所有图像都具有相同的维度

另外,我假设您对黑白图像感兴趣(否则您必须考虑RGB场的三维)

如果是这样,您只需读取它们并将其存储在阵列中:

首先以某种方式创建一个包含文件名的单元格:

fileName = {'image1.png';'image2.png'};
为图像矩阵分配空间:

h=30; w=30;
imagesArray = zeros(length(fileName),h,w);
按顺序读取图像并将其存储在空矩阵中:

for n=1:length(fileName)
    imagesArray(n,:,:) = imread(fileName{n});
end
最后展开:

unroll = reshape(imagesArray,length(fileName),h*w);

我假设您在当前的工作文件夹中有某种格式的图像,并且所有图像都具有相同的维度

另外,我假设您对黑白图像感兴趣(否则您必须考虑RGB场的三维)

如果是这样,您只需读取它们并将其存储在阵列中:

首先以某种方式创建一个包含文件名的单元格:

fileName = {'image1.png';'image2.png'};
为图像矩阵分配空间:

h=30; w=30;
imagesArray = zeros(length(fileName),h,w);
按顺序读取图像并将其存储在空矩阵中:

for n=1:length(fileName)
    imagesArray(n,:,:) = imread(fileName{n});
end
最后展开:

unroll = reshape(imagesArray,length(fileName),h*w);

您还可以使用
dir('folder/*.png')
在文件夹中找到所有
png
图像。这将返回一个结构,其中包含每个文件的一些信息,包括其名称。您还可以使用
dir('folder/*.png')
在文件夹中查找所有
png
图像。这将返回一个结构,其中包含每个文件的一些信息,包括其名称。yaa这适用于Biguri先生…你能建议我如何做同样的事情,如果我有可变的图像大小(即一个图像有20*20,其他30*30)yaa这适用于Biguri先生…你能建议我如何做同样的事情,如果我有可变的图像大小吗(即一幅图像为20*20,另一幅图像为30*30)