创建一个mat文件[重复]

问题描述 投票:-1回答:1

这个问题在这里已有答案:

我看到了下一个教程:https://www.mathworks.com/videos/object-recognition-deep-learning-and-machine-learning-for-computer-vision-121144.html

在演示2中,我正在深入学习食物检测。为此,使用.mat文件。我想使用代码进行道路标志检测,但我不知道如何创建我的.mat文件。我有25个图像用于输入,我想做一个.mat文件。我在互联网上搜索,我发现了以下代码。

%Generate mat file
srcFile = dir('..\ROAD-SIGN\*.jpg')
result = cell(1,length(srcFile))
for i = 1 : length(srcFile)
    filename = strcat('...\ROAD-SIGN\',srcFile(i).name)
    I = imread(filename);
    %figure, imshow(I);
    I = imresize(I,[273 273]);
    result{i} = I;  
    %figure, imshow(result{i});
end
save images1.mat, result;
length(srcFile)
load('images1.mat')
for j = 1:length(srcFile)
    figure, imshow(result{j});
end
%Read mat file 
for j =1 :length(srcFile)
    filename = strcat('...\ROAD-SIGN\',srcFile(j).name);
    I = imread(filename);
    a='I';
    input = load('images1.mat',a);
    figure, imshow(input.(a));
end
whos -file images1.mat

但它不起作用,因为在主程序中使用的是图层属性。在我的.mat文件的代码中,我没有layer属性。

任何人都可以帮我解决问题吗?enter image description here

matlab mat
1个回答
0
投票

要从工作区创建包含某些变量的mat文件,您应该能够使用:

save('matfilename','result');

问题是您是否需要为此特定示例创建mat文件?您已经在'结果'中显示了图像,是否真的需要保存它们然后再次加载它们?

另外,(提示!)查看ImageDatastore以便于阅读输入文件。

© www.soinside.com 2019 - 2024. All rights reserved.