MATLAB: How to convert ‘Structure’ ?!

featuresImage Processing Toolboxnumbersstructures

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

Best Answer

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.