\documentclass[html]{article}
\usepackage{html,fullpage}

%\newenvironment{code}{\tt \begin{verbatim}}{\end{verbatim}}

\begin{document}
\begin{center}
{\Large 
CS6640 -- Project 2 \\
Assigned Sept 12, 2013 \\
Due Sept 27 (Just before midnight) \\
}
\end{center}

\section*{Goals}
The purpose of this assignment is to develop you understanding of image histograms and histogram equalization.  

\section{Histogram Equalization}
\label{sect:HE}
\begin{enumerate}
\item  Implement a Matlab (or C++) function (you can use or build on one that already exists in the Matlab base, if you want):
{\tt
\begin{verbatim}
histogram(I, n, min, max)
\end{verbatim}
}
that takes a 2D array (or image) {\tt I} as input
and returns a 1D array of floats (length {\tt n}) that give the {\em relative} frequency of
the occurance of greyscale values in each of the {\tt n} bins that
equally 
divide the range of values between {\tt min} and {\tt max}.

\item  Implement a function
{\tt
\begin{verbatim}
histoeq(I, n, min, max)
\end{verbatim}
}
that takes a 2D array (or image) {\tt I} as input (e.g. VISImage<float> in Vispack) 
and returns an image of the same type that has undergone histogram
equalization using {\tt n} bins and has a range of outputs that spans
the range between {\tt min} and {\tt max}.
\item Use this routine to transform and enhance the following images:
\begin{enumerate}
\item \htmladdnormallink{Crowd}{../crowd.tif}
\item \htmladdnormallink{University}{../university.tif}
\item \htmladdnormallink{Cars}{../cars.tif}
\item \htmladdnormallink{Portal}{../portal.tif}
\end{enumerate}
\item 
In addition, include in your discussion 2-3 of your own greyscale
images that you think would be interesting from the point of view of
this exercise.  I.e. that have bad contrast characteristics and that might be improved by histogram equalization.
\item Show graphs of the histograms of the images before and after equalization and explain their appearance.  
\item Discuss (briefly) why histogram
equalization is or is not effective for each image.
\item 
Derive an algorithm that processes an image to return an image with a
histogram (pdf) that has at every grey level a value that is a linear
blend of the input histogram and a flat histogram.   Implement a
matlab function
{\tt
\begin{verbatim}
histoeq(I, n, min, max, alpha)
\end{verbatim}
}
where {\tt alpha} is a float between 0 and 1 and every bin is (in principle) equal to
$
\alpha H_{\rm eq} + (1 - \alpha) H_{I}.
$
Thus, for a value of {\tt   alpha} = 0, the
output equals the input and for a value of 1 the output is the same as
{\tt histoeq(I, n,)}.
Experiment and
report results on some of the images listed above.   Explain the results you get.
\end{enumerate}

\section{Adaptive Histogram Equalization}
\begin{enumerate}
\item  Implement a function
that returns the input image which has been transformed by adaptive
equalized histogram equalization using square neighborhoods (allowing
for boundaries).    The function should be
{\tt
\begin{verbatim}
AHE(I, n, windowsize)
\end{verbatim}
}
You may use whichever algorithm you
choose.  The function should treat {\tt windowsize} as an optional parameter.  If {\tt
windowsize} is left empty (set to -1) your routine should make a
reasonable choice of tile or window size based on the size of the
image, etc.  
 If you use the tiling method, then the window size parameter could be modified to fit into the image.  In this case, you should make windows as square as possible.  
Make sure that
your function is a sensibly efficient implementation (avoid obviously redundant computation) of whatever
algorithm you choose. 
\item
For the images given in \ref{sect:HE}  above (the samples given you
and the ones you bring in yourself) try adaptive histogram
equalization, with different values of window size.  
\item Discuss the time
it takes to run and its effectiveness for each image.  
\item Comment on and explain any artifacts in the results.
\end{enumerate}

\section{Clipped Local Adaptive Histogram Equalization}
Implement a version of Clipped LAHE (CLAHE).  Explain your algorithm
in the report, and if you used ideas from any outside resources.  The
clip value should be specified as an input parameter. The function
should be
{\tt
\begin{verbatim}
CLAHE(I, n, cliplevel, windowsize)
\end{verbatim}
}
Try your algorithm on a variety of images and compare against the
unclipped version.  What values of clipping are effective and why?
%\end{enumerate}

\section{Instructions, Requirements, and Restrictions}
\begin{enumerate}
\item Write your project code in a single directory, called {\tt
    project2}. 
\item For Matlab, each individual function (including functions you define) should be a ``.m'' file, and your
  functions should call one another as necessary.  Likewise, in C++ clearly separate these different functions and document how you have organized the code.  
\item Your project report will be in the form of an html file called
\underline{\tt index.html},
contained in that directory.  All links from that file must be
relative and all other files necessary to read your report must be in
that directory (or subdirectories).
\item You should use examples of images in your report.  They should
be viewable in the browser when we open your html file.
\item You will submit a single tar file created from from your project
directory with the unix command {\em tar -czf project2.tgz ./project2} or something equivalent on another operating system.
\end{enumerate}

\end{document}
