我有一张RGB图像,想要使用以下简单的方法进行阈值处理:
from skimage import filter
def threshold(image):
r = image[:, :, 0]
g = image[:, :, 1]
b = image[:, :, 2]
rt = filter.threshold_otsu(r)
gt = filter.threshold_otsu(g)
bt = filter.threshold_otsu(b)
我现在想做的是制作一个二进制掩模,其中原始图像中RGB值小于这些阈值的部分应设置为0。
mask = np.ones(r.shape)
我无法弄清如何设置掩码索引(x,y)为零的方法,其中
image[x, y, 0] < rt and image[x, y, 1] < gt and image [x, y, 2] < bt
我需要从原始图像中获取符合此条件的(x,y)像素索引,但我不确定如何做到这一点。
&
д»Јжӣҝand
еҗ—пјҹпјҲPythonзҡ„and
еңЁеӨ„зҗҶNumPyж•°з»„ж—¶ж•ҲжһңдёҚдҪігҖӮпјү - Alex Riley