1

** 我正在处理前哨图像,当我在这些图像上应用 GMM 时,在重塑图像时出现错误,我尝试了以下代码:

import numpy as np
import matplotlib.pyplot as plt
from sklearn.mixture import GaussianMixture as GMM
samples = 59
lines   = 104
w=10
h=10
fig=plt.figure(figsize=(20, 20))
g = open("C:/Users/oussa/Desktop/masques/01janvier/bande_04", 'rb')
im = np.fromfile(g, np.uint16,(samples * lines))
g.close()
im2 = np.reshape(im, (samples, lines), order="F")
print(im2)
gmm_model=GMM(n_components=59).fit(im2)
gmm_labels=gmm_model.predict(im2)
print(gmm_labels)
print(im2.shape)
original_shape=im2.shape
segmented_image=gmm_labels.reshape(original_shape[0],original_shape[1])
plt.imshow(segmented_image,cmap='gray',vmin=0,vmax=1)
plt.show()

**这是我正在处理的图像(光谱带)

4

0 回答 0