【问题标题】:Creating gray-level co-occurrence matrix from 16-bit image从 16 位图像创建灰度共生矩阵
【发布时间】:2019-02-04 08:43:54
【问题描述】:

我有一个 16 位图像数据集,我想从中创建 GLCM 矩阵以提取 GLCM 特征。

但是,生成的矩阵显示一个值(如下图所示),我想知道为什么。

我尝试使用相同的图像但转换为 8 位,生成的 GLCM 显示多个值。

注意:我使用了以下 Matlab 函数:

glcm_matrix = graycomatrix(image.tif);

这是从 16 位图像中截取的样本:

注意:计算中使用的图像可以从here下载。原始图像的对比度非常低,看起来很暗。上面显示的图像的对比度已被拉伸,仅用于可视化目的。

编辑:

我用过

glcm_matrix = graycomatrix(image.tif, 'GrayLimits', []); 

它给了我以下结果:

【问题讨论】:

  • 如果调用 graycomatrix(image.tif, 'GrayLimits', []) 会发生什么?
  • 你能分享其中一张图片吗?
  • @Tapio 我尝试添加“GrayLimits”并且它有效,它给了我几个值

标签: matlab image-processing glcm


【解决方案1】:

这是一个分箱/缩放问题。

让我们看看里面:

edit graycomatrix

在这种情况下,我们对“NumLevels”和“GrayLimits”这两个选项感兴趣

%   'NumLevels'      An integer specifying the number of gray levels to use
%                    when scaling the grayscale values in I. For example,
%                    if 'NumLevels' is 8, GRAYCOMATRIX scales the values in
%                    I so they are integers between 1 and 8.  The number of
%                    gray levels determines the size of the gray-level
%                    co-occurrence matrix (GLCM).
%
%                    'NumLevels' must be an integer. 'NumLevels' must be 2
%                    if I is logical.
%  
%                    Default: 8 for numeric
%                             2 for logical
%
%   'GrayLimits'     A two-element vector, [LOW HIGH], that specifies how 
%                    the values in I are scaled into gray levels. If N is
%                    the number of gray levels (see parameter 'NumLevels')
%                    to use for scaling, the range [LOW HIGH] is divided
%                    into N equal width bins and values in a bin get mapped
%                    to a single gray level. Grayscale values less than or
%                    equal to LOW are scaled to 1. Grayscale values greater
%                    than or equal to HIGH are scaled to NumLevels. If
%                    'GrayLimits' is set to [], GRAYCOMATRIX uses the
%                    minimum and maximum grayscale values in I as limits,
%                    [min(I(:)) max(I(:))].

换句话说,该函数将您的数据分箱到 8x8 箱中,并假设缩放范围是完整的 uint16 范围 (0-65535)。但是,您提供的示例图像最小为 305,最大为 769,使其落入第一个 bin(0-8192 左右)。当我打电话给A = graycomatrix(I) 时,它给了我以下矩阵:

A =

    6600           0           0           0           0           0           0           0
       0           0           0           0           0           0           0           0
       0           0           0           0           0           0           0           0
       0           0           0           0           0           0           0           0
       0           0           0           0           0           0           0           0
       0           0           0           0           0           0           0           0
       0           0           0           0           0           0           0           0
       0           0           0           0           0           0           0           0

但是,当调用A = graycomatrix(I,'GrayLimits', []) 时,缩放范围取为 min(I) - max(I),并且函数按预期工作:

A =
       4           2           1           0           0           0           0           0
       1           1           2           2           0           0           0           0
       2           2           4           7           1           0           0           0
       0           1           7         142          72           1           0           0
       0           0           0          65        1711         252           0           0
       0           0           0           0         230        3055         178           0
       0           0           0           0           0         178         654           8
       0           0           0           0           0           0           8           9

在您的原始示例中,单个值很可能位于 8x8 矩阵的中间,因为您的原始图像是 int16 而不是 uint16,因此 graycomatrix 是对称的以考虑负值的可能性。

您当然也可以缩放原始图像以适合其数据类型。例如,如果您期望异常值等,百分位缩放可能是一个好主意。

【讨论】:

  • 非常感谢您的解释,通过缩放图像是指放大/缩小(调整大小)它们,还是更改比例范围?您能否详细说明缩放如何有助于拟合数据类型?另外,对于“NumLevels”和“GrayLimits”,如何选择合适的级别和范围?根据:researchgate.net/post/…。通过增加层数直到 GLCM 的熵开始线性增长。还是有更好的方法来选择级别,与比例范围值相同?
  • 更改比例范围。我喜欢 Tonechas 的想法,计算整个数据集的 min-max 应该使结果在图像之间保持可比性,而不是让 bin 跳来跳去。如果有更好的方法我不熟悉。
【解决方案2】:

我只想在@Tapio 的出色答案的基础上再接再厉。

当您在函数调用中使用名称/值对 GrayLimits', [] 时,graycomatrix 生成的 GLCM 看起来不错。但是,这种方法可能对您的应用程序无效。如果以这种方式计算一组图像的 GLCM,则对应于两个不同图像的两个不同 GLCM 的相同元素可能具有不同的含义。事实上,由于对每张图像的强度进行了不同的重新调整,GLCM 的组件实际上是在对从一张图像到另一张图像的不同共现进行编码。

为避免这种情况,您可以首先计算整个图像数据集的最小和最大强度(例如 minImgsmaxImgs),然后使用这些值重新调整构成数据集的所有图像的强度完全相同的方式:

glcm_matrix = graycomatrix(image_tif, 'GrayLimits', [minImgs maxImgs]); 

【讨论】:

  • 谢谢您,先生,您的来信!所以你建议使用整个数据集的最大和最小强度来概括提取的 GLCM 矩阵
  • 没错。通过这样做,分类准确性应该会得到提高。
  • 太棒了! 'NumLevels' 灰度级数呢,默认级别是 8,但我不确定是保持原样还是应该更改它。
  • 您可以尝试其他值并查看结果。如果您这样做,我建议您对所有图像数据集使用相同的NumLevels
猜你喜欢
  • 2015-06-29
  • 2017-08-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-01
  • 2020-05-15
  • 2017-07-31
相关资源
最近更新 更多