1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Affine Transformation to "change perspective" of an image

Discussão em 'Python' iniciado por Stack, Outubro 3, 2024 às 12:52.

  1. Stack

    Stack Membro Participativo

    I need to write a Python script that changes the "perspective" of an image from off to the right to straight on using affine transformation. (See attached pictures. Not the actual images I am working on)

    Based on what I've read about affine transformation, parallelism is preserved after transformation. Doesn't that mean that non-parallel lines remain non-parallel and parallel lines remain parallel? Since the shape of the object to be transformed is a trapezoid, doesn't that mean that it is impossible to use affine transformation to transform the object into a rectangle?

    Just to clarify, the output does not have to be a perfect rectangle, just close enough visually. Affine transformation is also required.

    Perspective to be changed Output

    I tried doing affine transformation as normal (from what I've found online) using 3 source points and 3 destination points. I found that there is always 1 side of the object that is not roughly 90 degrees from the 2 other sides (i.e., I couldn't get the transformation to work).

    I know it is possible to use cv2.warpPerspective, but that requires 4 source and destination points. AFAIK, affine transformation is done with only 3 points.

    Please let me know if I am mistaken about anything, and if so, how I would go about using affine transformation to achieve the objective.

    Continue reading...

Compartilhe esta Página