def rotate_whole_img(self, img): """ rotate noise rotate angle is 0 - 20 """ angle = np.random.randint(0,20) h, w = img.shape[:2] center = (w / 2, h / 2) M = cv2.getRotationMatrix2D(center, angle, 1) im = cv2.warpAffine(img, M, (w,h), borderValue=(255,255,255)) return im消除黑色区域是由于cv2.warpAffine()参数borderValue的值,默认为0
opencv图像旋转后消除黑色背景
猜你喜欢
转载自blog.csdn.net/qq_30159015/article/details/80255114
今日推荐
周排行