问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/5556736/how-to-save-sift-feature-vector-for-classification-using-neural-network