当前位置: 首页>>代码示例>>Python>>正文


Python cv2.pow方法代码示例

本文整理汇总了Python中cv2.pow方法的典型用法代码示例。如果您正苦于以下问题:Python cv2.pow方法的具体用法?Python cv2.pow怎么用?Python cv2.pow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cv2的用法示例。


在下文中一共展示了cv2.pow方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_random_manipulation

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pow [as 别名]
def get_random_manipulation(img, manipulation=None):

    if manipulation == None:
        manipulation = random.choice(MANIPULATIONS)

    if manipulation.startswith('jpg'):
        quality = int(manipulation[3:])
        out = BytesIO()
        im = Image.fromarray(img)
        im.save(out, format='jpeg', quality=quality)
        im_decoded = jpeg.JPEG(np.frombuffer(out.getvalue(), dtype=np.uint8)).decode()
        del out
        del im
    elif manipulation.startswith('gamma'):
        gamma = float(manipulation[5:])
        # alternatively use skimage.exposure.adjust_gamma
        # img = skimage.exposure.adjust_gamma(img, gamma)
        im_decoded = np.uint8(cv2.pow(img / 255., gamma)*255.)
    elif manipulation.startswith('bicubic'):
        scale = float(manipulation[7:])
        im_decoded = cv2.resize(img,(0,0), fx=scale, fy=scale, interpolation = cv2.INTER_CUBIC)
    else:
        assert False
    return im_decoded, MANIPULATIONS.index(manipulation) 
开发者ID:antorsae,项目名称:sp-society-camera-model-identification,代码行数:26,代码来源:train.py

示例2: farthest_point

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pow [as 别名]
def farthest_point(defects, contour, centroid):
    if defects is not None and centroid is not None:
        s = defects[:, 0][:, 0]
        cx, cy = centroid

        x = np.array(contour[s][:, 0][:, 0], dtype=np.float)
        y = np.array(contour[s][:, 0][:, 1], dtype=np.float)

        xp = cv2.pow(cv2.subtract(x, cx), 2)
        yp = cv2.pow(cv2.subtract(y, cy), 2)
        dist = cv2.sqrt(cv2.add(xp, yp))

        dist_max_i = np.argmax(dist)

        if dist_max_i < len(s):
            farthest_defect = s[dist_max_i]
            farthest_point = tuple(contour[farthest_defect][0])
            return farthest_point
        else:
            return None 
开发者ID:amarlearning,项目名称:Finger-Detection-and-Tracking,代码行数:22,代码来源:FingerDetection.py

示例3: convert_to_nearest_label

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pow [as 别名]
def convert_to_nearest_label(label_path, image_size, apply_ignore=True):
    """
    Convert RGB label image to onehot label image
    :param label_path: File path of RGB label image
    :param image_size: Size to resize result image
    :param apply_ignore: Apply ignore
    :return:
    """
    label = np.array(Image.open(label_path).resize((image_size[0], image_size[1]), Image.ANTIALIAS))[:, :, :3]
    label = label.astype(np.float32)
    stacked_label = list()
    for index, mask in enumerate(label_mask):
        length = np.sum(cv2.pow(label - mask, 2), axis=2, keepdims=False)
        length = cv2.sqrt(length)
        stacked_label.append(length)

    stacked_label = np.array(stacked_label)
    stacked_label = np.transpose(stacked_label, [1, 2, 0])
    converted_to_classes = np.argmin(stacked_label, axis=2).astype(np.uint8)
    if apply_ignore:
        ignore_mask = (converted_to_classes == (len(label_mask) - 1)).astype(np.uint8)
        ignore_mask *= (256 - len(label_mask))
        converted_to_classes += ignore_mask

    return converted_to_classes 
开发者ID:POSTECH-IMLAB,项目名称:LaneSegmentationNetwork,代码行数:27,代码来源:dataset_util.py

示例4: imcv2_recolor

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pow [as 别名]
def imcv2_recolor(im, a = .1):
	t = [np.random.uniform()]
	t += [np.random.uniform()]
	t += [np.random.uniform()]
	t = np.array(t) * 2. - 1.

	# random amplify each channel
	im = im * (1 + t * a)
	mx = 255. * (1 + a)
	up = np.random.uniform() * 2 - 1
# 	im = np.power(im/mx, 1. + up * .5)
	im = cv2.pow(im/mx, 1. + up * .5)
	return np.array(im * 255., np.uint8) 
开发者ID:AmeyaWagh,项目名称:Traffic_sign_detection_YOLO,代码行数:15,代码来源:im_transform.py

示例5: imcv2_recolor

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pow [as 别名]
def imcv2_recolor(im, a=.1):
    t = [np.random.uniform()]
    t += [np.random.uniform()]
    t += [np.random.uniform()]
    t = np.array(t) * 2. - 1.

    # random amplify each channel
    im = im * (1 + t * a)
    mx = 255. * (1 + a)
    up = np.random.uniform() * 2 - 1
    # 	im = np.power(im/mx, 1. + up * .5)
    im = cv2.pow(im / mx, 1. + up * .5)
    return np.array(im * 255., np.uint8) 
开发者ID:MahmudulAlam,项目名称:Automatic-Identification-and-Counting-of-Blood-Cells,代码行数:15,代码来源:im_transform.py

示例6: _gamma_manip

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pow [as 别名]
def _gamma_manip(image, gamma):
        result = np.uint8(cv2.pow(image / 255., gamma) * 255.)
        return result 
开发者ID:PavelOstyakov,项目名称:camera_identification,代码行数:5,代码来源:augmentation.py


注:本文中的cv2.pow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。