math
Class Correlation

java.lang.Object
  extended by math.Correlation

public class Correlation
extends java.lang.Object

User: lyon Date: Nov 18, 2007 Time: 9:48:44 AM Copyright DocJava, Inc. 2005.


Constructor Summary
Correlation()
           
 
Method Summary
static double dot(double[] a, double[] b, int j)
          Calculate the dot product of two vectors.
static java.awt.Image extractTemplate(java.awt.Image img)
           
static double[] getMovingNormalizedCrossCorrelation(double[] signal, double[] kernel)
           
static float[][] getSIBB(ShortImageBean sib)
           
static float[][] getSIBG(ShortImageBean sib)
           
static float[][] getSIBR(ShortImageBean sib)
           
static void main(java.lang.String[] args)
           
static void main2(java.lang.String[] args)
           
static double moravec(double[] x, double[] y)
           
static java.awt.Image NCCTry2(java.awt.Image img1, java.awt.Image img2)
           
static double normalizedCrossCorrelation(double[] x, double[] y)
           
static java.awt.Image normalizedCrossCorrelation(java.awt.Image img1, java.awt.Image img2)
           
static java.awt.Image normalizedCrossCorrelationFFT(java.awt.Image img1, java.awt.Image img2)
           
static double nssd(double[] x, double[] y)
           
static double nzssd(double[] x, double[] y)
           
static void oldVersion(java.lang.String[] args)
           
static double[] padOutWithZeros(double[] b, int length)
          This method will pad out a new array of length length and return it.
static double sad(double[] x, double[] y)
           
static double simpleCrossCorrelation(double[] x, double[] y)
           
static void speedTestCorrelation(int n)
           
static double ssd(double[] x, double[] y)
           
static void testCorrelation()
           
static void timeTest(java.lang.Runnable r, java.lang.String title)
           
static double zeroMeanNormalizedCrossCorrelation(double[] x, double[] y, int period, int startpoint)
          Calculate the Pearson product-moment correlation between the two variables.
static double[] zeroPadCorrelate(double[] a, double[] b)
          Zero pads a non-cyclic cross correlation between the signal and the template.
static java.awt.Image zeroPadImage(java.awt.Image template, java.awt.Image img1)
           
static void zeroPadImage(ShortImageBean sibImage, ShortImageBean sibTemplate)
           
static double zsad(double[] x, double[] y)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Correlation

public Correlation()
Method Detail

main2

public static void main2(java.lang.String[] args)

speedTestCorrelation

public static void speedTestCorrelation(int n)

oldVersion

public static void oldVersion(java.lang.String[] args)

timeTest

public static void timeTest(java.lang.Runnable r,
                            java.lang.String title)

ssd

public static double ssd(double[] x,
                         double[] y)

sad

public static double sad(double[] x,
                         double[] y)

zsad

public static double zsad(double[] x,
                          double[] y)

nzssd

public static double nzssd(double[] x,
                           double[] y)

nssd

public static double nssd(double[] x,
                          double[] y)

moravec

public static double moravec(double[] x,
                             double[] y)

normalizedCrossCorrelation

public static double normalizedCrossCorrelation(double[] x,
                                                double[] y)

simpleCrossCorrelation

public static double simpleCrossCorrelation(double[] x,
                                            double[] y)

testCorrelation

public static void testCorrelation()

getMovingNormalizedCrossCorrelation

public static double[] getMovingNormalizedCrossCorrelation(double[] signal,
                                                           double[] kernel)

zeroMeanNormalizedCrossCorrelation

public static double zeroMeanNormalizedCrossCorrelation(double[] x,
                                                        double[] y,
                                                        int period,
                                                        int startpoint)
Calculate the Pearson product-moment correlation between the two variables. This will return a correlation co-efficient which is in the range of -1 (negative correlation) through to (no correlation) through to 1 (perfect correlation.

The correlation co-efficient is calculated as follows:

 r = sum(Zx * Zy)
     ------------
         N - 1
 

Where Zx = X - E(X) -------- Sx

Where E(X) is the mean of X and Sx is the standard deviation of X.

Simillarly for Zy. Zero Mean Normalized Cross-correlation zncc

Parameters:
x - values to test against
y - values to detect correlation against x
period - number of days to analyse
Returns:
the correlation co-efficient

normalizedCrossCorrelationFFT

public static java.awt.Image normalizedCrossCorrelationFFT(java.awt.Image img1,
                                                           java.awt.Image img2)

normalizedCrossCorrelation

public static java.awt.Image normalizedCrossCorrelation(java.awt.Image img1,
                                                        java.awt.Image img2)

NCCTry2

public static java.awt.Image NCCTry2(java.awt.Image img1,
                                     java.awt.Image img2)

zeroPadImage

public static java.awt.Image zeroPadImage(java.awt.Image template,
                                          java.awt.Image img1)

zeroPadImage

public static void zeroPadImage(ShortImageBean sibImage,
                                ShortImageBean sibTemplate)

getSIBR

public static float[][] getSIBR(ShortImageBean sib)

getSIBG

public static float[][] getSIBG(ShortImageBean sib)

getSIBB

public static float[][] getSIBB(ShortImageBean sib)

extractTemplate

public static java.awt.Image extractTemplate(java.awt.Image img)

zeroPadCorrelate

public static double[] zeroPadCorrelate(double[] a,
                                        double[] b)
Zero pads a non-cyclic cross correlation between the signal and the template.

Parameters:
a - vector signal for the cross correlation
b - template vector for the cross correlation
Returns:
non-normalized cross correlation

padOutWithZeros

public static double[] padOutWithZeros(double[] b,
                                       int length)
This method will pad out a new array of length length and return it.

Parameters:
b - prepended to the output array
length - of the new array
Returns:
new array with b at the beginning and zeros on the tail.

dot

public static double dot(double[] a,
                         double[] b,
                         int j)
Calculate the dot product of two vectors.

Parameters:
a - the first vector
b - the second vector
Returns:
the dot product

main

public static void main(java.lang.String[] args)