【问题标题】:Saving different 'graycoprops' properties values on a matrix [MATLAB]在矩阵上保存不同的 'graycoprops' 属性值 [MATLAB]
【发布时间】:2011-10-27 19:34:38
【问题描述】:


我有一张照片。我创建了共现矩阵(graycomatrix)来提取不同的属性(对比度、相关性)等(graycoprops

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 参数在结构字段名称中不一致。

因为这是我从每种类型得到的输出:

homogeneity = 

    Homogeneity: 0.8587

有不同的类型,所以我无法将它们保存在 X 矩阵上。
输出矩阵 X,应该只保存数字,而忽略“同质性”

谁能告诉我谁能做到这一点?

【问题讨论】:

    标签: matlab image-processing matrix glcm


    【解决方案1】:

    来自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
    

    还请注意,您可以将所有图像包含在一个 m x n x p 矩阵中并一次处理它们,而不是使用 for 循环。例如:

    >> GLCM(:,:,2) = GLCM;
    >> cell2mat(struct2cell(stats))
    
    ans =
    
        2.8947    2.8947
        0.0783    0.0783
        0.1191    0.1191
        0.5658    0.5658
    

    【讨论】:

      猜你喜欢
      • 2015-04-20
      • 2013-11-13
      • 1970-01-01
      • 2018-12-02
      • 1970-01-01
      • 2016-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多