\documentstyle[12pt,fullpage,psfig]{article}
\input{psfig}

\newcommand{\lecturetitle}[4]{
  \noindent
  CS 294, 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{17}{Recognition}{Oct. 25, 1999}{Dimitri Chernyak}

% INCLUDE AN OUTLINE OF THE CLASS TOPICS
\begin{itemize} 
  \item What is recognition?
  \item How do we recognize things?
  \item Bayesian categorization approach.
\end{itemize}

% THE NOTES WILL GO HERE

\section{What is recognition}

Recognition, (from RE - Cognize) is a term used to describe an ability to identify things based on prior knowledge. 

\subsection{Recognition is a hard task} 
The problem of recognition is hard due to many sources of variability:

1.	{\bf Each object in the class exibits variability\/}. What is a dog or a chair? \newline

2.	{\bf There is variability in lighting between instances of the same object\/}. Simple intensity matching will not work.\newline

3.	{\bf Variation in pose\/}. Orientation and position of object with respect to camera or observer. \newline


\subsection{What enables recognition}

Most object have specific characteristic features. Features can be visual (color, shape, texture, motion) or non-visual (smell, taste, sound, etc.).

\section{How do we recognize things}

A question that can be asked about recognition, is whether it is based on function or categoryzation.  There are two basic approaches to this, - {\bf affordance\/} and {\bf categorization\/}.
\subsection{Affordance}

Affordance, proposed by Gibson, postulates two assumptions:\newline
$\bullet$ Memory is not needed for recognition. Just the "bottom-up", geometric information obtained from a scene is sufficient.\newline
$\bullet$ Objects are recognized by their function, as suggested by their geometry. For example, a chair can be recognized as a flat surface of correct height that can support human weight, etc. 

However, some objects are similar in geometric properties, but different in function (mailbox vs. trash can).

\subsection{Categorization}

Categorization is approach advocated by most of the scientific community. It is based on the following principles:\newline
$\bullet$ Entities are learned from examples (by label association).\newline
$\bullet$ The examples can be generalized to categories or classes. 

\begin{figure*}[t]
\centerline{\hbox{
\psfig{file=fig1.eps,height=2.0in}}}
\vspace*{.05in}
\caption{Object hierarchies}
\label{fig1}
\end{figure*}

Each object belongs to multiple categories that have hierarchical structure (Figure \ref{fig1}) .

"Basic Category" is the level of hierarchy that is recognized the fastest. This natural category depends on the observer and his/her expertise with the subject area.

\section{Bayesian categorization approach}

How to classify patterns or features? We adopt Baesian approach. Let there be two classes $C_{1}$ and $C_{2}$. Let $x$ be a feature vector. For simplisity we assume that $x$ is scalar. For example categories can be male and female and the feature variable $x$ is the person's height.

We can define probability distribution of feature $x$, given the class as $P(x|C_{1})$  and $P(x|C_{2})$. These probabilities are infered from the data. Priors, $P(C_{1})$ and $P(C_{2})$ represent relative frequencies of the two classes. Using Bayes theorem:\newline \newline
$P(C_{1}|x) = \frac{P(x|C_{1})P(C_{1})}{P(x)}$ and $P(C_{2}|x) = \frac{P(x|C_{2})P(C_{2})}{P(x)}$\newline\newline
If there are only two possible classes, like in this example, we can rewrite $P(C_{1}|x)$ as:\newline\newline
$P(C_{1}|x) = \frac{P(x|C_{1})P(C_{1})}{P(x|C_{1})P(C_{1})+P(x|C_{2})P(C_{2})} = \frac{1}{1+\frac{P(x|C_{2})P(C_{2})}{P(x|C_{1})P(C_{1})}}$ \newline\newline
Define $z = ln(\frac{P(x|C_{1})P(C_{1})}{P(x|C_{2})P(C_{2})})$, so that:\newline \newline
$P(C_{1}|x) = \frac{1}{1+e^{-z}}$\newline \newline
$z$ is called log-likelihood ratio, and the conditional probability is a logistic function of $z$. It is plotted on figure \ref{fig2}.

\begin{figure*}[t]
\centerline{\hbox{
\psfig{file=fig2.eps,height=4.0in}}}
\vspace*{.05in}
\caption{Logistic function}
\label{fig2}
\end{figure*}

Sometimes, the posterior distribution $P(C_{1}|x)$ can be learned directly from data, but first we consider a special case, when $P(x|C_{1})$ is a Gaussian distribution. The class conditional probabilities can be arbitrary, but Gaussian distribution model allows simple mathematical framework. \newline \newline
Let $P(x|C_{1}) = \frac{1}{\sqrt{2*\pi}\sigma}e^{-\frac{1}{2}(\frac{x-\mu_{1}}{\sigma})^2}$ and $P(x|C_{2}) = \frac{1}{\sqrt{2*\pi}\sigma}e^{-\frac{1}{2}(\frac{x-\mu_{2}}{\sigma})^2}$. Then,\newline \newline
$z = ln(\frac{P(x|C_{1})P(C_{1})}{P(x|C_{2})P(C_{2})}) = ... = (\frac{\mu_{1}-\mu_{2}}{\sigma^{2}})x + ln(\frac{P(C_{1}}{P(C_{2}}) + \frac{\mu_{1}^2 + \mu_{2}^2}{2\sigma^{2}}$\newline \newline

Let $\mu_{1} > \mu_{2}$. Figure \ref{fig3} shows the plot of the distributions.

\begin{figure*}[t]
\centerline{\hbox{
\psfig{file=fig3.eps,height=4.0in}}}
\vspace*{.05in}
\caption{Probability distributions}
\label{fig3}
\end{figure*}

Setting a threshold for classification is a trade-off between false positives and misses. If the $\sigma$'s of the distributions are equal and the desision criteria is optimaly set, probability of misclassification can be given as:

$P(misclassification) = P(C_{2})\int_{\frac{\mu_{1} + \mu_{2}}{2}}^{\infty} P(x|C_{2})\ + P(C_{1})\int_{-\infty}^{\frac{\mu_{1} + \mu_{2}}{2}} P(x|C_{1})\ $\newline
i.e. it depends on the "overlap" of the distributions for the two classes.\newline

There are two basic approaches to classify the input data: {\bf generative\/} and {\bf discriminative\/}.

Approach A: Generative.\newline
$\bullet$ Guess suitable models for $P(x|C_{1})$ and $P(x|C_{2})$. Estimate parameters from the data.\newline
$\bullet$ For a sample to be classified compute $P(C_{1}|x)$.\newline
$\bullet$ Declare $C_{1}$ if $P(C_{1}|x) > 0.5$, and otherwise $C_{2}$.\newline

Approach B: Discriminative.\newline
$\bullet$ Learning posterior probability distributions directly.\newline

For many distributions, including but not limited to Gaussian, we can write $z = w_{1}x+w_{2}$ and $P(C_{1}|x) = \frac{1}{1+e^{-z}}$\newline 

A single layer perceptron neural network can be build to estimate the weights $w_{1}$ and $w_{2}$ (figure \ref{fig4}) from training examples \{$x_{i}, (0,1)_{i}$\}. This is called supervised learning.

\begin{figure*}[t]
\centerline{\hbox{
\psfig{file=fig4.eps,height=4.0in}}}
\vspace*{.05in}
\caption{Single layer perceptron}
\label{fig4}
\end{figure*}

Weights can be estimated using gradient descent for SLP. Alternatively, nearest neighbor approach can be used to classify the data using appropriate metric for the input space.

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


\end{document}

