本文整理汇总了Python中cv2.BORDER_REFLECT101属性的典型用法代码示例。如果您正苦于以下问题:Python cv2.BORDER_REFLECT101属性的具体用法?Python cv2.BORDER_REFLECT101怎么用?Python cv2.BORDER_REFLECT101使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类cv2
的用法示例。
在下文中一共展示了cv2.BORDER_REFLECT101属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: split
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import BORDER_REFLECT101 [as 别名]
def split(self, image, borderType=cv2.BORDER_REFLECT101, value=0):
assert image.shape[0] == self.image_height
assert image.shape[1] == self.image_width
orig_shape_len = len(image.shape)
image = cv2.copyMakeBorder(image, self.margin_top, self.margin_bottom, self.margin_left, self.margin_right, borderType=borderType, value=value)
# This check recovers possible lack of last dummy dimension for single-channel images
if len(image.shape) != orig_shape_len:
image = np.expand_dims(image,axis=-1)
tiles = []
for x, y, tile_width, tile_height in self.crops:
tile = image[y:y + tile_height, x:x + tile_width].copy()
assert tile.shape[0] == self.tile_size
assert tile.shape[1] == self.tile_size
tiles.append(tile)
return tiles
示例2: cut_patch
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import BORDER_REFLECT101 [as 别名]
def cut_patch(self, image, slice_index, borderType=cv2.BORDER_REFLECT101, value=0):
assert image.shape[0] == self.image_height
assert image.shape[1] == self.image_width
orig_shape_len = len(image.shape)
image = cv2.copyMakeBorder(image, self.margin_top, self.margin_bottom, self.margin_left, self.margin_right, borderType=borderType, value=value)
# This check recovers possible lack of last dummy dimension for single-channel images
if len(image.shape) != orig_shape_len:
image = np.expand_dims(image,axis=-1)
x, y, tile_width, tile_height = self.crops[slice_index]
tile = image[y:y + tile_height, x:x + tile_width].copy()
assert tile.shape[0] == self.tile_size
assert tile.shape[1] == self.tile_size
return tile