How to convert 'Structure' ?!
1 回表示 (過去 30 日間)
古いコメントを表示
Hi everybody;
I am trying to get feature value out of structure array..
for example:
glcms = graycomatrix(CG,'Offset',[0 1]);
Cont_RGB = graycoprops(glcms,'Contrast');
F=Cont_RGB;
F= Contrast: 0.2546 % i wana to remove word contrast and get the number only!
How can i get the number?
Thank you
0 件のコメント
採用された回答
Walter Roberson
2013 年 6 月 30 日
If your
Cont_RGB = graycoprops(glcms,'Contrast');
is returning a Cont_RGB which is a structure array, and you want to extract the field named "Contrast" from the first member of that structure array, you would use
Cont_RGB(1).Contrast
and in the cast where the structure array only has a single member (so Cont_RGB(2) does not exist) then you can abbreviate that to
Cont_RGB.Contrast
In the above, the period is part of the syntax.
If Cont_RGB is a structure array, so Cont_RGB(2).Contrast and so on exist, and you are trying to get a vector equivalent to
[Cont_RGB(1).Contrast Cont_RGB(2).Contrast Cont_RGB(3).Contrast ....]
then use
[Cont_RGB.Contrast]
In this, the [] and the period are part of the syntax.
その他の回答 (2 件)
Matthew Eicholtz
2013 年 6 月 29 日
Try
F.Contrast
2 件のコメント
Walter Roberson
2013 年 6 月 30 日
Cont_RGB = graycoprops(glcms,'Contrast');
Cont_RGB.Contrast
The "." between the variable name and "Contrast" is literal, part of the syntax.
Image Analyst
2013 年 6 月 29 日
theNumber = F.Contrast;
3 件のコメント
Image Analyst
2013 年 6 月 30 日
All 3 people answered with the same thing, and you accepted the third response, so I think we all knew what you meant. Hopefully you're now using Walter's answer, and are not doing unnecessary operations like converting to a cell array and then converting the cell array to a matrix. You may find it helpful to read the FAQ: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!