本文整理匯總了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