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


Python Image.PERSPECTIVE属性代码示例

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


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

示例1: _paste_donor_on_recipient

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import PERSPECTIVE [as 别名]
def _paste_donor_on_recipient(
        recipient_face: face_detect.Face,
        recipient_image: Image,
        donor_face: face_detect.Face,
        donor_image: Image) -> Image:

    get_coords = lambda face: [c.xy() for c in [face.left_eye, face.right_eye, face.mouth_left, face.mouth_right]]
    donor_coords = get_coords(donor_face)
    recipient_coords = get_coords(recipient_face)
    coefficients = _find_coeffs(recipient_coords, donor_coords)

    warped_donor = donor_image.transform(
        recipient_image.size, Image.PERSPECTIVE, coefficients, Image.BICUBIC)

    working_recipient = recipient_image.copy()
    working_recipient.paste(warped_donor, (0, 0), warped_donor)

    return working_recipient


# Adapted from https://stackoverflow.com/questions/14177744/how-does-perspective-transformation-work-in-pil. 
开发者ID:revan,项目名称:gabenizer,代码行数:23,代码来源:image_operations.py

示例2: transform

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import PERSPECTIVE [as 别名]
def transform(startpoints, endpoints, im):
	'''Perform a perspective transformation on an image where startpoints are moved to endpoints, and the image is streched accordingly.'''
	width, height = im.size
	coeffs = find_coeffs(endpoints, startpoints)

	im = im.transform((width, height), Image.PERSPECTIVE, coeffs, Image.BICUBIC)
	return im 
开发者ID:controversial,项目名称:maze-cv,代码行数:9,代码来源:perspective.py

示例3: __call__

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import PERSPECTIVE [as 别名]
def __call__(self, img, mask):
        width, height = img.size
        a = self.scale * (random.random() - 0.5) + 1
        b = self.scale * (random.random() - 0.5)
        c = self.scale * (random.random() - 0.5)
        d = self.scale * (random.random() - 0.5)
        e = self.scale * (random.random() - 0.5) + 1
        f = self.scale * (random.random() - 0.5)
        g = self.scale / width * (random.random() - 0.5)
        h = self.scale / height * (random.random() - 0.5)
        coeffs = np.array([a, b, c, d, e, f, g, h])
        return img.transform((width, height), Image.PERSPECTIVE, coeffs, Image.BICUBIC), mask.transform(
            (width, height), Image.PERSPECTIVE, coeffs, Image.NEAREST) 
开发者ID:maunzzz,项目名称:cross-season-segmentation,代码行数:15,代码来源:joint_transforms.py

示例4: drawTerminal

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import PERSPECTIVE [as 别名]
def drawTerminal(text, fontsize):
    """Compose an img made of a pseudo-terminal interface,
    with print outs of text and a background from the main video"""
    black = (16,16,16)
    light = (150,210,150)
    white = (190,210,230)
    x,y=(695,500)

    font_title = ImageFont.truetype("COURIER.TTF",15)
    font_text = ImageFont.truetype("COURIER.TTF",fontsize)
    img=Image.new("RGBA", (x,y),black)
    draw = ImageDraw.Draw(img)
    draw.rectangle(((4,4),(x-5,y-5)), outline = light)
    draw.rectangle(((5,5),(x-5,y-5)), outline = white)
    draw.rectangle(((9,9),(x-10,30)), outline = light)
    draw.rectangle(((10,10),(x-10,30)), outline = white)

    draw.text((11, 15),'  GIFOLATINE 3000 V1.337 - By 1-Sisyphe',light,
              font=font_title)
    draw.text((12, 16),'  GIFOLATINE 3000 V1.337 - By 1-Sisyphe',white,
              font=font_title)
    draw.text((x-50, 15),'X O',white,font=font_title)

    draw.multiline_text((10, 40),text,light,font=font_text)
    draw.multiline_text((11, 41),text,white,font=font_text)

    new_size = (800, 800)
    new_im = Image.new("RGBA", new_size)
    new_im.paste(img,(0,100))

    coeffs = find_coeffs(
        [(0, 0), (x, 0), (x, y), (0, y)],
        [(0, 0), (x, 50), (x, 450), (0, y)])

    img = new_im.transform(new_size, Image.PERSPECTIVE, coeffs,
        Image.BICUBIC)
    img = img.rotate(0.5, resample=Image.BICUBIC)
    img_finale = Image.open('temp/background.png')
    img_finale.paste(img,(340,-75),img)

    return img_finale 
开发者ID:1-Sisyphe,项目名称:youCanCodeAGif,代码行数:43,代码来源:terminal.py


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