What is the third coordinate in "Projective Transformation" of an image and how to build the matrix of the inverse transform? I am trying to understand the formalism of the projective transform of 2D image.
it has 9 parameters (a-i) which the 9th is redundant since we use houmogenous coordinates.
this transformation preserves only straight lines.

$\pmatrix{x'\\ y' \\ w'}$  = $\pmatrix{ a&amp; b&amp; c\\\ d&amp; e&amp; f \\\ g&amp; h&amp; i}$  $\pmatrix{x\\ y \\ w}$

I have three questions according this formalism:


Since the redundancy (from 8 to 9) of degrees of freedom is $i=1$ ?
what is the $w$ and $w'$ ? are they parameters? how do i calculate them?
How can I find the parameters so I can transform the image to its original(from the black background image to the square one). 


what I want to do is build the matrix to transform this image: 



and find matrix $M$

so I get back this image:



All the images  above taken from here

What I want finally do is to find the 

M = [a  b c; 
     d  e f;
     g  h i];

t_proj = maketform('projective',T);   
I_projective = imtransform(I,t_proj,'FillValues',.3);
imshow(I_projective)
title('unprojective - rectangular carpet')


taken from here
You have to understand that projective transformation is not linear.
It's $(x,y) -&gt; (X(x, y)/Z(x,y) , Y(x, y)/Z(x,y))$, where X, Y, Z - linear functions.

$w$ and $w&#39;$ are essential here - they help represent this non-linear transformation as linear - matrix multiplication - and that way this linear representation is a homomorphism (preserve "chaining" of operations).$w$ for input image is usually taken as $1$;
You get $w&#39;$ from matrix multiplication ($w' = gx + hy + iw$ ) and the end result of transform is $(x&#39;/w&#39;, y&#39;/w&#39;)$

Generally speaking you can't just assign $i=1$, but due to homogeneity you can divide all the matrix by $i$ and get new matrix, representing the same transform with right-left element $1$

I would advise you to read some textbook on projective geometry for computer vision to better understand this subject. Those questions have some deep implications.