MATLAB: How to save Extracted features as a matrix

image processing

Hello I have this code which I used to extract GLCM featues from a cell array . How can I save features as a matrix and not a cell array for easy classification using KNN?
here is my code:
glcm1 = graycomatrix(img1,'offset',offsets);
>> f1 = graycoprops(glcm1,{'all'});
glcm2 = graycomatrix(img2,'offset',offsets);
>> f2 = graycoprops(glcm2,{'all'});
features = {f1, f2}

Best Answer

features = [f1; f2]
However, what this will get you is a 2 x 1 struct array, since graycoprops returns a struct. Perhaps you might like
features = cell2mat([struct2cell(f1), struct2cell(f2)]);
but perhaps not. Since you used offsets, there is a possibility that each output has multiple values. You might want to
features = reshape(features,[],2).';
where the 2 is the number of different grayprops that you are putting together.
Related Question