ij.process
Class FHT

java.lang.Object
  extended by ij.process.ImageProcessor
      extended by ij.process.FloatProcessor
          extended by ij.process.FHT

public class FHT
extends FloatProcessor

This class contains a Java implementation of the Fast Hartley Transform. It is based on Pascal code in NIH Image contributed by Arlo Reeves (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.


Field Summary
 int originalBitDepth
          Used by the FFT class.
 java.awt.image.ColorModel originalColorModel
          Used by the FFT class.
 int originalHeight
          Used by the FFT class.
 int originalWidth
          Used by the FFT class.
 boolean quadrantSwapNeeded
          Used by the FFT class.
 ColorProcessor rgb
          Used by the FFT class.
 
Fields inherited from class ij.process.ImageProcessor
ABS, ADD, AND, antialiasedText, baseCM, BLACK, BLACK_AND_WHITE_LUT, BLUR_MORE, bLUT1, bLUT2, boldFont, CENTER_JUSTIFY, clipXMax, clipXMin, clipYMax, clipYMin, cm, cm2, cTable, cx, cy, defaultColorModel, drawingColor, EXP, fgColor, FILL, FIND_EDGES, fmImage, font, fontMetrics, GAMMA, gLUT1, gLUT2, height, histogramMax, histogramMin, histogramSize, image, img, interpolate, inversionTested, INVERT, invertedLut, justification, LEFT_JUSTIFY, lineWidth, LOG, lutAnimation, lutUpdateMode, mask, MAX, MAXIMUM, maxThreshold, MEDIAN_FILTER, MIN, MINIMUM, minThreshold, MULT, newPixels, NO_LUT_UPDATE, NO_THRESHOLD, OR, OVER_UNDER_LUT, progressBar, raster, RED_LUT, RIGHT_JUSTIFY, rLUT1, rLUT2, roiHeight, roiWidth, roiX, roiY, sampleModel, snapshotCopyMode, snapshotHeight, snapshotWidth, source, SQR, SQRT, width, WRONG_LENGTH, xMax, xMin, XOR, yMax, yMin
 
Constructor Summary
FHT(ImageProcessor ip)
          Constructs a FHT object from an ImageProcessor.
 
Method Summary
(package private)  void amplitude(int row, int maxN, float[] fht, float[] amplitude)
          Amplitude of one row from 2D Hartley Transform.
(package private)  void BitRevRArr(float[] x, int base, int bitlen, int maxN)
           
(package private)  ImageProcessor calculateAmplitude(float[] fht, int maxN)
           
(package private)  void changeValues(ImageProcessor ip, int v1, int v2, int v3)
           
 FHT conjugateMultiply(FHT fht)
          Returns the image resulting from the point by point Hartley conjugate multiplication of this image and the specified image.
 void dfht3(float[] x, int base, boolean inverse, int maxN)
          Performs an optimized 1D FHT.
 FHT divide(FHT fht)
          Returns the image resulting from the point by point Hartley division of this image by the specified image.
(package private)  void FHTimag(int row, int maxN, float[] fht, float[] imag)
          FFT imag value of one row from 2D Hartley Transform.
(package private)  void FHTps(int row, int maxN, float[] fht, float[] ps)
          Power Spectrum of one row from 2D Hartley Transform.
(package private)  void FHTreal(int row, int maxN, float[] fht, float[] real)
          FFT real value of one row from 2D Hartley Transform.
 ImageStack getComplexTransform()
          Converts this FHT to a complex Fourier transform and returns it as a two slice stack.
 FHT getCopy()
          Returns a clone of this FHT.
 ImageProcessor getPowerSpectrum()
          Returns an 8-bit power spectrum, log-scaled to 1-254.
 void inverseTransform()
          Performs an inverse transform, converting this image into the space domain.
(package private)  int log2(int x)
           
(package private)  void makeBitReverseTable(int maxN)
           
(package private)  void makeSinCosTables(int maxN)
           
 FHT multiply(FHT fht)
          Returns the image resulting from the point by point Hartley multiplication of this image and the specified image.
(package private)  FHT multiply(FHT fht, boolean conjugate)
           
 boolean powerOf2Size()
          Returns true of this FHT contains a square image with a width that is a power of two.
(package private)  void progress(double percent)
           
 void rc2DFHT(float[] x, boolean inverse, int maxN)
          Performs a 2D FHT (Fast Hartley Transform).
 void setShowProgress(boolean showProgress)
          Enables/disables display of the progress bar during transforms.
(package private)  float sqr(float x)
           
 void swapQuadrants()
          Swap quadrants 1 and 3 and 2 and 4 of the image contained in this FHT.
 void swapQuadrants(ImageProcessor ip)
          Swap quadrants 1 and 3 and 2 and 4 of the specified ImageProcessor so the power spectrum origin is at the center of the image.
 java.lang.String toString()
          Returns a string containing information about this FHT.
 void transform()
          Performs a foreward transform, converting this image into the frequency domain.
(package private)  void transform(boolean inverse)
          Returns an inverse transform of this image, which is assumed to be in the frequency domain.
(package private)  void transposeR(float[] x, int maxN)
           
 
Methods inherited from class ij.process.FloatProcessor
abs, add, add, and, applyTable, autoThreshold, convolve, convolve3x3, copyBits, createImage, createProcessor, crop, dilate, drawPixel, duplicate, erode, exp, fill, fill, filter, findMinAndMax, flipVertical, gamma, get, get, getf, getf, getHistogram, getInterpolatedPixel, getMax, getMin, getPixel, getPixel, getPixels, getPixelsCopy, getPixelValue, getSnapshotPixels, invert, log, max, maxValue, medianFilter, min, minValue, multiply, noise, or, putPixel, putPixel, putPixelValue, reset, reset, resetMinAndMax, resize, rotate, scale, set, set, setBackgroundValue, setColor, setf, setf, setMinAndMax, setPixels, setPixels, setSnapshotPixels, setThreshold, setValue, snapshot, sqr, sqrt, threshold, toFloat, xor
 
Methods inherited from class ij.process.ImageProcessor
convertToByte, convertToFloat, convertToRGB, convertToShort, drawDot, drawDot2, drawLine, drawOval, drawPolygon, drawRect, drawString, drawString, fillOval, fillPolygon, findEdges, flipHorizontal, getAutoThreshold, getAutoThreshold, getBestIndex, getCalibrationTable, getColorModel, getColumn, getCurrentColorModel, getDefaultColorModel, getFloatArray, getFontMetrics, getHeight, getHistogramMax, getHistogramMin, getHistogramSize, getIndexSampleModel, getIntArray, getInterpolate, getInterpolatedValue, getLine, getLutUpdateMode, getMask, getMaskArray, getMaxThreshold, getMinThreshold, getNChannels, getPixelCount, getRoi, getRow, getStringWidth, getWidth, hideProgress, insert, invertLut, isColorLut, isInvertedLut, isKillable, isPseudoColorLut, lineTo, makeDefaultColorModel, maskSizeError, moveTo, putColumn, putRow, resetBinaryThreshold, resetPixels, resetRoi, resetThreshold, resize, rotateLeft, rotateRight, setAntialiasedText, setCalibrationTable, setClipRect, setColor, setColorModel, setFloatArray, setFont, setHistogramRange, setHistogramSize, setIntArray, setInterpolate, setJustification, setLineWidth, setLutAnimation, setMask, setProgressBar, setRoi, setRoi, setRoi, setRoi, setSnapshotCopyMode, sharpen, showProgress, smooth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

quadrantSwapNeeded

public boolean quadrantSwapNeeded
Used by the FFT class.


rgb

public ColorProcessor rgb
Used by the FFT class.


originalWidth

public int originalWidth
Used by the FFT class.


originalHeight

public int originalHeight
Used by the FFT class.


originalBitDepth

public int originalBitDepth
Used by the FFT class.


originalColorModel

public java.awt.image.ColorModel originalColorModel
Used by the FFT class.

Constructor Detail

FHT

public FHT(ImageProcessor ip)
Constructs a FHT object from an ImageProcessor. Byte, short and RGB images are converted to float. Float images are duplicated.

Method Detail

powerOf2Size

public boolean powerOf2Size()
Returns true of this FHT contains a square image with a width that is a power of two.


transform

public void transform()
Performs a foreward transform, converting this image into the frequency domain. The image contained in this FHT must be square and its width must be a power of 2.


inverseTransform

public void inverseTransform()
Performs an inverse transform, converting this image into the space domain. The image contained in this FHT must be square and its width must be a power of 2.


transform

void transform(boolean inverse)
Returns an inverse transform of this image, which is assumed to be in the frequency domain.


makeSinCosTables

void makeSinCosTables(int maxN)

makeBitReverseTable

void makeBitReverseTable(int maxN)

rc2DFHT

public void rc2DFHT(float[] x,
                    boolean inverse,
                    int maxN)
Performs a 2D FHT (Fast Hartley Transform).


progress

void progress(double percent)

dfht3

public void dfht3(float[] x,
                  int base,
                  boolean inverse,
                  int maxN)
Performs an optimized 1D FHT.


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 ImageProcessor getPowerSpectrum()
Returns an 8-bit power spectrum, log-scaled to 1-254. The image in this FHT is assumed to be in the frequency domain.


FHTps

void FHTps(int row,
           int maxN,
           float[] fht,
           float[] ps)
Power Spectrum of one row from 2D Hartley Transform.


getComplexTransform

public ImageStack getComplexTransform()
Converts this FHT to a complex Fourier transform and returns it as a two slice stack.


FHTreal

void FHTreal(int row,
             int maxN,
             float[] fht,
             float[] real)
FFT real value of one row from 2D Hartley Transform.


FHTimag

void FHTimag(int row,
             int maxN,
             float[] fht,
             float[] imag)
FFT imag value of one row from 2D Hartley Transform.


calculateAmplitude

ImageProcessor calculateAmplitude(float[] fht,
                                  int maxN)

amplitude

void amplitude(int row,
               int maxN,
               float[] fht,
               float[] amplitude)
Amplitude of one row from 2D Hartley Transform.


sqr

float sqr(float x)

swapQuadrants

public void swapQuadrants(ImageProcessor ip)
Swap quadrants 1 and 3 and 2 and 4 of the specified ImageProcessor so the power spectrum origin is at the center of the image.
                    2 1
                    3 4
                


swapQuadrants

public void swapQuadrants()
Swap quadrants 1 and 3 and 2 and 4 of the image contained in this FHT.


changeValues

void changeValues(ImageProcessor ip,
                  int v1,
                  int v2,
                  int v3)

multiply

public FHT multiply(FHT fht)
Returns the image resulting from the point by point Hartley multiplication of this image and the specified image. Both images are assumed to be in the frequency domain. Multiplication in the frequency domain is equivalent to convolution in the space domain.


conjugateMultiply

public FHT conjugateMultiply(FHT fht)
Returns the image resulting from the point by point Hartley conjugate multiplication of this image and the specified image. Both images are assumed to be in the frequency domain. Conjugate multiplication in the frequency domain is equivalent to correlation in the space domain.


multiply

FHT multiply(FHT fht,
             boolean conjugate)

divide

public FHT divide(FHT fht)
Returns the image resulting from the point by point Hartley division of this image by the specified image. Both images are assumed to be in the frequency domain. Division in the frequency domain is equivalent to deconvolution in the space domain.


setShowProgress

public void setShowProgress(boolean showProgress)
Enables/disables display of the progress bar during transforms.


getCopy

public FHT getCopy()
Returns a clone of this FHT.


toString

public java.lang.String toString()
Returns a string containing information about this FHT.

Overrides:
toString in class ImageProcessor