\documentclass[12pt]{article}
%\usepackage{subfigure}
\usepackage{graphicx}
\usepackage{psfrag}
\usepackage[hang,sl,bf,small]{caption}
%\thispagestyle{empty}

\newcommand{\lecturetitle}[4]{
  \noindent
  CS 280, Computer Vision (Prof. Jitendra Malik) \hfill #3\\
  Lecture \##1 (#2) \hfill {\bf DRAFT} Notes by #4\\[-.05in]
  \mbox{}\hrulefill \mbox{}\\}

\begin{document}

% MODIFY THE FOLLOWING TO INCLUDE THE LECTURE #, TOPIC, DATE, and YOUR NAME
\lecturetitle{22}{Measurement of Disparity}{April 14, 1999}{Ye Sheng}

% INCLUDE AN OUTLINE OF THE CLASS TOPICS

\begin{itemize} 
    \item Disparity measurement approaches
        \begin{itemize} 
          \item Discrete(block) Matching Approaches
          \item Differential Approaches(not good)       
          \item Epipolar Constraint Approaches
          \item Ordering Constraint Approaches
          \item Piecewise Smoothing Approaches
          \item Uniqueness Constraint Approaches
        \end{itemize}
    \item Algorithms that have been used
        \begin{itemize} 
          \item Area Matching
          \item Edge Matching
        \end{itemize}

\end{itemize}


% THE NOTES WILL GO HERE


\section{Disparity Measurement}

\subsection{Discrete(block) Matching Approaches} 
As shown in Fig.(\ref{fig:1}), this method computs matching error $E$ between two images. It finds $(u,v)$ which minimize the error, i.e.:
\begin{equation}
       \  (u,v)  =  \min_{u,v} \{E\}             
\label{equ:1} 
\end{equation}   
Where, the matching error $E$ will be defined in section {\bf $1.3$}.

\subsection{Differential Approaches (not good)}
This method assume the brightness is conserved, and:
\begin{equation}
       \  E_{x}u+E_{y}v+E_{t}  =  0             
\label{equ:2} 
\end{equation}   

There is 1 equation and 2 unknowns---Aparture problem.



\begin{figure}
\centering
\includegraphics[height=1.8in,width=4in]{csfig_1.eps}
\caption{Block matching strategy}
\label{fig:1}
\end{figure}


{\bf Lucas Kanade:}
\begin{figure}
\centering
\psfrag{Assume}[][]{assume $u$,$v$ be constant in the block}
\includegraphics[height=2in,width=5.0in]{csfig_2.eps}
%\includegraphics* {csfig_2.eps}
\caption{A typical block}
\label{fig:2}
\end{figure}


As shown in Fig.(\ref{fig:2}), assume $u, v$ be constant in the block. Thus 
there are totally 9 equations and two unknowns for the 9 pixels in the block, i.e.:
\begin{eqnarray*}
    E_{x}^{1}u+E_{y}^{1}v+E_{t}^{1}  =  0  \\
    \vdots \\
    E_{x}^{9}u+E_{y}^{9}v+E_{t}^{9} =  0  \\   
\end{eqnarray*}

{\bf How to get $E_{x}$, $E_{y}$ and $E_{t}$?}
\begin{figure}
\centering
\psfrag{Ex}[][]{$E_{x}=\frac{40-70}{2}=-15$}
\includegraphics[height=2in,width=4in]{csfig_6.eps}
%\includegraphics*{csfig_6.eps}
\caption{How to calculate $E_{x}$}
\label{fig:6}
\end{figure}
As shown in Fig.(\ref{fig:6}), $E_{x}$  = $\frac{40-70}{2}$ = $-15 $.\\

{\bf Note:}
 \begin{itemize} 
          \item Digital way to get derivatives
          \item Smooth the image first in order to get bette results (i.e. small noise)\\
 \end{itemize}

{\bf There are some points we must pay attention to:}

