Borrar filtros
Borrar filtros

Can't load dataset from .mat correctly?

5 visualizaciones (últimos 30 días)
Maria Rasmussen
Maria Rasmussen el 29 de Dic. de 2017
Comentada: Maria Rasmussen el 29 de Dic. de 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 comentarios
KALYAN ACHARJYA
KALYAN ACHARJYA el 29 de Dic. de 2017
Please clarify where you faced problem Load image from folder or save as .mat
Maria Rasmussen
Maria Rasmussen el 29 de Dic. de 2017
Loading the .mat

Iniciar sesión para comentar.

Respuesta aceptada

Rik
Rik el 29 de Dic. de 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;

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by