bijnum

## Class BIJfht

• ```public class BIJfht
extends 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.
• ### Field Summary

Fields
Modifier and Type Field and Description
`protected int[]` `bitrev`
`protected float[]` `C`
Static variables used in BIJfht algorithms.
`protected int` `maxN`
`protected float[]` `S`
`protected float[]` `tempArr`
• ### Constructor Summary

Constructors
Constructor and Description
`BIJfht(int length)`
Set up a BIJfht for matrices of size length = maxNxmaxN
• ### Method Summary

All Methods
Modifier and Type Method and Description
`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.
`protected void` ```fhtps(int row, int maxN, float[] BIJfht, float[] ps)```
Calculate the Power Spectrum of one row from 2D Hartley Transform.
`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.
`protected void` `makeBitReverseTable(int maxN)`
`protected void` `makeSinCosTables(int maxN)`
`protected void` `progress(double percent)`
Can be used to show progress in other programs.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Field Detail

• #### C

`protected float[] C`
Static variables used in BIJfht algorithms.
• #### S

`protected float[] S`
• #### bitrev

`protected int[] bitrev`
• #### maxN

`protected int maxN`
• #### tempArr

`protected float[] tempArr`
• ### 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

• #### progress

`protected void progress(double percent)`
Can be used to show progress in other programs.
• #### compute

```public void compute(float[] m,
boolean inverse)
throws 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
`inverse` - a flag whether to perform the forward or inverse transform.
Throws:
`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
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;

`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.
• #### makeSinCosTables

`protected void makeSinCosTables(int maxN)`
• #### makeBitReverseTable

`protected void makeBitReverseTable(int maxN)`
• #### getPowerSpectrum

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

```protected void fhtps(int row,
int maxN,
float[] BIJfht,
float[] ps)```
Calculate the Power Spectrum of one row from 2D Hartley Transform.