MATLAB is (sometimes) your friend!
Generate.m
The Generate function takes in an image size and generates an
image with three lines of tracks each going in a randomly choosen
direction and starting at a random location. The function insures
that tracks will not overlap in order to improve results. Gait
information, including the stride, straddle and intergroup of the animal, is taken into account when generating the image.
prep.m
The Prep function is use prior to running the actual scripts since its only
purpose is to take an image of a footprint in a tiff format and
convert it to a standardized format for use in Matlab. The files
myfoot.tif, mybobcat.tif, and mydeer.tif were obtained by
running Prep on the PAW*.tif files. In creating larger images
with multiple tracks, always use the footprints that have been
run through Prep in order to make correlation possible.
peaks.m
The Peaks function takes in a maximum correlation value and the
matrix of correlation values. If the correlation value of each found peak is large
enough (within 15% of the maximum value), the peak is recorded as a
footprint and its location is outputed by Peaks.
Loadin.m
The Loadin function loads in (surprised?) an image and then shifts each
pixel value so that black has a value of -.5 and white has a value of .5.
These numbers result in the best correlation values.
Pad.m
The pad function adds a white border around the image of
width 16, half of the width of a standard footprint. This is
done so that boundary condition problems are avoided when removing the
whitespace from the image matrix. It makes the code in cor2
and cor3 much cleaner as well.
WhiteSpace.m
The WhiteSpace function elminates the unintersting "snow"
and only leaves the areas that are likely to contain foot
prints. This is accomplished by scaning across the columns until a
non-snow column is found. The code continues to scan until the next snow
column is found. This provides a set of contiguous columns in
the matrix that likely contain a footprint. Next, a similar process
with the rows is executed, but the scaning is limited to the region
between the two boundary columns. Finally, the code scans once
again for a set of inner columns bounding the interesting space by scanning
between the first set of found columns and rows.
LineFit.m
The LineFit function fits the data points returned by the cor*
functions with a linear approximation. Using the information about angle
and position at each data point, LineFit calculates the slope and
y-intercept of a line that traces the prints. This function draws a line
of the appropriate color for the animal.
cor.m
The cor function takes in an image matrix and returns the
correlation with all of the footprints. The matlab command conv2 is used instead of xcorr2
because it is more flexible in terms of cropping the output
properly. The program runs by taking the footprint, rotating
it by a specified angle, correlating it with the whole image matrix,
and determining if any of the correlation values are large enough to
suggest a match. This process is preformed over seven
different angles (from -90 to 90).
cor2.m
The cor2 function is just like cor.m except that it uses the results
of the WhiteSpace function to more efficently do the
correlation. This is done by carefully using the Matlab conv2 command
over correctly-sized matricies of the areas containing non-white
information. Also, the results have to be adjusted a little bit
since the matrix is padded.
cor3.m
The cor3 function improves upon cor2.m by using gait to reduce the
number of correlations needed. The white space is still detected.
After the convolution of the first print, the animal, its
direction, and its location are identified and the correlation
stops. Then the gait of the identified animal is taken into account to approximate the locations of further
prints, assuming the animal is moving in a straight line at a constant
gait. If there is non-white space at these locations, the print is
assumed to be there. Now correlation continues with any other
"interesting" areas which were indentified by the function WhiteSpace.
Run.m
The Run function controls the flow of execution. This script
runs all of the functions in the proper order and prints out the
results. It is used only for testing purposes and to demonstrate what
areas whitespace is removing. For performance comparisions, the
Compare2.m function is used.
Compare2.m
This function is used to compare the performance of the various
correlation methods. It bases its comparision on the total number of
flops and the cpu time used. It runs multiple trials in order to
compensate for random fluctuations.