net.sarcommand.fft
Class FourierTransform2D

java.lang.Object
  extended by net.sarcommand.fft.FourierTransform
      extended by net.sarcommand.fft.FourierTransform2D
Direct Known Subclasses:
DFT2, FFT2

public abstract class FourierTransform2D
extends FourierTransform

Author:
A. O. Ergueven, Torsten Heup
Abstract superclass for all 2-dimensional fourier transforms in this package.

Field Summary
protected  ComplexSignal image
          The complex image data.
 
Constructor Summary
FourierTransform2D()
           
 
Method Summary
static java.awt.image.BufferedImage fourierSignalToGrayscale(ComplexSignal frequencyImage)
          Creates a grayscale BufferdImage of type BufferedImage.TYPE_BYTE_GRAY.
protected  void getCol(int u, ComplexSignal signal)
          Returns the contents of the column indexed by u in the complex image being computed.
protected  void getRow(int v, ComplexSignal signal)
          Returns row number 'v' from the complex image being computed and stores it's contents in 'rowC'.
static ComplexSignal imageToSignal(java.awt.image.BufferedImage image)
          Converts the pixels of an image to a complex signal.
 ComplexSignal inverseTransform(java.awt.image.BufferedImage image, net.sarcommand.util.ProgressNotifier notifier)
          Applies an inverse fourier transform to this BufferedImage.
static boolean isPowerOf2(java.awt.Dimension size)
          Returns true if the given int is a power of two value.
static boolean isPowerOf2(int length)
          Returns true if the given int is a power of two value.
protected  void putCol(int u, ComplexSignal signal)
          Stores the contents of the complex vector 'colV' in column number 'u' of the complex image being computed.
protected  void putRow(int v, ComplexSignal signal)
          Stores the contents of the complex vector 'rowC' in row number 'v' of the complex image being computed.
static java.awt.image.BufferedImage realToGrayscale(ComplexSignal signal)
          Creates a grayscale BufferedImage of type BufferedImage.TYPE_BYTE_GRAY from the given complex signal.
static void shiftQuadrants(byte[] pixels, int width, int height)
          Performs a quadrant shift.
 ComplexSignal transform(java.awt.image.BufferedImage image, net.sarcommand.util.ProgressNotifier notifier)
          Transforms this BufferedImage to a frequencyImage.
 
Methods inherited from class net.sarcommand.fft.FourierTransform
computeUnityRoot, convertToBytes, inverseTransform, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

image

protected ComplexSignal image
The complex image data.

Constructor Detail

FourierTransform2D

public FourierTransform2D()
Method Detail

shiftQuadrants

public static void shiftQuadrants(byte[] pixels,
                                  int width,
                                  int height)
Performs a quadrant shift.

Parameters:
pixels - Pixels of the image to shift.
width - The image's width.
height - The image's height.

fourierSignalToGrayscale

public static java.awt.image.BufferedImage fourierSignalToGrayscale(ComplexSignal frequencyImage)
Creates a grayscale BufferdImage of type BufferedImage.TYPE_BYTE_GRAY. Therefore, the frequency values will be scaled to a range of 0-255 and a quadrant shift will be applied afterwards.

Parameters:
frequencyImage - Frequency image to use as source.
Returns:
Human-friendly grayscale version of the frequency image.

realToGrayscale

public static java.awt.image.BufferedImage realToGrayscale(ComplexSignal signal)
Creates a grayscale BufferedImage of type BufferedImage.TYPE_BYTE_GRAY from the given complex signal. It will be assumed that the signal only holds real numbers as components.

Parameters:
signal - Signal to convert
Returns:
BufferedImage containing signal

imageToSignal

public static ComplexSignal imageToSignal(java.awt.image.BufferedImage image)
                                   throws java.lang.IllegalArgumentException
Converts the pixels of an image to a complex signal.

Parameters:
image - Image to convert.
Returns:
ComplexSignal containing the pixel values.
Throws:
java.lang.IllegalArgumentException - If an unknown image type was specified.

transform

public ComplexSignal transform(java.awt.image.BufferedImage image,
                               net.sarcommand.util.ProgressNotifier notifier)
                        throws java.lang.IllegalArgumentException
Transforms this BufferedImage to a frequencyImage.

Parameters:
image - Image to transform.
Returns:
float[] containing the frequency image.
Throws:
java.lang.IllegalArgumentException

inverseTransform

public ComplexSignal inverseTransform(java.awt.image.BufferedImage image,
                                      net.sarcommand.util.ProgressNotifier notifier)
                               throws java.lang.IllegalArgumentException
Applies an inverse fourier transform to this BufferedImage.

Parameters:
image - Image to transform.
Returns:
float[] containing the frequency image.
Throws:
java.lang.IllegalArgumentException

getRow

protected void getRow(int v,
                      ComplexSignal signal)
Returns row number 'v' from the complex image being computed and stores it's contents in 'rowC'.

Parameters:
v - Index of row to retrieve.

putRow

protected void putRow(int v,
                      ComplexSignal signal)
Stores the contents of the complex vector 'rowC' in row number 'v' of the complex image being computed.

Parameters:
v - Index of row to store.

getCol

protected void getCol(int u,
                      ComplexSignal signal)
Returns the contents of the column indexed by u in the complex image being computed.

Parameters:
u - Index of column to retrieve.

putCol

protected void putCol(int u,
                      ComplexSignal signal)
Stores the contents of the complex vector 'colV' in column number 'u' of the complex image being computed.

Parameters:
u - Index of column to store.

isPowerOf2

public static boolean isPowerOf2(int length)
Returns true if the given int is a power of two value.

Parameters:
length - Signal width to be checked.
Returns:
true if width is a power of two, false otherwise.

isPowerOf2

public static boolean isPowerOf2(java.awt.Dimension size)
Returns true if the given int is a power of two value.

Returns:
true if width is a power of two, false otherwise.