當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。