Мне нужно получить результат функции GLCM calc_texture из R в Python.
Я пытаюсь сделать это с помощью greycomatrix и greycoprops skimage.feature.texture, но это не работает.
input
[,1] [,2] [,3]
[1,] 1 4 7
[2,] 5 5 5
[3,] 1 6 1
result=calc_texture(input,window_dims =c(1,1),shift
=matrix(unlist(list(c(0,1))),ncol=2,byrow = TRUE),
na_opt="ignore", statistics=c("contrast"),n_grey = 8,na_val = NA)
result
, , 1
[,1] [,2] [,3]
[1,] 9 9 NA
[2,] 0 0 NA
[3,] 25 25 NA
img=np.array([[1,4,7],[5,5,5],[1,6,1]])
img = img.astype(np.uint8)
rows,cols=img.shape
radius = 1
side = 2*radius + 1
distances = [1]
angles = [0]
prop= 'contrast'
dim = len(distances)*len(angles)
padded = np.pad(img, radius, mode='constant',constant_values=(np.nan,))
windows = util.view_as_windows(padded.copy(), (side, side))
feats = np.zeros(shape=(rows, cols, dim))
for row in range(rows):
for col in range(cols):
pixel_feats = []
glcm = greycomatrix(windows[row, col, :, :],
distances=distances,
angles=angles,
normed=False,levels=8)
pixel_feats.extend([greycoprops(glcm, prop).ravel()])
feats[row, col, :] = np.concatenate(pixel_feats)
print(feats[:,:,0])
[[ 5.83333333 3. 13.83333333]
[10.16666667 11.33333333 18.16666667]
[ 8.5 8.33333333 8.5 ]]
Мне нужен вывод, который я получаю в r, используя python.