如何使用 scikit 填充二值图像的漏洞?
对于图像分析问题,我想输出一个背景为深色而硬币为白色的二值图像。我应该使用 skimage 而不是 CV2。
运行该图像的代码是:
im_coin = io.imread("coins.jpg")
imgGaussF = scipy.ndimage.gaussian_filter(im_coin, sigma=2.5)
im = img_as_ubyte(imgGaussF)
edge_canny = feature.canny(im, sigma=1,low_threshold=10, high_threshold=50)
plt.figure(figsize=(15,8))
plt.subplot(131), plt.imshow(edge_canny, cmap='gray'), plt.axis('off'), plt.title('Canny Edge Dectector \n (sigma = 1, T1=10, T2 = 50)')
现在我应该填补上面显示的图像的漏洞。
我尝试过:
edge_canny = edge_canny > 0.5
im_fill1 = binary_fill_holes(edge_canny, structure=np.ones((3,3)))
plt.gray()
plt.figure(figsize = (15,12))
plt.subplot(132), plt.imshow(im_fill1), plt.axis('off'), plt.title('Binary holes filling square size = 3 ')
但这并不能解决问题。它返回相同的图像,没有填充任何孔。谁能帮助我吗?
注意:我应该使用 skimage 而不是 cv2
For an image analysis problem, I want to output a binary image where the background is dark and the coins are white. I'm supposed to use skimage and not CV2.
I've already done some coding to come up with the following image:
The code that runs this image is:
im_coin = io.imread("coins.jpg")
imgGaussF = scipy.ndimage.gaussian_filter(im_coin, sigma=2.5)
im = img_as_ubyte(imgGaussF)
edge_canny = feature.canny(im, sigma=1,low_threshold=10, high_threshold=50)
plt.figure(figsize=(15,8))
plt.subplot(131), plt.imshow(edge_canny, cmap='gray'), plt.axis('off'), plt.title('Canny Edge Dectector \n (sigma = 1, T1=10, T2 = 50)')
Now I'm supposed to fill the holes of the image presented above.
I tried:
edge_canny = edge_canny > 0.5
im_fill1 = binary_fill_holes(edge_canny, structure=np.ones((3,3)))
plt.gray()
plt.figure(figsize = (15,12))
plt.subplot(132), plt.imshow(im_fill1), plt.axis('off'), plt.title('Binary holes filling square size = 3 ')
But this doesn't do the trick. It returns the same image with no holes filled. Can anyone help me?
Note: I'm supposed to use skimage instead of cv2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论