Creating Feature vector in .mat file
2 次查看(过去 30 天)
显示 更早的评论
I wanted to create a feature vector for training dataset and wanted to store all feature as rows in the.mat file. The .mat file must be in the form
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165274/image.jpeg)
I am able to extract Feature of 1 image and store it in excel file or .mat file but not able to extract all image feature and store it in .mat file. Can anyone knows this?
4 个评论
dpb
2017-6-18
Don't expect folks to go somewhere else...post the info here or use stackoverflow, your choice.
Neha singh
2017-6-19
编辑:Neha singh
2017-6-19
Hi @KSSV, All the dimension of the images are same. So here is my sample code .
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/184898/image.jpeg)
I am able to get
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/184899/image.jpeg)
xpecting somthing to do like
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/184900/image.jpeg)
采纳的回答
dpb
2017-6-19
graycoprops returns a structure containing the requested statistics in fields of each name; hence you got what you requested in the .mat file.
To convert that structure to an array of contiguous features, use
features=struct2array(stats);
if all the features returned are commensurately-sized arrays (and I don't know if that is true or not; I don't have Image Processing TB to test). If not, you'd have to take the variously-shaped/sized arrays in the various structure names and convert them individually to linear vectors to concatenate by row.
In your code above, even when you're concatenating the structs into mydataGLCM, you've got the initialization of creating the empty container variable INSIDE the loop so you end up with only the last one as that throws away all the previous.
PS: Why do you continue to make it so difficult to try to help by pasting essentially nearly illegible images owing to their size plus one can't do anything with the code without typing everything in again. Copy and paste text and code so folks here have a chance (and then be sure to format it so it's legible using the {}Code button where needed.
7 个评论
更多回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!