Problem with cell2mat "Cannot support cell arrays containing cell arrays or objects."

I am trying to run a pseudocode, which needs to run on a complete dataset of images. Name of the dataset is MICC-F220. The path of the dataset is 'C:\Users\parminder\Downloads\sift-forensic-master\sift-forensic-master\dataset'. I have following lines to process each image of the dataset.
% RUN EXPERIMENT
tstart = tic;
% dataset
DB = 'MICC-F220';
db_dir ='C:\Users\parminder\Downloads\sift-forensic-master\sift-forensic-master\dataset';
file_ground_truth = 'groundtruthDB_220.txt';
% parameters
metric = 'ward';
th = 2.2;
min_pts = 4;
% load ground truth from a file
[ImageName, GT] = textread(fullfile(db_dir,DB,file_ground_truth), '%s %d');
num_images = size(ImageName,1);
fid_gt = fopen(fullfile(db_dir,DB,file_ground_truth));
C = textscan(fid_gt, '%s %u');
fclose(fid_gt);
TP = 0; % True Positive
TN = 0; % True Negative
FP = 0; % False Positive
FN = 0; % False Negative
for i = 1:num_images
%parfor i = 1:num_images % use for parallel computation (needs matlabpool)
loc_file = fullfile(db_dir,DB,cell2mat(ImageName(i)));
name = cell2mat(ImageName(i));
% process an image
fprintf('Processing: %s (%d/%d)\n',loc_file,i,num_images);
countTrasfGeom = process_image(loc_file, metric, th, min_pts, 0);
......and so on
I am getting the following error
>>run_F220_experiment
Error using cell2mat (line 53)
Cannot support cell arrays containing cell arrays or objects.
Error in run_F220_experiment (line 30)
loc_file = fullfile(db_dir,DB,cell2mat(ImageName(i)));
How can i resolve it.

 Réponse acceptée

Image Analyst
Image Analyst le 2 Mai 2015
Modifié(e) : Image Analyst le 2 Mai 2015
Maybe ImageName is already a string and you don't need cell2mat. Or maybe you can do char(ImageName{i}) or ImageName{i} (braces instead of parentheses). See the FAQ: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F.

3 commentaires

Thank you image analyst Error resolves using 'ImageName{i}'.
hey..could you solve your problem of running this code ? @harpreet
Apparently so, since he accepted my proposed solution.

Connectez-vous pour commenter.

Plus de réponses (1)

It is complaining that ImageName(i) does not contain a data type that cell2mat can handle. Check the content of ImageName{i} and re-evaluate whether cell2mat is the appropriate tool.

Catégories

Produits

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by