mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 02:36:17 +03:00
Added PerspectiveTransform
This commit is contained in:
parent
a786a0551b
commit
ba6399cad1
|
@ -16,6 +16,8 @@ class TestImageTransform:
|
||||||
|
|
||||||
transform = ImageTransform.AffineTransform(seq[:6])
|
transform = ImageTransform.AffineTransform(seq[:6])
|
||||||
im.transform((100, 100), transform)
|
im.transform((100, 100), transform)
|
||||||
|
transform = ImageTransform.PerspectiveTransform(seq[:8])
|
||||||
|
im.transform((100, 100), transform)
|
||||||
transform = ImageTransform.ExtentTransform(seq[:4])
|
transform = ImageTransform.ExtentTransform(seq[:4])
|
||||||
im.transform((100, 100), transform)
|
im.transform((100, 100), transform)
|
||||||
transform = ImageTransform.QuadTransform(seq[:8])
|
transform = ImageTransform.QuadTransform(seq[:8])
|
||||||
|
|
|
@ -19,6 +19,11 @@ The :py:mod:`~PIL.ImageTransform` module contains implementations of
|
||||||
:undoc-members:
|
:undoc-members:
|
||||||
:show-inheritance:
|
:show-inheritance:
|
||||||
|
|
||||||
|
.. autoclass:: PerspectiveTransform
|
||||||
|
:members:
|
||||||
|
:undoc-members:
|
||||||
|
:show-inheritance:
|
||||||
|
|
||||||
.. autoclass:: ExtentTransform
|
.. autoclass:: ExtentTransform
|
||||||
:members:
|
:members:
|
||||||
:undoc-members:
|
:undoc-members:
|
||||||
|
|
|
@ -63,6 +63,26 @@ class AffineTransform(Transform):
|
||||||
method = Image.Transform.AFFINE
|
method = Image.Transform.AFFINE
|
||||||
|
|
||||||
|
|
||||||
|
class PerspectiveTransform(Transform):
|
||||||
|
"""
|
||||||
|
Define a perspective image transform.
|
||||||
|
|
||||||
|
This function takes an 8-tuple (a, b, c, d, e, f, g, h). For each pixel
|
||||||
|
(x, y) in the output image, the new value is taken from a position
|
||||||
|
((a x + b y + c) / (g x + h y + 1), (d x + e y + f) / (g x + h y + 1)) in
|
||||||
|
the input image, rounded to nearest pixel.
|
||||||
|
|
||||||
|
This function can be used to scale, translate, rotate, and shear the
|
||||||
|
original image.
|
||||||
|
|
||||||
|
See :py:meth:`.Image.transform`
|
||||||
|
|
||||||
|
:param matrix: An 8-tuple (a, b, c, d, e, f, g, h).
|
||||||
|
"""
|
||||||
|
|
||||||
|
method = Image.Transform.PERSPECTIVE
|
||||||
|
|
||||||
|
|
||||||
class ExtentTransform(Transform):
|
class ExtentTransform(Transform):
|
||||||
"""
|
"""
|
||||||
Define a transform to extract a subregion from an image.
|
Define a transform to extract a subregion from an image.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user