how to fix Cell contents assignment to a non-cell array object.?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
hallo I'm trying to create a 2D by N dimentions pictures features array to save code running time so i created the next code:
SurfFeatures = {};
folderlisting = dir('C:\Documents\');
for item=3:1:numel(folderlisting)
name = folderlisting(item).name;
Fname = strcat('C:\Documents\',name);
comperimg = imread(Fname);
comperimg = comperimg(:,:,1:3);
I = rgb2gray(comperimg);
points = detectSURFFeatures(I);
[features,valid_points] = extractFeatures(I,points);
SurfFeatures{item-2} = features;
end
save('SurfFeatures.mat','SurfFeatures');
I keep getting the next error right after the code enters the part of the feature assignment "Cell contents assignment to a non-cell array object."
happy for help :) .
3 Kommentare
OCDER
am 20 Okt. 2017
Bearbeitet: OCDER
am 20 Okt. 2017
I don't see anything wrong, but perhaps the error is in extractFeatures or detectSURFFeatures. Here are some tips to improve the code though.
FolderList = dir(fullfile('C:\Documents\', '*.jpg')); %Use file extensions since dir will also return "." and ".." folders, + other files
SurfFeatures = cell(1, numel(FolderList) - 2); %Preallocate for speed
for item = 3:numel(FolderList)
%name = FolderList(item).name; %Uppercase notation. Also, this isn't needed.
%Fname = strcat('C:\Documents\',name); %fullfile is better
%comperimg = imread(Fname);
%comperimg = comperimg(:,:,1:3); %squeeze will remove singleton dimension
Fname = fullfile('C:\Documents\',FolderList(item).name);
I = squeeze(imread(Fname));
I = rgb2gray(I);
Points = detectSURFFeatures(I);
[Features, ValidPoints] = extractFeatures(I, Points);
SurfFeatures{item-2} = Features;
end
save('SurfFeatures.mat','SurfFeatures');
Be consistent when using camelcase notation to help you determine what is a function vs variable. I noticed a partial implementation, which can get confusing later (ex: valid_points vs ValidPoints). Using uppercase is generally good for variables, to prevent overriding a matlab function by accident. You're function naming scheme is fine
Antworten (0)
Siehe auch
Kategorien
Mehr zu Computer Vision with Simulink finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!