Batch Normalized Cross-Correlation

By TC


Description

The purpose of the batch NCC is to be able to see what areas of the topography are strongest and weakest. In general, this will be performed on the the high resolution maplets that make up the topography in question, but this process will work for any given list of maplets. Following this guide will run norm_xcorr.py for each maplet specified in your input list, as well as provide several useful statistics and plots for analysis.


Setup

There are a few prerequisites to get in order before processing can begin. First of which is gathering files. Links to text versions of all of the script files I use are provided, but feel free to adapt them to your needs, or write new ones!


Step 1: Create a directory called COROUT in your working directory. (Can be called whatever you'd like but this will require updating the scripts)

mkdir COROUT

Step 2: Place the search image inside of COROUT. For our purposes this is generally an image rendered from the truth model using Showmap

cp /whatever/path/truth.pgm COROUT/

Step 3: Add the truth .MAP file to your MAPFILES directory, and update BIGLIST.TXT. Generally speaking it is bad form to have a truth map in your MAPFILES directory, but as long as this is for post-processing analysis it should be fine. It may be best to create a symbolic link.

ln -s /path/to/TRUTH.MAP MAPFILES/TRUTH.MAP

vi BIGLIST.TXT                (insert truth map name in BIGLIST.TXT)

Step 4: Create the .pgm image files of each maplet using Showmap. This can be easily done in bash with the script below which takes a command line argument of your list of maplets. If you chose to not stick with the COROUT naming convention, update the $cp variable as well.

file=$1
cp=COROUT

list=`cat $file`

for i in $list
do
        showmap <<< $i
        mv $i.pgm $cp/
done


Batch NCC

Step 1: Again using a simple bash script, iteratively run norm_xcorr.py using on each maplet. Again an example is given below where paths should be updated as necessary. The command line argument should be your list of maplets. The default output file is locations.txt

file=$1
cp=COROUT

list=`cat $file`

rm -f locations.txt

for i in $list
do
        echo "m" > tmpf
        echo $i >> tmpf
        echo "50 50" >> tmpf

        read x y <<< $(/path/to/newFind < tmpf | awk '/T15-1K/{print $3, $4}')

        python /path/to/norm_xcorr.py -o $cp/$i.png $cp/$i.pgm $cp/T15-1K.pgm > $cp/$i.txt

        read tx ty <<< $(awk '/match/{print $8, $9}' $cp/$i.txt)
        dx=`echo "$tx-$x" | bc`
        dy=`echo "$ty-$y" | bc`

        cor=`awk '/Max/{print $4}' $cp/$i.txt`

        printf "$i $x $y $dx $dy $cor\n" >> locations.txt
done

rm tmpf

This script also assumes the use of a FORTRAN program called newFind which is a standalone version of the lithos "find" option that prints to higher precision. This can easily be replaced with the lithos program instead, but expect this to approximately double processing time.

**N.B. If you are changing from newFind to lithos you need to change the beginning of the for loop to call the find routine in lithos. The new script should start like this:

.
.
.
for i in $list
do
        echo "f" > tmpf
        echo "m" >> tmpf
        echo $i >> tmpf
        echo "50 50" >> tmpf
.
.
.

Step 2: Use transStats.py on the output file from the above script (locations.txt) to get some statistics from the batch NCC. For a more detailed description of this python script, see Translation Statistics.

python transStats.py locations.txt > transOut.txt


Visualizing Output

The output from the batch correlation script (locations.txt) can be plotted very easily in Gnuplot.

gnuplot

set term x11
unset key

set yrange [*:*] reverse
set cbrange [0.2:1]

plot 'locations.txt' u 2:3:4:5 w vectors

plot 'locations.txt' u 2:3:6 pal pt 5 ps 3

F3C6cor.png F3C6trans.png