필터 지우기
필터 지우기

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

조회 수: 6 (최근 30일)
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.

채택된 답변

Stephen23
Stephen23 2019년 6월 5일
편집: Stephen23 2019년 6월 5일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Variables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by