I'm in the usual situation that if I would know what the name of the thing was, then I could find the answer. Since I dont know the name, here is what I'm looking for:
Suppose I have the following "snake" of 10 quadrilaterals:

I now want to apply a transformation to each of these quadrilaterals such that the "snake" is straightened. To that end I calculated a perspective transformation according to what I read here. This also seems to work "somehow" as I end up with the following result:

As one can see, the line that was in the center of the "snake" is not in the center of the straightened object anymore.
What I need is a transformation which linearly scales all the content of the "warped" quadrilaterals into straight rectangles. If something was at the center of an edge in the snake, then it should also be at the center of the transformed edge. Apparently a perspective transform does not do this.
My question is: which transformation am I looking for that fulfills this property?
The solution is the following: given a distorted, input quadrilateral $A$,$B$,$C$,$D$, a point in it $X$, and the width $w$, height $h$ and position $x_R,y_R$ of the output rectangle, the solution is:
$$ X' = x_R+sw \\ Y' = y_R+th \\ $$
Where parameters $s$ and $t$ calculate as follows:
$$ s_{1,2} = \frac{-b_s\pm\sqrt{b_s^2-4a_sc_s}}{2a_s} \\ a_s = (D_x-C_x)(B_y-A_y-C_y+D_y)-(D_y-C_y)(B_x-A_x-C_x+Dx) \\ b_s = (D_y-A_y)(C_x-D_x)+(X_x-D_x)(B_y-A_y-C_y+D_y)-(X_y-D_y)(B_x-A_x-C_x+D_x)-(A_x-D_x)(D_y-C_y) \\ c_s = (A_y-D_y)(X_x-D_x)-(A_x-D_x)(X_y-D_y) \\ t_{1,2} = \frac{-b_t\pm\sqrt{b_t^2-4a_tc_t}}{2a_t} \\ a_t = (D_y-A_y)(B_x-A_x-C_x+D_x)-(D_x-A_x)(B_y-A_y-C_y+D_y) \\ b_t = (D_y-A_y)(C_x-D_x)+(X_y-D_y)(B_x-A_x-C_x+D_x)-(X_x-D_x)(B_y-A_y-C_y+D_y)-(C_y-D_y)(D_x-A_x) \\ c_t = (C_x-D_x)(X_y-D_y)-(C_y-D_y)(X_x-D_x) \\ $$
To demonstrate the correctness of the solution, here is the result of the transformation. In contrast to above not only with the central line transformed but also other data transformed in the same way. As you can see, both successfully connect at the borders between output rectangles.
User 5xum helped me with finding a solution for the above equation in case $a$ is zero. In that case, $s$ and $t$ are linear and calculate as $-\frac{c}{b}$.