Azzera filtri
Azzera filtri

Conversion to logical from struct is not possible. (It's a binary matrix!)

6 visualizzazioni (ultimi 30 giorni)
myFolder = '/MATLAB Drive/saliency/code_forMetrics/dataset/test';
filePattern1 = fullfile(myFolder,'saliency', '*.jpg');
filePattern2 = fullfile(myFolder,'fixation_b', '*.mat');
imgFiles = dir(filePattern1);
fixFiles = dir(filePattern2);
for k = 1:length(imgFiles)
baseFileName1 = imgFiles(k).name;
fullFileName1 = fullfile(myFolder,'saliency', baseFileName1);
baseFileName2 = fixFiles(k).name;
fullFileName2 = fullfile(myFolder,'fixation_b', baseFileName2);
img{k} = imread(fullFileName1);
fix{k} = load(fullFileName2);
score{k} = NSS(img{k}, fix{k});
end
Output:
test_0_bfix
Error using logical
Conversion to logical from struct is not possible.
Error in NSS (line 16)
score = mean(map(logical(fixationMap)));
Error in test_0_bfix (line 14)
score{k} = NSS(img{k}, fix{k});
Since the problem doesn't seem to appear before,is this the version problem?
fixation.mat suppose to be a binary matrix
Besides,as a newbee in ML,i would like to ask how to calculate the mean of score since it's a cell.
I'd appreciate for your help.

Risposta accettata

Stephen23
Stephen23 il 5 Giu 2019
Modificato: Stephen23 il 5 Giu 2019
As the load documentation clearly states, if the file is a .mat file then the output of load is a scalar structure, whos fields are the variables that were saved in the .mat file. So you will need to refer to the field of that structure:
S = load(...);
F{k} = S.whateverFieldNameYourDataHas;
If there is only one variable per file and you do not know its name, then you could do this:
S = load(...);
C = struct2cell(S);
F{k} = C{1};
Note that naming a variable fix is not a good idea, as this shadows the inbuilt fix function.

Più risposte (0)

Categorie

Scopri di più su Variables in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by