-1

I saw the next tutorial: https://www.mathworks.com/videos/object-recognition-deep-learning-and-machine-learning-for-computer-vision-121144.html.

At the Demo 2 was doing with deep learning a food detection. For this was use a .mat file. I want to use the code for road sign detection but I don't know how to create my .mat file. I have 25 images for input and I want to do a .mat file. I searched on Internet and I found the following code.

%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

But it isn't working because in the main program is useing the layer attributt. In my code for a .mat file I don't have the layer attribute.

Can anyone help me with a solution, please?enter image description here

1 Answers1

0

To create a mat file with certain variables from your workspace, you should be able to use:

save('matfilename','result');

The issue is whether you need to create a mat file for this particular example? You already have your images in 'result', do you really need to save them and then load them again?

Also, (hint!) check out ImageDatastore for easier reading in of your input files.

Johanna
  • 36
  • 1