我尝试从下面的照片1中删除背景和白色文本,但我只能删除这些图像2{a3}。圆圈内仍有白色文字。 我使用了以下代码。 我非常感谢大家的帮助
img = cv2.imread('sample.jpg')
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
#Crop image
croped_img = img[51:403,102:454]
#plt.imshow(croped_img)
radius = 176
cx, cy = radius, radius # The center of circle
x,y = np.ogrid[-radius: radius, -radius: radius]
index = x**2 + y**2 > radius**2
croped_img[cy-radius:cy+radius, cx-radius:cx+radius][index] = 0
plt.imshow(croped_img)
croped_img=cv2.cvtColor(croped_img, cv2.COLOR_BGR2RGB)
cv2.imwrite('croped_circle_2.jpg', croped_img)
一种方法是创建一个文本掩码,并使用它进行修复。在Python/OpenCV中,有两种形式的修复:Telea和Navier-Stokes。两者产生的结果大致相同
输入:
阈值图像:
遮罩图像:
Telea修复:
Navier Stokes修复:
相关问题 更多 >
编程相关推荐