1

Matlab implementation of SIFT features were found from http://www.cs.ubc.ca/~lowe/keypoints/. with the help of stackoverflow. I want to save features to a .mat file. Features are roundness, color, no of white pixel count in the binary image and sift features. For the sift features I took descriptors in above code { [siftImage, descriptors, locs] = sift(filteredImg) } So my feature vector now is FeaturesTest = [roundness, nWhite, color, descriptors, outputs]; When saving this to .mat file using save('features.mat','Features'); it gives an error.
Error is like this.

??? Error using ==> horzcat CAT arguments dimensions are not consistent. Error in ==> user_interface>extract_features at 336 FeaturesTest = [roundness, nWhite, color, descriptors, outputs];

As I can understand, I think the issue is descriptor feature vector size. It is <14x128 double>. 14 rows are for this feature, where as for others only one row is in .mat file. How can I save this feature vector to the .mat file with my other features?

Awaiting for the reply. Thanks in advance.

xor
  • 2,668
  • 2
  • 28
  • 42

1 Answers1

2

From what I can understand, it looks like you are trying to put the variables roundness, nWhite, color, descriptors, and outputs into a single vector, and all the variables have unique dimensions.

Maybe it would be better to use a cell or a structure to store the data. To store the data in a cell, just change square brackets to curly braces, like so:

FeaturesTest = {roundness, nWhite, color, descriptors, outputs};

However, that would require you to remember which cells were which when you pulled the data back out of the .mat file. A structure may be more useful for you:

FeaturesTest.roundness = roundness;
FeaturesTest.nWhite = nWhite;
FeaturesTest.color = color;
FeaturesTest.descriptors = descriptors;
FeaturesTest.outputs = outputs;

Then, when you load the .mat file, all of the data will be contained in that structure, which you can easily reference. If you needed to look at just the color variable, you would type FeaturesTest.color, press enter, and the variable would be displayed. Alternatively, you could browse the structure by double clicking on it in the workspace window.

Alternatively, you could just use the save command like so:

save(filename,roundness, nWhite, color, descriptors, outputs)

Hope this helps.

whlteXbread
  • 411
  • 1
  • 4
  • 14
  • I saved features set using the method you mentioned above. FeaturesTest = {roundness, nWhite, color, descriptors, outputs}; Now my first 4 features are input to neural network and the 5th one is the target. I wrote like this. >> load('features.mat','FFeaturesTest'); A = FeaturesTest; P=A(:,1:4)'; T=A(:,5:5)'; >> rand('seed', 491218382); >> net = newff(minmax(P),T,20); Now the same error comes for input features... ??? Error using ==> horzcat CAT arguments dimensions are not consistent. Error in ==> minmax at 38 pr{i} = minmax([p{i,:}]); Do you have an idea of this please? – Nadeeshani Jayathilake Apr 06 '11 at 05:32
  • using FeaturesTest.color, it doesn't display the values. Instead it gives this error ??? Attempt to reference field of non-structure array. – Nadeeshani Jayathilake Apr 06 '11 at 05:52
  • I am not sure what format your functions need or what variable types your features are, but if, for example, you wanted to get the `roundness` variable back out of the cell array, you would use: `roundness = FeaturesTest{1}`. Take a look at MATLAB's documentation regarding cell arrays (pay attention to the difference between curly braces and parentheses!) and structures. If you have vectors of different sizes that MATLAB is trying to combine somewhere, you will get an error like the one you mentioned. For the second question, if `FeaturesTest` isn't actually a struct, you will get that error. – whlteXbread Apr 06 '11 at 18:27