\begin{figure}
\centering
\psfrag{p}[][]{$p$}
\psfrag{pp}[][]{$p'$}
\includegraphics[height=2in,width=4in] {csfig_3.eps}
%\includegraphics* {csfig_3.eps}
\caption{Lambertian condition}
\label{fig:3}
\end{figure}

\begin{itemize}
  \item As shown in Fig.(\ref{fig:3}), consider only moving of cameras, and if it's Lambertian, then the brightness is conserved. 
  \item Note for uniform white board, then  $E_{x}$, $E_{y}$ and $E_{t}$=$0$, there is no useful information. 
  \item Also note that in stereo case, the differential method not good for the fact that the assumption that $u$, $v$ be constant in a block doesn't hold because the motion is large.
\end{itemize}

\subsection{Epipolar Constraint Approaches}
The idea here is using epipolar conatraint to reduce search to be along corresponding epipolar line.

\begin{figure}
\centering
\includegraphics[height=2in,width=4in] {csfig_4.eps}
%\includegraphics* {Csfig4.eps}
\caption{The relationship between two cameras}
\label{fig:4}
\end{figure}

As shown in Fig.(~\ref{fig:4}), in stereosis, typically the geometry 
relationship between the two cameras are known. $\Rightarrow$ {\bf Epipolar
Constraint} can be used. Corresponding points in two planes lie on 
corresponding e[ipolar lines. And now we can search in 1-dimension instead
of 2-dimension.

\begin{figure}
\centering
\psfrag{p}[][]{$P$ }
\psfrag{C1}[][]{$C_{1}$ }
\psfrag{C2}[][]{$C_{2}$ }
\psfrag{C1,C2 be the optical centers of cameras}[][]{$C_{1}$,$_{2}$ be
  the optical centers of cameras }
\includegraphics[height=2.8in,width=4in] {csfig_5.eps}
\caption{Illustration of epipolar constraint}
\label{fig:5}
\end{figure}
As shown in Fig.(~\ref{fig:5}), from the fact that the point should lie in  the Epipolar line we can get another equation.

\begin{figure}
\centering
\psfrag{I}[][]{$I$ }
\psfrag{p}[][]{$p$ }
\psfrag{q1}[][]{$q_{1}$ }
\psfrag{q2}[][]{$q_{2}$ }
\psfrag{q3}[][]{$q_{3}$ }
\psfrag{aI}[][]{$\alpha I$+$\beta$ }
\includegraphics[height=1.5in,width=4in]{csfig_7.eps}
%\includegraphics* {Csfig7.eps}
\caption{An example of epipolar constraint}
\label{fig:7}
\end{figure}
As shown in Fig.(\ref{fig:7}), we can now search only on the line!

{\bf Blocking matching error criterion:}
\begin{figure}
\centering
\psfrag{v1}[][]{$v_{1}$ }
\psfrag{v2}[][]{$v_{2}$ }
\psfrag{v3}[][]{$v_{3}$ }
\psfrag{v4}[][]{$v_{4}$ }
\psfrag{v5}[][]{$v_{5}$ }
\psfrag{v6}[][]{$v_{6}$ }
\psfrag{v7}[][]{$v_{7}$ }
\psfrag{v8}[][]{$v_{8}$ }
\psfrag{v9}[][]{$v_{9}$ }

\psfrag{w1}[][]{$w_{1}$ }
\psfrag{w2}[][]{$w_{2}$ }
\psfrag{w3}[][]{$w_{3}$ }
\psfrag{w4}[][]{$w_{4}$ }
\psfrag{w5}[][]{$w_{5}$ }
\psfrag{w6}[][]{$w_{6}$ }
\psfrag{w7}[][]{$w_{7}$ }
\psfrag{w8}[][]{$w_{8}$ }
\psfrag{w9}[][]{$w_{9}$ }

\psfrag{p}[][]{$p$ block }
\psfrag{q}[][]{$q$ block }


\psfrag{v}[][]{$\vec v$ \in $R^{9}$ }
\psfrag{w}[][]{$\vec w$ \in $R^{9}$ }
\includegraphics[height=2.1in,width=4in]{csfig_8.eps}
%\includegraphics* {csfig_8.eps}
\caption{Two blocks and their elements}
\label{fig:8}
\end{figure}


There are two kind of block matching error criterion:
\begin{itemize}
 \item Sum of Squared Diference:
\end{itemize}
\begin{equation}
       \ SSD \equiv \| \vec v-\vec w \|^{2}             
\label{equ:9} 
\end{equation}   


\begin{itemize}
 \item Normalized Cross Correlation:
\end{itemize}
\begin{equation}
       \ COR \equiv  \frac{\vec v \cdot \vec w}{\| \vec v \| \| \vec w \|}             
\label{equ:10} 
\end{equation}  

{\bf Note:}
\begin{itemize}
 \item The $SSD \neq 0$ if one bright and the other dark
\end{itemize}
\begin{itemize}
 \item Correlation is ok because there is no effect of ($I$, $\alpha I$), and in fact, this method takes into consideration of different gains of the two cameras.
\end{itemize}

\subsection{Ordering Constraint Approaches}
Ordering constraint says that if $p$ is to the left of $r$, then parter($p$) is to the left of parter($r$).


\begin{figure}
\centering
\psfrag{p}[][]{$p$}
\psfrag{q}[][]{$q$}
\psfrag{r}[][]{$r$}
\psfrag{q1}[][]{$q_{1}$}
\psfrag{q2}[][]{$q_{2}$}
\includegraphics[height=1.5in,width=3.8in]{csfig_9.eps}
%\includegraphics* {csfig_9.eps}
\caption{Illustration of ordering constraint}
\label{fig:9}
\end{figure}

As shown in Fig.(\ref{fig:9}), if $p$ is to the left of $r$, then parter($p$) is to the left of parter($r$). Note that this is true unless points lie in the forbidden zone as described later.

\begin{figure}
\centering
\psfrag{m1}[][]{$m_{1}$}
\psfrag{m2}[][]{$m_{2}$}
\psfrag{n1}[][]{$n_{1}$}
\psfrag{n2}[][]{$n_{2}$}
\psfrag{n1'}[][]{$n_{1}'$}
\psfrag{n2'}[][]{$n_{2}'$}
\psfrag{N'}[][]{$N'$}
\psfrag{C1}[][]{$C_{1}$}
\psfrag{C2}[][]{$C_{2}$}
\psfrag{M}[][]{$M$}
\psfrag{N}[][]{$N$}
\psfrag{Note}[][]{note: $n_{2}' $ left of $m_{2}$, \\ $\ n_{1}'$ right of $m_{1}$}
\includegraphics[height=3in,width=4.8in]{csfig_10.eps}
%\includegraphics* {csfig_10.eps}
\caption{Area where ordering constraint works and area it doesn't work (i.e. forbidden zone)}
\label{fig:10}
\end{figure}

As shown in Fig.(\ref{fig:10}), M is the fixation. The shadowed area is called forbidden zone in which the ordering constraint is wrong. And if M and N are on a single smooth surface, points in the shaded region can only be seen by one eye.\\
{\bf Conclusions:}
\begin{itemize}
 \item The ordering constraint is wrong in forbidden zone
 \item The ordering constraint can be used in other zone
\end{itemize}


\subsection{Piecewise Smoothing Approaches}
Note the fact that the disparity values are piecewise smooth. If two points are on same smooth surface, then nearby points will have similar disparity.
\begin{figure}
\centering
\psfrag{p}[][]{$p$ }
\psfrag{r}[][]{$r$ }
\psfrag{q1}[][]{$q$ }
\psfrag{q2}[][]{$s_{1}$ }
\psfrag{q3}[][]{$s_{2}$ }
\includegraphics[height=1.3in,width=3.8in]{csfig_11.eps}
%\includegraphics*{csfig_11.eps}
\caption{Illustration of piecewise constraint}
\label{fig:11}
\end{figure}

As shown in Fig.(\ref{fig:11}), $p$ and $q$ mathch, $r$ will match with $s_{1}$ or $s_{2}$.


\subsection{Uniqueness Constraint Approaches}
The idea is that a point in left image may match exactly one point in the
right image (except for occlusion, thus $ \leq 1$).

As shown in Fig.(\ref{fig:12}), $p$ and $r$ in the left image cannot be 
matched to the same point in the right image.



\begin{figure}
\centering
\psfrag{p}[][]{$p$ }
\psfrag{r}[][]{$r$ }
\includegraphics[height=1.3in,width=3.8in]{csfig_12.eps}
\caption{Illustration of uniqueness constraint}
\label{fig:12}
\end{figure}


\section{Algorithms That Have Been Used}
These two method are used frequently:
\begin{itemize}
  \item Area matching 
  \item Edge matching
\end{itemize}

For the problem shown in Fig.(\ref{fig:13}), you can use either area matching or edge matching to solve it.

\begin{figure}
\centering
\includegraphics[height=1.5in,width=3.8in]{csfig_13.eps}
%\includegraphics* {Csfig13.eps}
\caption{A problem that you can use either area or edge matching}
\label{fig:13}
\end{figure}




% EXAMPLE OF A PostScript FIGURE
%\begin{figure}
%\centerline{\psfig{file=lec4.eps,height=3in}}
%\caption{Illustration}
%\label{surface}
%\end{figure}


\end{document}



