本文整理匯總了Python中cv2.BORDER_WRAP屬性的典型用法代碼示例。如果您正苦於以下問題:Python cv2.BORDER_WRAP屬性的具體用法?Python cv2.BORDER_WRAP怎麽用?Python cv2.BORDER_WRAP使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類cv2
的用法示例。
在下文中一共展示了cv2.BORDER_WRAP屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: E2P
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import BORDER_WRAP [as 別名]
def E2P(image, corner_i, corner_j, wall_height, camera, resolution=512, is_wall=True):
"""convert panorama to persepctive image
"""
corner_i = corner_i - camera
corner_j = corner_j - camera
if is_wall:
xs = np.linspace(corner_i[0], corner_j[0], resolution)[None].repeat(resolution, 0)
ys = np.linspace(corner_i[1], corner_j[1], resolution)[None].repeat(resolution, 0)
zs = np.linspace(-camera[-1], wall_height - camera[-1], resolution)[:, None].repeat(resolution, 1)
else:
xs = np.linspace(corner_i[0], corner_j[0], resolution)[None].repeat(resolution, 0)
ys = np.linspace(corner_i[1], corner_j[1], resolution)[:, None].repeat(resolution, 1)
zs = np.zeros_like(xs) + wall_height - camera[-1]
coorx, coory = xyz_2_coorxy(xs, ys, zs)
persp = cv2.remap(image, coorx.astype(np.float32), coory.astype(np.float32),
cv2.INTER_CUBIC, borderMode=cv2.BORDER_WRAP)
return persp
示例2: blur_edge
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import BORDER_WRAP [as 別名]
def blur_edge(img, d=31):
h, w = img.shape[:2]
img_pad = cv2.copyMakeBorder(img, d, d, d, d, cv2.BORDER_WRAP)
img_blur = cv2.GaussianBlur(img_pad, (2*d+1, 2*d+1), -1)[d:-d,d:-d]
y, x = np.indices((h, w))
dist = np.dstack([x, w-x-1, y, h-y-1]).min(-1)
w = np.minimum(np.float32(dist)/d, 1.0)
return img*w + img_blur*(1-w)
示例3: _smoothen_alphas
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import BORDER_WRAP [as 別名]
def _smoothen_alphas(cls, alphas, sigma):
if sigma <= 0.0+1e-2:
return alphas
ksize = max(int(sigma * 2.5), 3)
ksize_y, ksize_x = (1, ksize)
if ksize_x % 2 == 0:
ksize_x += 1
# we fake here cv2.BORDER_WRAP, because GaussianBlur does not
# support that mode, i.e. we want:
# cdefgh|abcdefgh|abcdefg
alphas = np.concatenate([
alphas[-ksize_x:],
alphas,
alphas[:ksize_x],
])
alphas = cv2.GaussianBlur(
_normalize_cv2_input_arr_(alphas[np.newaxis, :]),
ksize=(ksize_x, ksize_y),
sigmaX=sigma, sigmaY=sigma,
borderType=cv2.BORDER_REPLICATE
)[0, :]
# revert fake BORDER_WRAP
alphas = alphas[ksize_x:-ksize_x]
return alphas
# Added in 0.4.0.
示例4: __init__
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import BORDER_WRAP [as 別名]
def __init__(self, target_size, fill_color=127, mode='letterbox',
border='constant', random_state=None):
super(Resize, self).__init__(random_state=random_state)
self.target_size = None if target_size is None else np.array(target_size)
self.mode = mode
import imgaug.parameters as iap
if fill_color == imgaug.ALL:
self.fill_color = iap.Uniform(0, 255)
else:
self.fill_color = iap.handle_continuous_param(
fill_color, "fill_color", value_range=None,
tuple_to_uniform=True, list_to_choice=True)
self._cv2_border_type_map = {
'constant': cv2.BORDER_CONSTANT,
'edge': cv2.BORDER_REPLICATE,
'linear_ramp': None,
'maximum': None,
'mean': None,
'median': None,
'minimum': None,
'reflect': cv2.BORDER_REFLECT_101,
'symmetric': cv2.BORDER_REFLECT,
'wrap': cv2.BORDER_WRAP,
cv2.BORDER_CONSTANT: cv2.BORDER_CONSTANT,
cv2.BORDER_REPLICATE: cv2.BORDER_REPLICATE,
cv2.BORDER_REFLECT_101: cv2.BORDER_REFLECT_101,
cv2.BORDER_REFLECT: cv2.BORDER_REFLECT
}
if isinstance(border, six.string_types):
if border == imgaug.ALL:
border = [k for k, v in self._cv2_border_type_map.items()
if v is not None and isinstance(k, six.string_types)]
else:
border = [border]
if isinstance(border, (list, tuple)):
from imgaug.parameters import Choice
border = Choice(border)
self.border = border
assert self.mode == 'letterbox', 'thats all folks'