我正在尝试在趋势减少的数字高程模型上生成 glcm。我目前的问题是 skimage.feature.greycomatrix(image) 的输出仅包含矩阵的对角线条目中的值。
glcm = greycomatrix(image,distances=[1],levels=100,angles=[0] ,symmetric=True,normed=True)
使用以下代码先对图像进行量化:
import numpy as np
from skimage.feature import greycomatrix
def quantize(raster):
print("\n Quantizing \n")
raster += (np.abs(np.min(raster)) + 1)
mean = np.nanmean(raster.raster[raster.raster > 0])
std = np.nanstd(raster.raster[raster.raster > 0])
raster[raster == None] = 0 # set all None values to 0
raster[np.isnan(raster)] = 0
raster[raster > (mean + 1.5*std)] = 0
raster[raster < (mean - 1.5*std)] = 0 # High pass filter
raster[raster > 0] = raster[raster > 0] - (np.min(raster[raster > 0]) - 1)
raster[raster>101] = 0
raster = np.rint(raster)
flat = np.ndarray.flatten(raster[raster > 0])
range = np.max(flat) - np.min(flat)
print("\n\nRaster Range: {}\n\n".format(range))
raster = raster.astype(np.uint8)
raster[raster > 101] = 0
我将如何让 glcm 计算对角矩阵之外的值(即只是值本身的频率),我的方法有什么根本错误吗?