【发布时间】:2018-12-09 03:56:23
【问题描述】:
我使用此代码,但它不会裁剪黑色边框。那么,有人可以帮帮我吗?
im = cv2.imread("Data/"+file, 0)
retval, thresh_gray = cv2.threshold(im, thresh=100, maxval=255, type=cv2.THRESH_BINARY)
points = np.argwhere(thresh_gray==0)
points = np.fliplr(points)
x, y, w, h = cv2.boundingRect(points)
crop = im[y:y+h, x:x+w] # create a crop
retval, thresh_crop = cv2.threshold(crop, thresh=200, maxval=255, type=cv2.THRESH_BINARY)
path = 'D:\Picture\Camera Roll'
cv2.imwrite(os.path.join(path , file),thresh_crop)
【问题讨论】:
标签: python image opencv border crop