【发布时间】:2017-07-24 22:59:13
【问题描述】:
我正在使用 GMM 分离出 2 个重叠的高斯。一个是信号,另一个是背景。背景总是比信号具有更低的值和平均值。大多数时候,gmm.means_ 的顺序是 [lower_mean, Higher_mean],这使得它预测 0 作为背景,1 作为信号。有时,均值的顺序是 [higher_mean, lower_mean],这使得 GMM 将其预测为 0 表示信号,1 表示噪声(与我想要的相反)。我希望具有较低均值的高斯为背景(0),而具有较高均值的高斯为信号(1)。如何将 GMM 结果设置为正确的顺序或如何设置预测输出?
img = cv2.imread(path, -1)
img_flatten = img.flatten().reshape(img.flatten().shape[0],1)
gmm = GaussianMixture(n_components=2, covariance_type='full')
gmm.fit(img_flatten)
pred = gmm.predict(img_flatten) # how can I set the prediction value I want for each Gaussian?
print(np.round(g.means_, 2))
# gives [[ 66.31] [ 203.64]] on some images and [[ 67.32] [ 306.13]] on other
【问题讨论】:
标签: python scipy scikit-learn