Kim*_*Hee 1 image-processing python-2.7 scikit-image
我正在使用skimage填充二进制输入图像(左侧)的孔。这是我的代码
from skimage import ndimage
img_fill_holes=ndimage.binary_fill_holes(binary).astype(int)
Run Code Online (Sandbox Code Playgroud)
但是,以上代码的结果无法完全填补二进制图像的空白。这意味着输出仍然保留圆内的孔。如何完全填充圆孔?
您可能已尝试将其应用于binary_fill_holesRGB图像(3D矩阵,请binary.shape[2] == 3进行检查)。
尝试:
img_fill_holes = ndimage.binary_fill_holes(binary[:,:,0]).astype(int)
Run Code Online (Sandbox Code Playgroud)
或任何其他“ rgb2gray”方法,您应该获得预期的输出