我有一个像下面这样的图片文件...
我想要删除该图片中所有的注释。不清楚如何在Python中完成此操作。这是我所做的:
import cv2 as cv
import numpy as np
img = cv.imread("/path/to/image/1.png")
image_contours = np.zeros((img.shape[1], img.shape[0], 1), np.uint8)
image_binary = np.zeros((img.shape[1], img.shape[0], 1), np.uint8)
for channel in range(img.shape[2]):
ret, image_thresh = cv.threshold(img[:, :, channel], 127, 255, cv.THRESH_BINARY)
contours = cv.findContours(image_thresh, 1, 1)[0]
cv.drawContours(image_contours, contours, -1, (255,255,255), 3)
contours = cv.findContours(image_contours, cv.RETR_LIST,
cv.CHAIN_APPROX_SIMPLE)[0]
cv.drawContours(image_binary, [max(contours, key = cv.contourArea)],
-1, (255, 255, 255), -1)
cv.imwrite("/path/to/save/save.png", image_binary)
我没有把原始图片从注释中删除,但我得到了下面这个......我错过了什么吗?