BIJ API

bijnum
Class BIJfht

java.lang.Object
  |
  +--bijnum.BIJfht

public class BIJfht
extends java.lang.Object

This class implements the fast Hartley transform on images (real float matrices). It also includes some utility functions for dealing with Hartley transforms, especially for correlation. This class implements the commands in the Process/FFT submenu. It 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-2003, Michael Abramoff. All rights reserved.


Field Summary
protected  int[] bitrev
           
protected  float[] C
          Static variables used in BIJfht algorithms.
protected  int maxN
           
protected  float[] S
           
protected  float[] tempArr
           
 
Constructor Summary
BIJfht(int length)
          Set up a BIJfht for matrices of size length = maxNxmaxN
 
Method Summary
(package private)  void BitRevRArr(float[] x, int base, int bitlen, int maxN)
           
 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.
(package private)  void dfht3(float[] x, int base, boolean inverse, int maxN)
           
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.
(package private)  int log2(int x)
           
protected  void makeBitReverseTable(int maxN)
           
protected  void makeSinCosTables(int maxN)
           
protected  void progress(double percent)
          Can be used to show progress in other programs.
(package private)  void rc2DFHT(float[] x, boolean inverse, int maxN)
          Row-column Fast Hartley Transform
(package private)  void transposeR(float[] x, int maxN)
           
 
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 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.
Returns:
m which is changed!

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.

makeSinCosTables

protected void makeSinCosTables(int maxN)

makeBitReverseTable

protected void makeBitReverseTable(int maxN)

rc2DFHT

void rc2DFHT(float[] x,
             boolean inverse,
             int maxN)
Row-column Fast Hartley Transform

dfht3

void dfht3(float[] x,
           int base,
           boolean inverse,
           int maxN)

transposeR

void transposeR(float[] x,
                int maxN)

log2

int log2(int x)

BitRevRArr

void BitRevRArr(float[] x,
                int base,
                int bitlen,
                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.

BIJ API

Submit a bug or feature

Copyright (c) 1997-2003 Michael Abramoff
Licensing available. All Rights Reserved.