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


Python cv2.COLOR_YCR_CB2BGR属性代码示例

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


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

示例1: convert_to_original_colors

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import COLOR_YCR_CB2BGR [as 别名]
def convert_to_original_colors(content_img, stylized_img):
  content_img  = postprocess(content_img)
  stylized_img = postprocess(stylized_img)
  if args.color_convert_type == 'yuv':
    cvt_type = cv2.COLOR_BGR2YUV
    inv_cvt_type = cv2.COLOR_YUV2BGR
  elif args.color_convert_type == 'ycrcb':
    cvt_type = cv2.COLOR_BGR2YCR_CB
    inv_cvt_type = cv2.COLOR_YCR_CB2BGR
  elif args.color_convert_type == 'luv':
    cvt_type = cv2.COLOR_BGR2LUV
    inv_cvt_type = cv2.COLOR_LUV2BGR
  elif args.color_convert_type == 'lab':
    cvt_type = cv2.COLOR_BGR2LAB
    inv_cvt_type = cv2.COLOR_LAB2BGR
  content_cvt = cv2.cvtColor(content_img, cvt_type)
  stylized_cvt = cv2.cvtColor(stylized_img, cvt_type)
  c1, _, _ = cv2.split(stylized_cvt)
  _, c2, c3 = cv2.split(content_cvt)
  merged = cv2.merge((c1, c2, c3))
  dst = cv2.cvtColor(merged, inv_cvt_type).astype(np.float32)
  dst = preprocess(dst)
  return dst 
开发者ID:cysmith,项目名称:neural-style-tf,代码行数:25,代码来源:neural_style.py

示例2: hist

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import COLOR_YCR_CB2BGR [as 别名]
def hist(img):
    ycrcb = cv2.cvtColor(img, cv2.COLOR_BGR2YCR_CB)
    channels = cv2.split(ycrcb)
    cv2.equalizeHist(channels[0], channels[0])  #输入通道、输出通道矩阵
    cv2.merge(channels, ycrcb)  #合并结果通道
    cv2.cvtColor(ycrcb, cv2.COLOR_YCR_CB2BGR, img)
    return img 
开发者ID:vipstone,项目名称:faceai,代码行数:9,代码来源:eye2.py

示例3: color_draw

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import COLOR_YCR_CB2BGR [as 别名]
def color_draw(path="img/sjtu.jpg", gammaS=1, gammaI=1):
    im = Image.open(path)

    if im.mode == 'RGB':
        ycbcr = im.convert('YCbCr')
        Iruv = np.ndarray((im.size[1], im.size[0], 3), 'u1', ycbcr.tobytes())
        type = "colour"
    else:
        Iruv = np.array(im)
        type = "black"

    S = get_s(Iruv[:, :, 0], gammaS=gammaS)
    T = get_t(Iruv[:, :, 0], type, gammaI=gammaI)
    Ypencil = S * T

    new_Iruv = Iruv.copy()
    new_Iruv.flags.writeable = True
    new_Iruv[:, :, 0] = Ypencil * 255

    R = cv2.cvtColor(new_Iruv, cv2.COLOR_YCR_CB2BGR)
    img = Image.fromarray(R)
    # img.show()

    name = path.rsplit("/")[-1].split(".")[0]
    suffix = path.rsplit("/")[-1].split(".")[1]

    save_output(Image.fromarray(S * 255), name + "_s", suffix)
    save_output(Image.fromarray(T * 255), name + "_t", suffix)
    save_output(img, name + "_color", suffix) 
开发者ID:duduainankai,项目名称:pencil-python,代码行数:31,代码来源:color_pencil.py

示例4: create_mask

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import COLOR_YCR_CB2BGR [as 别名]
def create_mask(self, img, color):
        img = cv2.cvtColor(img, cv2.COLOR_BGR2Lab)

        if color == 'green':
            threshold = [(20, 0, 128), (235, 128, 255)]
        elif color == 'white':
            threshold = [(100, 110, 110), (200, 140, 140)]

        else:
            raise Exception('Color undefined')
        
        mask = cv2.inRange(img, threshold[0], threshold[1])
        # kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (7,7))
        # mask =  cv2.morphologyEx(mask, cv2.MORPH_OPEN, kernel)
        # mask =  cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel)

        mask = mask > 0

        # img = cv2.cvtColor(img, cv2.COLOR_YCR_CB2BGR)

        # thres_img = np.zeros_like(img, np.uint8)
        # thres_img[mask] = img[mask]

        binary_img = np.zeros((img.shape[0],img.shape[1]), np.uint8)
        binary_img[mask] = 255

        # cv2.imshow('img', binary_img)
        # cv2.waitKey(0)
        # exit(0)

        return mask 
开发者ID:zuoym15,项目名称:craves.ai,代码行数:33,代码来源:imutils.py

示例5: houghCircles

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import COLOR_YCR_CB2BGR [as 别名]
def houghCircles(path, counter):
    img = cv2.imread(path, 0)
    # img = cv2.medianBlur(img, 5)

    x = cv2.Sobel(img, -1, 1, 0, ksize=3)
    y = cv2.Sobel(img, -1, 0, 1, ksize=3)
    absx = cv2.convertScaleAbs(x)
    absy = cv2.convertScaleAbs(y)
    img = cv2.addWeighted(absx, 0.5, absy, 0.5, 0)

    # ycrcb = cv2.cvtColor(img, cv2.COLOR_BGR2YCR_CB)
    # channels = cv2.split(ycrcb)
    # cv2.equalizeHist(channels[0], channels[0])  #输入通道、输出通道矩阵
    # cv2.merge(channels, ycrcb)  #合并结果通道
    # cv2.cvtColor(ycrcb, cv2.COLOR_YCR_CB2BGR, img)

    # img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

    cimg = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)

    # cv2.imshow("img2", img)
    # cv2.imshow("grayimg", grayimg)

    circles = cv2.HoughCircles(
        img,
        cv2.HOUGH_GRADIENT,
        1,
        50,
        param1=50,
        param2=10,
        minRadius=2,
        maxRadius=0)

    circles = np.uint16(np.around(circles))
    for i in circles[0, :]:
        # draw the outer circle
        # cv2.circle(cimg, (i[0], i[1]), i[2], (0, 255, 0), 1)
        # draw the center of the circle
        cv2.circle(cimg, (i[0], i[1]), 2, (0, 0, 255), 2)
    # cv2.imshow("img" + str(counter), cimg)
    return (i[0] + 3, i[1] + 3)


#彩色直方图均衡化 
开发者ID:vipstone,项目名称:faceai,代码行数:46,代码来源:eye.py


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