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

\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{20}{Texture Discrimination and Edge Detection}
{April 7, 1999}{Shawn Hsu}

% INCLUDE AN OUTLINE OF THE CLASS TOPICS

\begin{itemize} 
  \item Texture Discrimination

\item Edge Detection
\end{itemize}

% THE NOTES WILL GO HERE

This lecture was given by Thomas Leung.  His office is in 485 Soda and his email is
leungt@cs.berkeley.edu.

\section{Texture Discrimination}
\subsection{Textons}
{\bf Textons} are used to differentiate regions with different textures or patterns.
Three characteristics of textons are used:

\begin{figure}[h]
\centerline {\psfig{file=fig1.eps,height=1in}}
\caption{Textons}
\label{Textons}
\end{figure}


%\begin{figure}[h]
%\centering
%\mbox {
%\subfigure[Rotation around Y axis]{\psfig{file=hw1/ry.eps,height=2.5in}} \quad
%\subfigure[Translation along X axis]{\psfig{file=hw1/tx.eps,height=2.5in}}
%}
%\caption{Bas-Relief Ambiguity}
%\label{rtambig}
%\end{figure}

\subsection
{Pre-attentive texture discrimination} (10ms - 30ms)

\begin{itemize}

\item Not much reasoning is possible 

\item Most of the image processing is done by V1

\end{itemize}

V1 cells respond to:

\begin{itemize}

\item {\bf Oriented Edges}
$(Rot_\theta \hspace{1em} G_{\sigma_1}(x)  G^{'}_{\sigma_2}(y))$

\item {\bf Oriented Bars} 
$(Rot_\theta \hspace{1em} G_{\sigma_1}(x)  G^{''}_{\sigma_2}(y))$
\item {\bf Dots}
$(Rot_\theta \hspace{1em} G^{'}_{\sigma_1}(x)  G^{''}_{\sigma_2}(y))$
\end{itemize}

\begin{figure}[h]
\centerline {\psfig{file=fig2.eps,height=2in}}
\caption{Texture Discrimination Example}
\label{fig2}
\end{figure}

\begin{figure}[h]
\centerline {\psfig{file=fig3.eps,height=2in}}
\caption{Cross Section}
\label{fig3}
\end{figure}

\section {Edge Detection}
\subsection {Edge Detection in Different Orientations}

If there is an edge in any of the channels in Figure \ref{fig4}, then you 
declare an edge in the image.  The edge detectors are arrayed in 
different orientations.
This is done to detect edges in the different orientations.

\begin{figure}[h]
\centerline {\psfig{file=fig4.eps,height=3in}}
\caption{Edge Detection in Different Orientations}
\label{fig4}
\end{figure}

\subsection {Using histograms to detect edges}

Since we smooth the images, images that have the same mean would end
up looking the same, even though they can have different edges (See Figure 
\ref{fig5}).

\begin{figure}[h]
\centerline {\psfig{file=fig5.eps,height=1.5in}}
\caption{Problem with Differentiating Images with the Same Mean}
\label{fig5}
\end{figure}

Therefore, instead of looking at the mean, we look at the distribution
of intensity values.  We use histograms to determine the intensity values 
which occur the most frequent in the image.  As shown in Figure \ref {fig6},
the two images have the same mean (0.8), but it's obvious that the 
two images are not the same.  If we 
just use regular smoothing, then we would not be able to detect any difference
between the first image and the second image.  However, we can use histograms 
to see a difference between these images.  The histograms show that the first 
image contains many pixels with intensity values around 0.5 and 1, 
while the second image has pixels with intensity values around 0.8.  

\begin{figure}[h]
\centerline {\psfig{file=fig6.eps,height=3in}}
\caption{Two Images with the Same Mean}
\label{fig6}
\end{figure}

We can use Chi-Square ($X^2$) for comparing histograms:

\begin{eqnarray}
d(h_1,h_2) &=& \sum_{n = 1}^{N} \frac{[h_1(n) - h_2(n)]^2} {[h_1(n) + h_2(n)]}
\end{eqnarray}

$h_1$ : first image \newline
$h_2$ : second image \newline
N : number of bins \newline

We plot a histogram for each section of the image, by sampling the image 
using different windows.  
The edges occur where the histogram changes between two
successive windows. 


\subsection {Elongated Filters}

Rule of Thumb:  for $G_{\sigma_1}(x) \hspace{0.5em} and \hspace{0.5em}
G^{'}_{\sigma_2}(y)$, the ratio of $\sigma_1 : \sigma_2$ is 3:1

\vspace {0.5cm}

Suppose we have:
\begin {itemize}

\item Edges with contrast [0...5].  Contrast is the difference 
between pixel intensity.

\item Noise with mean of 0 and $\sigma = \frac{1} {2 \sqrt{2}}$

%\begin{eqnarray}
$\sum_{i = 1}^{N} r_i = N(0,\sqrt{N} \sigma)$
%\end{eqnarray}

if $r_i$ = N(0,$\sigma$)
\end {itemize}

If we use the filter shown in part (A) of Figure \ref{fig9}
we get the equation $x_2 - x_1 = N(0,\frac{1}{2})$ just from the noise.
If we set threshold to 1, then we would miss 20\% of the edges, and 
get about 5\% false positives (2 standard deviations from the mean).
If we set threshold to 1.5, then the miss rate becomes 30\%, and false 
positives 1\% (about 3 std away from mean).
We want to push the curve down, to the ideal spot where there would be
no misses and no false positives (shown in Figure \ref{fig7}).

\begin{figure}[h]
\centerline {\psfig{file=fig7.eps,height=2in}}
\caption{Misses to False Positives Plot}
\label{fig7}
\end{figure}


\begin{figure}[h]
\centerline {\psfig{file=fig8.eps,height=2in}}
\caption{Sample Image}
\label{fig8}
\end{figure}


\begin{figure}[h]
\centerline {\psfig{file=fig9.eps,height=1.0in}}
\caption{Comparison of Two Filters}
\label{fig9}
\end{figure}

Now let's look at an elongated filter like the one in part (B) of 
Figure \ref{fig9}.  What kind of result will we get if we use this
filter on an image like the one in Figure \ref{fig8}?
Filter (b) has a reponse to edge of $4*(step size)$.  Since the step size
is equal to 5, the response to edge is from 0 to 20.  
If we use threshold = 2, the 
percentage of misses is 10\%, and false positives 5\%.  If we raise the 
threshold to 3, the miss rate becomes 15\% and false positives 1\%.  This
pushes the curve down.

\vspace{.5cm}

SNR (Signal to Noise Ratio) gets better as false positives and misses 
decrease.  However, if the length of the filter is too long, then 
there would be problems at edges and curved boundaries.  Therefore, the
rule of thumb is 3:1 for $\sigma_1:\sigma_2$.


\end{document}


