【发布时间】:2015-04-02 02:03:35
【问题描述】:
我正在寻找一种可靠的方法来从背景中有一些噪点的图像中提取前景。
所以,我想用它的图像是:
我的尝试是使用Otsu thresholding。我在 Python 中这样做如下:
from skimage.filter import threshold_otsu
import os.path as path
import matplotlib.pyplot as plt
img = io.imread(path.expanduser('~/Desktop/62.jpg'))
r_t = threshold_otsu(img[:, :, 0])
g_t = threshold_otsu(img[:, :, 1])
b_t = threshold_otsu(img[:, :, 2])
m = np.zeros((img.shape[0], img.shape[1]), dtype=np.uint8)
mask = (img[:, :, 0] < r_t) & (img[:, :, 1] < g_t) & (img[:, :, 2] < b_t)
m[~mask] = 255
plt.imshow(m)
plt.show()
这给出了 R、G、B 阈值为 (62 67 64),这有点高。结果是:
这张图片也是Otsu thresholding 效果最好的图片之一。如果我使用像 30 这样的手动阈值,它工作得很好。结果是:
我想知道我是否应该尝试其他一些方法。细分确实不是我的专业领域,而且我能开箱即用的东西似乎有限。
【问题讨论】:
标签: python image-processing image-segmentation scikit-image