Implementing Bilinear Transformation version quadToQuad (without perspective)
This is my first post.
What I'm trying to do, is implement function quadToQuad but based on bilinear transformation.
Mean almost the same result but without perspective.
It is possible to implement this doing simple inversed transformation pixel by pixel, with returning changed QImage.
But better is to do it throu matrix with QTransform.
As I searched throu net, I found some people who try to do it, in qt too. But many people who describe bilinear transformation for GIS - Image (Point) Registration, Image Morphing.
So I thing many people will use this function as well. Even someone put request for OpenCV developers for this function.
What I need is transformation EXACTLY to requested corners, not like QTransform::quadToQuad which give me picture's corners unreleated to delivered QPoint's.
I want to deform face throu selected points (wider/smaller mouths, eyes, nose, etc). So I need divide photo for triangles or quads, and then modify them. So, if someone have: anyTriangleToAnyTriangle function (affine transformation), I'm appreciate too :-D.
Here is texts concerning our problem:
Here is mathematical models for bilinear transformation among other things. Everything in Polish language.
Very good text for master's degree, about program with bilinear and perspective transformation (page 11, chapter 2.2.1 "Przekształcenie dwuliniowe / bilinear transformation). Polish language.
Wikipedia about bilinear transformation.
Find function: solveBilinearTransform(points1, points2), which return matrix for bilinear transformation of given points.
Maybe in this library we can find solution, but I'm not enough good in matrix transformation.
This library probably giving solution, but my mathematical abilities cannot let me find solution.
Author of the post asking about perspective transformation, but answer 2 giving code for step by step solution matrix deformation, which I tried but without success. My intention was use this code, but remove perspective transformation - but without good understanding of matrixes I can't get it work.
...and rest sources concerning the topic:
Zack Rusin is the author of QTransform::quadToQuad function. Probably implementation of this function without perspective is easier. Source is in qtransform.cpp.
Search for "bilinear". This progs using QTransform::quadToQuad, but comments pointing to bilinear transformation. Is this what we need ?
This is very good and short text about this what we need. Mathematics.
Post about projective transformation (perspective transformation). But author make firstly transformation without perspective. I think it can be usable for this topic.
Unfortunately OpenCV don't have bilinear image warping. So we cannot use it. But maybe affine transformation for any triangle to any triangle function ??? But the other things is >>probably<< Qt have same functions for affine.
Intel paid library have this function implemented. Which i'm not interested to pay for all library for one function only.
Someone ask for bilinear transformation for OpenCV library, but without success, about one year ago.
"http://homes.cs.washington.edu/~ankit/course_projects/files/DIP/A2_web/Image Morphing.htm":http://homes.cs.washington.edu/~ankit/course_projects/files/DIP/A2_web/Image Morphing.htm
Short text about Image Morphing.
Inside this dissertation (polish) on page 13, we see picture showing differences between bilinear and perspective transformation.
And on page 70, we can find function "Bilinear Transformation" - completly, but in MatLab.
If anyone know MatLab script language, maybe this solution we can translate to Qtransform matrix :-D