2011-10-27 100 views
1


我有一张图片。我创建了共生矩阵(graycomatrix)提取不同的特性(对比度,相关性)等就可以了(graycoprops在矩阵中保存不同的'graycoprops'属性值[MATLAB]

x = [] 
for a lot of pictures, do the same: 
    imgB = imread('currentLoopImage.jpg') 

    contrast = graycoprops(graycomatrix(rgb2gray(imgB)), 'Contrast') 
    correlation = graycoprops(graycomatrix(rgb2gray(imgB)), 'Correlation') 
    energy = graycoprops(graycomatrix(rgb2gray(imgB)), 'Energy') 
    homogeneity = graycoprops(graycomatrix(rgb2gray(imgB)), 'Homogeneity') 

    x = [x;contrast;correlation;energy;homogeneity] 

的事情是,我需要节省的是矩阵X的所有值,但我出现以下错误:

CAT arguments are not consistent in structure field names.

,因为这是我的输出从各类型得到:

homogeneity = 

    Homogeneity: 0.8587 

有不同的类型,所以我不能SAV e他们在X矩阵上。
输出矩阵X,应该只保存数字,而忽略“的均匀性”

有人能告诉我是谁,我可以做到这一点?

回答

2

graycoprops()例如:

>> GLCM = [0 1 2 3;1 1 2 3;1 0 2 0;0 0 0 3]; 
>> stats = graycoprops(GLCM) 

stats = 

     Contrast: 2.8947 
    Correlation: 0.0783 
     Energy: 0.1191 
    Homogeneity: 0.5658 

然后,只需做:

>> x = struct2array(stats) 

ans = 

    2.8947 0.0783 0.1191 0.5658 

另外请注意,您可以包括所有的图像在mxnxp矩阵并一次处理它们,而不是使用for循环。例如:

>> GLCM(:,:,2) = GLCM; 
>> cell2mat(struct2cell(stats)) 

ans = 

    2.8947 2.8947 
    0.0783 0.0783 
    0.1191 0.1191 
    0.5658 0.5658