Can't load dataset from .mat correctly?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Maria Rasmussen
le 29 Déc 2017
Commenté : Maria Rasmussen
le 29 Déc 2017
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 commentaires
KALYAN ACHARJYA
le 29 Déc 2017
Please clarify where you faced problem Load image from folder or save as .mat
Réponse acceptée
Rik
le 29 Déc 2017
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!