Utente:Gianguodala/Sandbox e Chiesa della Madonna degli Angeli (Scorrano di Cellino Attanasio): differenze tra le pagine

(Differenze fra le pagine)
Contenuto cancellato Contenuto aggiunto
 
Nuova pagina: {{Edificio religioso |DedicatoA = Madonna degli Angeli |NomeEdificio= Chiesa della Madonna degli Angeli (Scorrano di Cellino Attanasio) (TE) |Immagine...
 
Riga 1:
{{Edificio religioso
'''Author: Consoli Gianluca'''
|DedicatoA = [[ Madonna degli Angeli ]]
= Structure From Motion with Orthographic and Paraperspective projection models =
|NomeEdificio= Chiesa della Madonna degli Angeli (Scorrano di Cellino Attanasio) ([[teramo|TE]])
|Immagine= Chiesa della Madonna degli Angeli (Scorrano di Cellino Attanasio).jpg
|Didascalia= Chiesa della Madonna degli Angeli (Scorrano di Cellino Attanasio)
|Larghezza =
|Città= Scorrano di Cellino Attanasio
|SiglaStato = ITA
|Regione= [[Abruzzo]]
|Religione= [[cattolicesimo]]
|Diocesi=
|AnnoConsacr=
|Arciprete=
|StileArchitett=
|InizioCostr= [[1800]]
|FineCostr=
|Website= }}
 
La '''Chiesa della Madonna degli Angeli ''' è una chiesa in [[Scorrano (Cellino Attanasio)|Scorrano di Cellino Attanasio]], in [[provincia di Teramo]] ed è dedicata alla Madonna degli Angeli.
An implementation of two different Structure From motion algorithms developed in ''Matlab'', with result analysis and elaboration. The sequences used for this work are from John Hopkins University Computer Vision Lab, the Hopkins 155 Database, <ref name="Hopkins" /> that consist in different scenes with feature matrices tracked in all frames and subdivided for different bodys. In this work fundamental steps to resolve the Structure From Motion Problem factorization are explained, with both result's and plot analysis, for 3D shape reconstruction and rotation in all the scene.
== Descrizione ==
La chiesa è stata costruita nel 1513 su un alto colle sulla sponda orientale del fiume [[Vomano]]. L’interno è stato costruito da un’unica auletta.
 
==Voci Theory correlate==
*[[Valle del Vomano]]
*[[Scorrano (Cellino Attanasio)]]
== Collegamenti esterni ==
* {{cita web|url=http://www.paesiteramani.it/paesi/ScorranoSBiagio.htm|titolo= Chiesa dei SS.Biagio e Nicola (Scorrano di Cellino Attanasio)|accesso=21 giugno 2014}}
* {{cita web|url=http://www.paesiteramani.it/paesi/ScorranoSBiagio.htm|titolo=Chiesa dei SS. Biagio e Nicola a Scorrano|accesso=21 giugno 2014}}
* {{cita web|url=http://foto.inabruzzo.it/provincia%20Teramo/S-Z/Scorrano/index.html|titolo=Scorrano (Cellino Attanasio)|accesso=21 giugno 2014}}
== Altri progetti ==
{{interprogetto|commons=Category:Scorrano di Cellino Attanasio}}
 
=== Tomasi-Kanade (1992) - Orthographic Factorization ===
 
[http://mmlab.science.unitn.it/wiki/index.php/Structure_from_Motion#Factorization See Tomasi-Kanade orthographic factorization]
 
[[Categoria:Chiese della provincia di Teramo|SS.Biagio e Nicola]]
=== Poelman-Kanade (1997) - Paraperspective Factorization <ref name="PK" />===
 
The method proposed by Tomasi & Kanade takes advantage of the linear algebraic properties of orthographic projection. This method is very robust and efficient, but there are some limitations. The applicability of the method is actually limited to image sequences created from certain types of camera motions. The orthographic model contains no notion of the distance from the camera to the object.
As a result, shape reconstruction from image sequences containing large translations toward or away from the camera often produces deformed object shapes, as the method tries to explain the size differences in the images by creating size differences in the object. The method also supplies no estimation of translation along the camera’s optical axis, which limits its usefulness for certain tasks.
 
In 1997 Conrad J. Poelman & Takeo Kanade developed a factorization method based on the Paraperspective projection model. This kind of method accounts for the scaling effect as well as the different angle from which an object is viewed as it moves in a direction parallel to the image plane.The paraperspective factorization method is still fast, and robust with respect to noise. It can be applied to a wider realm of situations than the orthographic factorization method, such as sequences containing significant depth translation or containing objects close to the camera, and can be used in applications where it is important to recover the distance to the object in each image, such as navigation.
 
 
''' Orthographic Projection vs Paraperspective Projection '''
 
[[File:pkcameramodel.png|200px|thumb|left|World and camera reference frames <ref name="PK" />]]
 
Like in (TOMASI KANADE) we are given a set of <math>P</math> features tracked in sequence of F images taken from a camera that is moving relative to an object, recording the coordinates <math>(u_{fp}, v_{fp})</math> of each point p in each image f.
Each fearture point p tracked corresponds to a single world point, located at position <math>s_p</math> in some fixed world coordinate system. Like we see in (IMMAGINE PKCAMERAMODEL) each image f was taken at some camera orientation, which we describe by the orthonormal unit vectors vectors <math>i_f</math>, <math>j_f</math>, and <math>k_f</math>, where <math>i_f</math> and <math>j_f</math> correspond to the orizzontal and vertical axes of the camera's image plane, and <math>k_f</math> points along the camera's line of sight. We describe the position of the camera in each frame <math>f</math> by the vector <math>t_f</math> indicating the camera's focal point.
 
The Orthographic Projection model assumes that rays are projected from an object point along the directin parallel to the camera's optical axsis, so that they strike the image plane orthogonally as illustrated in (Orthographicmodel.png).
 
<ref[[File:Orthographicmodel.png|200px|thumb|right|Orthographic projection in two dimensions. Dotted lines indicate
perspective projection <ref name="PK" />]]
 
All feature point coordinates <math>(u_{fp}, v_{fp})</math> are components of the measurement matrix <math>W</math> as we can see in (8) and (9).
 
:<math>u_{fp}=m_f \cdot s_p + x_f \; \; \; v_{fp}=n_f \cdot s_p + y_f</math> --> (1.01)
 
where
 
:<math>
\begin{matrix}
x_f=-(t_f \cdot i_f) & y_f=-(t_f \cdot j_f)\\
\\
m_f=i_f & n_f=j_f
\end{matrix}
</math> --> (1.02)
 
As we saw in (10) and (11) <math>i_f</math> and <math>j_f</math> are unit orthogonal vectors, and then:
 
:<math>|m_f|^2 = 1 \; \; \; \;\;|n_f|^2 = 1</math> --> (1.03)
 
and because they are orthogonal
 
:<math>m_f \cdot n_f = 0 </math> --> (1.04)
 
Equations (1.03) and (1.04) gives us 3F equations which we call the metric constraint (16).
As we said before orthographic model does not produce accurate results when there is significant translation along the camera's optical axsis, because orthography does not account for the fact that an object appears larger when it is closer to the camera. The orthographic model actually does not take account of the <math>k_f</math> coordinate, that in the real scenes shows great variations if the motion of the object is in direction of the camera's line of sight.
 
The Paraperspective Projection closely approximates perspective projection by modeling both the scaling effect (closer objects appear largher than distant ones) and the position effect (objects in the periphery of the image are viewed from a different angle than thos near the center of projection while retaining the linear properties of orthographic prohjection. The paraperspective projection of an object onto an image, illustrated in (Paraperspectivegraphicmodel.png), involves two steps:
* An object point is projected along the direction of the line connecting the focal point of the camera to the object’s center of mass, onto a hypothetical image plane parallel to the real image plane and passing through the object’s center of mass.
* The point is then projected onto the real image plane using perspective projection. Because the hypothetical plane is parallel to the real image plane, this is equivalent to simply scaling the point coordinates by the ratio of the camera focal length and the distance between the two planes.
In general, the projection of a point p along direction r, onto the plane with normal n and distance from the origin d, is given by the equation
[[File:Paraperspectivegraphicmodel.png|200px|thumb|right|Paraperspective projection in two dimensions. Dotted lines indi-
cate perspective projection. → indicates parallel lines <ref name="PK" />]]
 
:<math>p'=p-\frac{p\cdot n-d}{r\cdot n}r</math> --> (2.01)
 
In frame <math>f</math> , each object point <math>s_p</math> is projected along the direction <math>c=t_f</math> (which is the direction from the camera’s focal point to the object’s center of mass) onto the plane defined by normal <math>k_f</math> and distance from the origin <math>c \cdot k_f</math>. The result <math>s'_{p}</math> of this projection is:
 
:<math>s'_{fp}=s_p-\frac{(s_p\cdot k_f)-(c\cdot k_f)}{(c-t_f)\cdot k_f}(c-t_f)</math> --> (2.02)
 
The perspective projection of this point onto the image plane is given by subtracting <math>t_f</math> from <math>s'_{fp}</math> to give the position of the point in the camera's coordinate system, and then scaling the result by the ratio of the camera's focal length <math>I</math> to the depth to the object's center of mass <math>z_r</math> Adjusting for the aspect ratio a and projection center <math>(0_x, 0_y)</math> yields the coordinates of the prohection in the image plane.
 
:<math>u_{fp}=\frac{l i_f}{z_f}(s'_{fp}-t_f)+0_x\; \; \; v_{fp}=\frac{la j_f}{z_f}(s'_{fp}-t_f)+0_y \;\;\; \text{where} \;\;\; z_f=(c-t_f)\cdot k_f</math> --> (2.03)
 
Substituting (2.02) in (2.03) and simplifying gives the general paraperspective equations for <math>u_{fp}</math> and <math>v_{fp}</math>
 
:<math>\begin{matrix}
u_{fp}=\frac{l}{z_f} \left \{ \left[i_f-\frac{i_f \cdot(c-t_f)}{z_f}k_f \right ]\cdot (s_p-c)+(c-tf)\cdot i_f \right \}\\
\\
v_{fp}=\frac{l}{z_f} \left \{ \left[j_f-\frac{j_f \cdot(c-t_f)}{z_f}k_f \right ]\cdot (s_p-c)+(c-tf)\cdot j_f \right \}
\end{matrix}</math> --> (2.04)
 
Assuming for semplicity focal length <math>l=1</math>.
Without loss of generality we can simplify our equations by placing the world origin at the object’s center of mass with
 
:<math>c=\frac{1}{P}\sum^P_{p=1}s_p</math> --> (2.05)
 
This reduces (2.05) to:
 
:<math>
\begin{matrix}
u_{fp}=\frac{1}{z_f} \left \{ \left[i_f+\frac{i_f \cdot t_f}{z_f}k_f \right ]\cdot s_p-(tf\cdot i_f) \right \}\\
\\
v_{fp}=\frac{1}{z_f} \left \{ \left[j_f+\frac{j_f \cdot t_f}{z_f}k_f \right ]\cdot s_p-(tf\cdot j_f) \right \}
\end{matrix}
</math> --> (2.06)
 
These equations can be rewritten as:
 
:<math>u_{fp}=m_f \cdot s_p + x_f \; \; v_{fp}=n_f \cdot s_p + y_f</math> --> (2.07)
 
where
 
:<math>z_f = -t_f \cdot k_f</math> --> (2.08)
 
:<math>x_f = - \frac{t_f \cdot i_f}{z_f} \; \; \; \; y_f = - \frac{t_f \cdot i_f}{z_f}</math> --> (2.09)
 
:<math>m_f = \frac{i_f - x_f k_f}{z_f} \; \; \; \; n_f = \frac{j_f - y_f k_f}{z_f}</math> --> (2.10)
 
Notice that (2.07) has a form identical to its counterpart for orthographic projection, (9), although the corresponding definitions of <math>x_f</math>, <math>y_f</math>, but <math>m_f</math> and <math>n_f</math> differ. This enables us to perform basic decomposition of the matrix in the same manner that Tomasi and Kanade did for orthographic projection.
 
 
''' Paraperspective Decomposition '''
 
Like in the orthographic projection model <math>W</math> can be decomposed into the single matrix equation:
 
:<math>W = MS + T[1 \dots 1]</math> --> (3.01)
 
where <math>W</math> is the <math>2xF</math> measurement matrix, M is the <math>2Fx3</math> motion matrix (same as R in orthographic model), and <math>S</math> is the 3xP shape matrix, and <math>T</math> is the <math>2Fx1</math> translation vector.
We can now proceed exactly like in the Tomasi-Kanade's factorization method obtaining the ''registered measurement matrix'' and then applying Singular Value Decomposition to obtain the best rank three approximation of the ideal <math>\hat{W}^{*}</math> (RIFERIMENTI)
 
:<math>W^* = \hat{M} \hat{S} </math> --> (3.02)
 
 
''' Normalization '''
Just as in the orthographic case, the decomposition of <math>W^*</math> is only determined up to a linear transformation Q. Again, we determine this matrix Q by observing that the rows of the motion matrix M (the <math>m_f</math> and <math>n_f</math> vectors) must be of a certain form.
Taking advantage of the fact that <math>i_f</math>, <math>j_f</math> and <math>k_f</math> are unit vectors, from are unit vectors, from (2.10) we observe that
 
:<math>|m_f|^2 = \frac{i_f + x_f^2}{z_f^2} \; \; \; \; |n_f|^2 = \frac{i_f + y_f^2}{z_f^2}</math> --> (4.01)
 
We know the values of <math>x_f</math> and <math>y_f</math> from our initial registration step, but we do not know the
value of the depth <math>z_f</math>. Thus we cannot impose individual constraints on the magnitudes of <math>m_f</math> and <math>n_f</math> as was done in the orthographic factorization method. Instead we adopt the following constraint on the magnitudes of <math>m_f</math> and <math>n_f</math>.
 
:<math> \frac{|m_f|^2}{i_f + x_f^2} = \frac{|n_f|^2}{i_f + y_f^2} \; \; \; \; \left(=\frac{1}{z_f^2}\right)</math> --> (4.02)
 
In the case of orthographic projection, one constraint on <math>m_f</math> and <math>n_f</math> was that they each have unit magnitude, as required by equation (16). In the above paraperspective case, we simply require that their magnitudes be in a certain ratio.
 
There is also a constraint on the angle relationship of <math>m_f</math> and <math>n_f</math>. From equation (2.10), and the knowledge that <math>i_f</math>, <math>j_f</math>, and <math>k_f</math> are orthogonal unit vectors,
 
:<math>m_f \cdot n_f = \frac{i_f-x_fk_f}{z_f} \cdot \frac{j_f-y_fk_f}{z_f} = \frac{x_fy_f}{z_f^2}</math> --> (4.03)
 
The problem with this constraint is that, again, <math>z_f</math> is unknown. We could use either of the
two values given in equation (4.02) for <math>1/z_f^2</math>, but in the presence of noisy input data the two will not be exactly equal, so we use the average of the two quantities. We choose the arithmetic mean over the geometric mean or some other measure in order to keep the solution of these constraints linear. Thus our second constraint becomes
 
:<math>m_f \cdot n_f = x_fy_f\frac{1}{2}\left ( \frac{|m_f|^2}{1 + x_f^2} + \frac{|n_f|^2}{1 + y_f^2}\right)</math> --> (4.04)
 
This is the paraperspective version of the orthographic constraint given by equation (16), which required that the dot product of and be zero.
 
Equations (4.02) and (4.04) are homogeneus constraints, which could be trivially satisfied by the solution <math>\forall f\; \; m_f=n_f=0</math>, or <math>M=0</math>. To avoid this solution, we impose the additional constraint
 
:<math>|m_1|=1</math> --> (4.05)
 
This does not effect the final solution except by a scaling factor.
 
Imposing this constraint now it's easy to compute the <math>Q</math> matrix and find the best approximations of real ''rotation matrix'' <math>M</math> and ''shape matrix'' <math>S</math> and finally compute the Structure From Motion.
 
=== Appendix: Morita and Kanade - Constraint solution ===
 
In <ref name="MK" /> Morita and Kanade proposed a method that could be used to solve 3F overdetermined system (16) and the one formed by (4.02),(4.04):
 
:<math>L=QQ^T \; \; \; \;
L=\begin{bmatrix}
l_1 & l_2 & l_3\\
l_2 & l_4 & l_5\\
l_3 & l_5 & l_6
\end{bmatrix}</math> --> (5.01)
where <math>G \in \mathbb{R}^{3Fx6}</math>, <math>l \in \mathbb{R}^{6}</math>, and <math>c \in \mathbb{R}^{3F}</math>
:<math>
G=\begin{bmatrix}
g^T(i_1,i_1)\\
\vdots \\
g^T(i_F,i_F)\\
g^T(j_1,j_1)\\
\vdots \\
g^T(j_F,j_F)\\
g^T(i_1,j_1)\\
\vdots \\
g^T(i_F,j_F)\\
\end{bmatrix},
\;
l =\begin{bmatrix}
l_1\\
\vdots
l_6
\end{bmatrix}, \;
c=\begin{bmatrix}
1\\
\vdots \\
\vdots \\
\vdots \\
\vdots \\
1\\
0\\
\vdots \\
0\\
\end{bmatrix}, \; \; \; \; \text{where} \; \; \; \; Gl=c
</math>
and
:<math>g^T(a_f,b_f)=[a_{f1}b_{f1},\;
a_{f1}b_{f2}+a_{f2}b_{f1} ,\;
a_{f1}b_{f3}+a_{f3}b_{f1},\;
a_{f2}b_{f2}, \;
a_{f2}b_{f3}+a_{f3}b_{f2},\;
a_{f3}b_{f3}
]</math> --> (5.02)
 
The simplest solution of the system is given by the pseudo inverse method, such that
 
:<math>l=(G^TG)^{-1}G^Tc</math> --> (5.03)
 
==Matlab Implementation==
Below the ''Matlab'' implementation of the two factorization method is briefly explained with a discussion of the results.
 
In the first step different kind sequences are loaded with the features tracked in ''Measurement Matrix'' from <ref name="Hopkins" />.
 
[[File:Step1LoadSeq.png|200px|thumb|left|Step 1: Load Sequence with Tracked features]]
 
Then the ''Measurement Matrices'' for each body in the scene are composed with truth segmentation matrix.
 
[[File:Step2Segmentation.png|200px|thumb|left|Step 1: Load Sequence with Tracked features]]
 
After the initial ''loading'' steps ''Registered Measurement Matrices'' are computed for each body, subtracting the mean of the coordinates in every frame to project them in centroid centered system.
 
<pre>
%Registered Measurement Matrix
W1_mean = mean(W1, 2)
W1_reg = W1 - repmat(W1_mean, 1, size(W1, 2));
</pre>
 
Now <math>W</math> matrices of each body are ready to be eleborated in factorization methods individually.
 
== Factorizations ==
 
The first steps for each factorization are the same:
 
First of all Singular Value Decomposition is computed to obtain <math>\hat R</math> and <math>\hat S</math> that are the two matrices that after we have to linear transform to obtain real ''Rotation Matrix'' and ''Shape Matrix''
 
<pre>
% Singular Value Decomposition
[O1, Sigma, O2T] = svd(W_reg, 'econ');
O2 = O2T';
 
% Computing of R and S hat (R_n, S_n)
R_n = O1(:, 1:3) * sqrt(Sigma(1:3, 1:3));
S_n = sqrt(Sigma(1:3, 1:3)) * O2(1:3, :);
 
t = W_mean;
x = t (1:F);
y = t (F+1:2*F);
i_nT = R_n(1:F, :);
j_nT = R_n(F+1:2*F, :);
</pre>
 
Now the constraint has to be imposed to compute orthographic or paraperspective prohection method.
 
''' Tomasi-Kanade - Orhographic metric constraint '''
The 3F overdetermined system (16) has to be solved with Morita and Kanade <ref name="MK" />
 
<pre>
% Costruzione sistema in via matriciale
G = [gT(i_nT, i_nT); gT(j_nT, j_nT); gT(i_nT, j_nT)];
%imposizione dei termini noti (vincoli)
c = [ones(2*F, 1); zeros(F, 1)];
 
I = pinv(G) * c;
 
L = [I(1) I(2) I(3);
I(2) I(4) I(5);
I(3) I(5) I(6)];
</pre>
 
<pre>
%% Costruzione matrice Q
 
% Imposizione simmetria matrice L
L = (L + L') / 2;
[V, D] = eigs(L); % decomposizione autovalori L = V*D*V';
</pre>
 
=References=
<!--Cognome e nome autore (anno), "titolo articolo", titolo della rivista, luogo di edizione, casa editrice, volume, numero, (giorno), (mese), numero di pagina iniziale e finale-->
<references>
 
<ref name="PK">* Conrad J. Poelman, Takeo Kanade (1997), "A Paraperspective Factorization Method for Shape and Motion Recovery", Journal IEEE Transactions on Pattern Analysis and Machine Intelligence archive, Volume 19 Issue 3</ref>
 
<ref name="MK">* Toshihiko Morita, Takeo Kanade (1997), "A Sequential Factorization Method for Recovering Shape and Motion From Image Streams", Journal IEEE Transactions on Pattern Analysis and Machine Intelligence archive, Volume 19 Issue 3</ref>
 
<ref name="Hopkins">* [http://www.vision.jhu.edu/data/hopkins155/ John Hopkins University Computer Vision Lab, Hopkins 155 Dataset]</ref>
<references/>