Can't load dataset from .mat correctly?
2 次查看(过去 30 天)
显示 更早的评论
I have tried to follow this guide in the documentation: https://se.mathworks.com/help/vision/examples/object-detection-using-faster-r-cnn-deep-learning.html#d119e1400 I first load a folder with data locally and save it as .mat.
%%Load image folder and save as .mat
clear;
clc;
addpath(genpath(pwd));
dataFolder = '.../pathtofolder';
if ~isdir(dataFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s',
dataFolder);
uiwait(warndlg(errorMessage));
return;
end
filePattern = fullfile(dataFolder, '*.tif');
pngFiles = dir(filePattern);
result = cell(1,100);
for k = 1:length(pngFiles)
baseFileName = pngFiles(k).name;
fullFileName = fullfile(dataFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
imageArray= imread(fullFileName);
result{k} = imageArray;
end
save fasterRCNNtestImages.mat result;
And in another script after running the code above, I load it like so:
data = load('fasterRCNNtestImages.mat');
varoaDataset = data.fasterRCNNtestImages;
I have made the code as in the guide, but I seem to be misunderstanding something?
What I want to do is give a bunch of images as input and then "teach" it to search for some specific objects in the images. I could also do this by making a script that sorts objects in the images based on size, but I could not find a could source explaining how this can be done, and since my images are .png it appears to be a bit more tricky. I got the arror 2d image expected when I tried the other option any way and got stuck when I did not seem able to convert png. to another format (.jpg in my trial and error). So CNN seemed the better solution, but now I am stuck again.
2 个评论
KALYAN ACHARJYA
2017-12-29
Please clarify where you faced problem Load image from folder or save as .mat
采纳的回答
Rik
2017-12-29
In your code you save the mat file with this line
save fasterRCNNtestImages.mat result;
This creates a mat file with the result variable inside it. However, when you load it, you try to get the variable fasterRCNNtestImages from the file. That isn't what you saved, so it is not there. Using the code below should fix your error.
data = load('fasterRCNNtestImages.mat');
varoaDataset = data.result;
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Entering Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!