bijnum
Class BIJfht

java.lang.Object
  extended by bijnum.BIJfht

public class BIJfht
extends java.lang.Object

This class implements the fast Hartley transform on matrices and vectors (real float matrices). It also includes some utility functions for dealing with Hartley transforms, especially for correlation. This class is based on Arlso Reeves' Pascal implementation of the Fast Hartley Transform from NIH Image (http://rsb.info.nih.gov/ij/docs/ImageFFT/). The Fast Hartley Transform was restricted by U.S. Patent No. 4,646,256, but was placed in the public domain by Stanford University in 1995 and is now freely available. This implementation based in part on the implementation by Wyane Rasband in ImageJ. Copyright (c) 1999-2004, Michael Abramoff. All rights reserved.


Constructor Summary
BIJfht(int length)
          Set up a BIJfht for matrices of size length = maxNxmaxN
 
Method Summary
 void compute(float[] m, boolean inverse)
          Perform a Fast Hartley Transform on an image BIJfht of maxN x maxN pixels.
 float[] crossPowerSpectrum(float[] im1, float[] im2)
          Compute the conjugate product R = IM1* IM2 for real matrices (Hartley transformed) im1 and im2.
 float[] crossPowerSpectrum2(float[] im1, float[] im2, int maxN)
          Alternative method to compute the cross power spectrum (im1* im2) / | im1 im2 | for Hartley (as opposed to Fourier) opposed matrices im1 and im2.
 float[] flipquad(float[] m)
          Flip quadrants 1 and 3 and quadrants 2 and 4 of an image column vector.
 byte[] getPowerSpectrum(float[] BIJfht)
          Get the power spectrum of the hartley transform (maxN x maxN pixels) and return as a byte array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BIJfht

public BIJfht(int length)
Set up a BIJfht for matrices of size length = maxNxmaxN

Parameters:
length: - the square of the size of the matrices (the length of the vector used for storing the matrix).
Method Detail

compute

public void compute(float[] m,
                    boolean inverse)
             throws java.lang.IllegalArgumentException
Perform a Fast Hartley Transform on an image BIJfht of maxN x maxN pixels. If inverse == true, do the inverse transform. m is modified!

Parameters:
m - the matrix of the image, an array of floats
maxN - the size of the matrix
inverse - a flag whether to perform the forward or inverse transform.
Throws:
java.lang.IllegalArgumentException

crossPowerSpectrum

public float[] crossPowerSpectrum(float[] im1,
                                  float[] im2)
Compute the conjugate product R = IM1* IM2 for real matrices (Hartley transformed) im1 and im2. im1 and im2 are not modified. To go from Hartley to Fourier: F(x,y) = Re { F(x,y) } + j Im { F(x,y) } = He(x,y) - j Ho(x,y) = (H(x,y) + H(-x,-y))/2 - j (H(x,y) - H(-x, -y))/2 This is the best function for obtaining the translation from im1 to im2.

Parameters:
im1 - a real Hartley transform of an image
im2 - a real Hartley transform of another image
maxN - the size of im1 and im2 in pixels. im1 and im2 should be maxN x maxN.
Returns:
the resulting matrix with the conjugate product of the two transforms.

crossPowerSpectrum2

public float[] crossPowerSpectrum2(float[] im1,
                                   float[] im2,
                                   int maxN)
Alternative method to compute the cross power spectrum (im1* im2) / | im1 im2 | for Hartley (as opposed to Fourier) opposed matrices im1 and im2. Conversion between Hartley and Fourier: F(x,y) = Re { F(x,y) } + j Im { F(x,y) } = He(x,y) - j Ho(x,y) = (H(x,y) + H(-x,-y))/2 - j (H(x,y) - H(-x, -y))/2 To go from Fourier to Hartley H(x,y) = He = Re - Im and H(-x,-y) = Ho = Re + Im;


flipquad

public float[] flipquad(float[] m)
Flip quadrants 1 and 3 and quadrants 2 and 4 of an image column vector. 2 1 3 4

Parameters:
m - an image vector.
Returns:
the flipped image vector.

getPowerSpectrum

public byte[] getPowerSpectrum(float[] BIJfht)
Get the power spectrum of the hartley transform (maxN x maxN pixels) and return as a byte array.