def cutout(self, img, cut_point, img_path='trim', padding=False, extra_cut=False):
'''??????????????image_path?????'''
px = self.padding_x if padding else 0
py = self.padding_y if padding else 0
cp_x = cut_point['x']
cp_y = cut_point['y']
for i in range(0, len(cp_y)):
if i % 2 == 0:
img_cut_1_4 = img[cp_y[i] - py:cp_y[i + 1] + py, cp_x[2] - px:cp_x[3] + px]
img_cut_5_8 = img[cp_y[i] - py:cp_y[i + 1] + py, cp_x[0] - px:cp_x[1] + px]
if extra_cut:
# ???????1???????????????????
img_cut_1_4 = hybrid_cut(img=img_cut_1_4, img_path='dum-{}'.format(i // 2 + 1))
img_cut_5_8 = hybrid_cut(img=img_cut_5_8, img_path='dum-{}'.format(i // 2 + 5))
cv2.imwrite('{}-{}.png'.format(img_path, str(i // 2 + 1)), img_cut_1_4)
cv2.imwrite('{}-{}.png'.format(img_path, str(i // 2 + 5)), img_cut_5_8)
评论列表
文章目录