【发布时间】:2018-11-22 20:31:15
【问题描述】:
我正在尝试从使用 greycomatrix 创建的 GLCM 中获取 texture properties,来自 skimage.feature。我的输入数据是具有多个波段的图像,我想要每个像素的纹理属性(生成尺寸为cols x rows x (properties *bands) 的图像),因为它可以使用 ENVI 来实现。但我对这个太陌生了,无法掌握greycomatrix 和greycoprops。这是我尝试过的:
import numpy as np
from skimage import io
from skimage.feature import greycomatrix, greycoprops
array = io.imread('MYFILE.tif')
array = array.astype(np.int64)
props = ['contrast', 'dissimilarity', 'homogeneity', 'energy', 'correlation', 'ASM']
textures = np.zeros((array.shape[0], array.shape[1], array.shape[2] * len(props)), np.float32)
angles = [0, np.pi / 4, np.pi / 2, 3 * np.pi / 4]
bands = array.shape[2]
for b in range(bands):
glcm = greycomatrix(array[:, :, b], [1], angles, np.nanmax(array) + 1,
symmetric=True, normed=True)
for p, prop in enumerate(props):
textures[:, :, b] = greycoprops(glcm, prop)
不幸的是,这给了我每个prop 的1 x 4 矩阵,我猜这是整个图像的每个角度的一个值,但这不是我想要的。我需要每个像素,例如每个像素的contrast,从其各自的环境计算。我错过了什么?
【问题讨论】:
标签: python image-processing feature-extraction scikit-image glcm