###########Play with the code

Extract the files to a directory. 
Start Matlab and move to the above directory. 
Type StartFromHere



###########Options for normalizing filter responses

localOrNot: +1 means normalizing a filter response by dividing the filter response 
by the average response pooled within a window centered at this filter. -1 means not 
using local normalization. localHalfx and localHalfy specify the half length and width 
of the local window for normalization.  
 	
windowNormalizeOrNot: when we scan the template over the testing image in the detection 
stage, at each position, we need to normalize the filter responses within the scanning 
window of the template by dividing them by the average response pooled within this 
scanning window. +1 means using window normalization, -1 means not. 

If we use local normalization, we should not use window normalization. They are kind of 
similar to each other. 
 	
Currently, we set localOrNot = -1, and windowNormalizeOrNot = 1. That is, we use 
within-window normalization in ABfind. 



###########Key parameters 

numScale: total number of scales of the Gabor filters.

scales: scales of the Gabor filters. 

numElement: number of elements. Result on classification and detection is not sensitive 
to this number. However, it is still worthwhile to play with it. 
 	
subsample: the subsample rate in learning and detection. Currently we set it at 2, you 
may set it at 1. 
 	
locationShiftLimit: the range of displacement of the Gabor element along its normal 
direction. Currently we set localShiftLimit = 3, which means the range of displacement 
is 6 pixels, because currently we set sample rate = 2. You can decrease the range to 3 
pixels or 2 pixels with subsample = 1. 
 	
saturation: saturation level for sigmoid transformation. Currently we set it at 6, you may 
increase it to favor strong edges. 
 	
resizefactor: the factor to resize all the training images. 
 	
numResolution: number of resolutions to search in detection
line -3 from bottom in ParameterCodeImage: specify the actual resolutions to search for. 



###########About the files in zip
            
StartFromHere.m : run the code. 

+++++++++++++$$$$$$$$ key .m code
            
ParameterCodeImage.m : set up parameter values, mex C code, and read in images. 
 	
ABlearn.m: Matlab code for learning active basis from images in a dictionary. 

SUM1MAX1.m: Matlab code for computing SUM1 maps and MAX1 maps of testing images. 

SUM2MAX2.m: Matlab code for computing SUM2 maps and MAX2 scores of testing images, 
for detecting and sketching objects in the testing images using the learned model, 
output from ABlearn.m. 

+++++++++++++$$$$$$$$ key .c code
 	
CsharedSketch.c: mex-C code for learning active basis. It is called by ABlearn.m. 
 
CgetMAX1track.c: mex-C code for getting MAX1 maps and track maps, called by ABlearn.m and SUM1MAX1.m. 	

CgetSUM2.c: mex-C code for computing the SUM2 maps. It is called by ABfind.m. 
 	
CgetMAX2.c: mex-C code for computing the MAX2 scores at multiple resolutions. 
 	
CgetBack.c: after detection, get back to sketch the object.  

CgetBackInhibit.c: with local inhibition, for re-calculating MAX2 scores. 

+++++++++++++$$$$$$$$ utility .c code for local averaging and transformation

Caverage.c: mex-C code for computing window averages of filter responses, to be used in 
normalization. 
 
ClocalNormalize.c: local instead of global normalization in filtering. 
 	
ClocalNormalizeDouble.c: used in ExponentialModel.m, for images of type double. 	

Csigmoid.c: mex-C code for sigmoid transformation of SUM1 maps. 

+++++++++++++$$$$$$$$ utility .m code for filtering by Gabor filters
 	
ApplyFilterfft.m: filtering input images by Gabor filters based on fft. 
 	
ApplyFilterfftSame.m: filtering images that are of the same size, so we only need fft 
the filters once. 
 		
GaborFilter.m: create a pair of Gabor sine and cosine filters. 
 	
MakeFilter.m: make a set of Gabor filters at different orientations. 
 	
CorrFilter.m: compute correlations between filters to be used in non-maximum suppression. 

+++++++++++++$$$$$$$$ code for exponential family model 
 		
ExponentialModel.m: store the grid of lambda values and the corresponding expectation and 
logZ values to be used for estimating lambda and computing logZ in model fitting.
 	
Chistogram.c: compute the marginal histogram of filter responses from negative images. 
We do not need negative images beyond this marginal histogram. 

+++++++++++++$$$$$$$$ code for output and clean up 
 		
OutLearningResult.m: output learning results. 
 	
Outepsgif.m: output eps and gif files to be included in latex or html. 

CleanUp.m: removed generated files during the running of matlab code. 

+++++++++++++$$$$$$$$ folders and files for images, storage, and output
 	
PositiveImage: the folder that contains the training images. 
 	
NegativeImage: the folder that contains natural images. We do not need negative images 
beyond pooling a marginal histogram. 
 	
Testing: the foler that contains the testing images. 

working: the folder that contains .mat files generated during the running. 

output: the folder that contains .eps and .gif files generated during the running. 
 	

