com.pearsoneduc.ip.op
Class ImageFFT

java.lang.Object
  |
  +--com.pearsoneduc.ip.op.ImageFFT

public class ImageFFT
extends java.lang.Object

Computes the FFT of an image, and the inverse FFT of its frequency domain representation. The transformed data can be inspected or filtered before performing the inverse transform.

Version:
1.3 [1999/08/09]
Author:
Nick Efford
See Also:
FFTException, BufferedImage

Field Summary
static int BARTLETT_WINDOW
           
static int HAMMING_WINDOW
           
static int HANNING_WINDOW
           
static int NO_WINDOW
           
 
Constructor Summary
ImageFFT(java.awt.image.BufferedImage image)
          Creates an ImageFFT for the specified image.
ImageFFT(java.awt.image.BufferedImage image, int win)
          Creates an ImageFFT for the specified image, applying the specified windowing function to the data.
 
Method Summary
static double bartlettWindow(double r, double rmax)
          Computes one half of a radial Bartlett windowing function.
 void butterworthBandPassFilter(double radius, double delta)
          Performs order-1 Butterworth band pass filtering of the spectrum.
 void butterworthBandPassFilter(int n, double radius, double delta)
          Performs Butterworth band pass filtering of the spectrum.
static double butterworthBandPassFunction(int n, double radius, double delta, double r)
          Computes the transfer function for a Butterworth band pass filter.
 void butterworthBandStopFilter(double radius, double delta)
          Performs order-1 Butterworth band stop filtering of the spectrum.
 void butterworthBandStopFilter(int n, double radius, double delta)
          Performs Butterworth band stop filtering of the spectrum.
static double butterworthBandStopFunction(int n, double radius, double delta, double r)
          Computes the transfer function of a Butterworth band stop filter.
 void butterworthHighPassFilter(double radius)
          Performs order-1 Butterworth high pass filtering of the spectrum.
 void butterworthHighPassFilter(int n, double radius)
          Performs Butterworth high pass filtering of the spectrum.
static double butterworthHighPassFunction(int n, double radius, double r)
          Computes the transfer function for a Butterworth high pass filter.
 void butterworthLowPassFilter(double radius)
          Performs order-1 Butterworth low pass filtering of the spectrum.
 void butterworthLowPassFilter(int n, double radius)
          Performs Butterworth low pass filtering of the spectrum.
static double butterworthLowPassFunction(int n, double radius, double r)
          Computes the transfer function for a Butterworth low pass filter.
 int getHeight()
           
 float getMagnitude(int u, int v)
          Computes magnitude for any point in the spectrum.
 float getPhase(int u, int v)
          Computes phase for any point in the spectrum.
 java.awt.image.BufferedImage getSpectrum()
          Returns the amplitude spectrum of an image, as another image.
 java.awt.image.BufferedImage getUnshiftedSpectrum()
          Returns the amplitude spectrum of an image, as another image.
 int getWidth()
           
 int getWindow()
           
static double hammingWindow(double r, double rmax)
          Computes one half of a radial Hamming windowing function.
static double hanningWindow(double r, double rmax)
          Computes one half of a radial Hanning windowing function.
 void idealBandPassFilter(double radius, double delta)
          Performs ideal band pass filtering on the spectrum.
 void idealBandStopFilter(double radius, double delta)
          Performs ideal band stop filtering on the spectrum.
 void idealHighPassFilter(double radius)
          Performs ideal high pass filtering on the spectrum.
 void idealLowPassFilter(double radius)
          Performs ideal low pass filtering on the spectrum.
 boolean isSpectral()
           
 void setMagnitude(int u, int v, float mag)
          Modifies magnitude at any point in the spectrum.
 void setPhase(int u, int v, float phase)
          Modifies phase at any point in the spectrum.
 java.awt.image.BufferedImage toImage(java.awt.image.BufferedImage image)
          Converts stored data into an image.
 java.awt.image.BufferedImage toImage(java.awt.image.BufferedImage image, int bias)
          Converts stored data into an image.
 java.lang.String toString()
           
 void transform()
          Transforms data via a forward or inverse FFT, as appropriate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_WINDOW

public static final int NO_WINDOW

BARTLETT_WINDOW

public static final int BARTLETT_WINDOW

HAMMING_WINDOW

public static final int HAMMING_WINDOW

HANNING_WINDOW

public static final int HANNING_WINDOW
Constructor Detail

ImageFFT

public ImageFFT(java.awt.image.BufferedImage image)
         throws FFTException
Creates an ImageFFT for the specified image. There will be no windowing of image data.
Parameters:
image - input image
Throws:
FFTException - if the image is not 8-bit greyscale.

ImageFFT

public ImageFFT(java.awt.image.BufferedImage image,
                int win)
         throws FFTException
Creates an ImageFFT for the specified image, applying the specified windowing function to the data.
Parameters:
image - input image
win - windowing function
Throws:
FFTException - if the image is not 8-bit greyscale.
Method Detail

bartlettWindow

public static final double bartlettWindow(double r,
                                          double rmax)
Computes one half of a radial Bartlett windowing function.
Parameters:
r - distance from centre of data
rmax - maximum distance
Returns:
function value.

hammingWindow

public static final double hammingWindow(double r,
                                         double rmax)
Computes one half of a radial Hamming windowing function.
Parameters:
r - distance from centre of data
rmax - maximum distance
Returns:
function value.

hanningWindow

public static final double hanningWindow(double r,
                                         double rmax)
Computes one half of a radial Hanning windowing function.
Parameters:
r - distance from centre of data
rmax - maximum distance
Returns:
function value.

butterworthLowPassFunction

public static final double butterworthLowPassFunction(int n,
                                                      double radius,
                                                      double r)
Computes the transfer function for a Butterworth low pass filter.
Parameters:
n - order of filter
radius - filter radius
r - distance from centre of spectrum
Returns:
transfer function value.

butterworthHighPassFunction

public static final double butterworthHighPassFunction(int n,
                                                       double radius,
                                                       double r)
Computes the transfer function for a Butterworth high pass filter.
Parameters:
n - order of filter
radius - filter radius
r - distance from centre of spectrum
Returns:
transfer function value.

butterworthBandPassFunction

public static final double butterworthBandPassFunction(int n,
                                                       double radius,
                                                       double delta,
                                                       double r)
Computes the transfer function for a Butterworth band pass filter.
Parameters:
n - order of filter
radius - filter radius
delta - band width
r - distance from centre of spectrum
Returns:
transfer function value.

butterworthBandStopFunction

public static final double butterworthBandStopFunction(int n,
                                                       double radius,
                                                       double delta,
                                                       double r)
Computes the transfer function of a Butterworth band stop filter.
Parameters:
n - order of filter
radius - filter radius
delta - band width
r - distance from centre of spectrum
Returns:
transfer function value.

getWidth

public int getWidth()
Returns:
width of FFT.

getHeight

public int getHeight()
Returns:
height of FFT.

getWindow

public int getWindow()
Returns:
current windowing function.

isSpectral

public boolean isSpectral()
Returns:
true if data are spectral, false if data are spatial.

toString

public java.lang.String toString()
Returns:
information string for an ImageFFT object.
Overrides:
toString in class java.lang.Object

transform

public void transform()
Transforms data via a forward or inverse FFT, as appropriate. An inverse transform is computed if the previous transform was in the forward direction; otherwise, the forward transform is computed.

toImage

public java.awt.image.BufferedImage toImage(java.awt.image.BufferedImage image)
                                     throws FFTException
Converts stored data into an image.
Parameters:
image - destination image, or null
Returns:
FFT data as an image.
Throws:
FFTException - if the data are in spectral form; an image can be created only from data in the spatial domain.

toImage

public java.awt.image.BufferedImage toImage(java.awt.image.BufferedImage image,
                                            int bias)
                                     throws FFTException
Converts stored data into an image.
Parameters:
image - destination image, or null
bias - constant value added to data
Returns:
FFT data as an image.
Throws:
FFTException - if the data are in spectral form; an image can be created only from data in the spatial domain.

getSpectrum

public java.awt.image.BufferedImage getSpectrum()
                                         throws FFTException
Returns the amplitude spectrum of an image, as another image. The data are shifted such that the DC component is at the image centre, and scaled logarithmically so that low-amplitude detail is visible.
Returns:
shifted spectrum, as an image.
Throws:
FFTException - if spectral data are not available (e.g. because last transform was in the inverse direction).

getUnshiftedSpectrum

public java.awt.image.BufferedImage getUnshiftedSpectrum()
                                                  throws FFTException
Returns the amplitude spectrum of an image, as another image. The data are unshifted and are scaled logarithmically so that low-amplitude detail is visible.
Returns:
unshifted spectrum, as an image.
Throws:
FFTException - if spectral data are not available e.g. because last transform was in the inverse direction).

getMagnitude

public float getMagnitude(int u,
                          int v)
                   throws FFTException
Computes magnitude for any point in the spectrum.
Parameters:
u - horizontal spatial frequency
v - vertical spatial frequency
Returns:
magnitude at the specified point, or zero if point does not exist.
Throws:
FFTException - if spectral data are not available.

getPhase

public float getPhase(int u,
                      int v)
               throws FFTException
Computes phase for any point in the spectrum.
Parameters:
u - horizontal spatial frequency
v - vertical spatial frequency
Returns:
phase at the specified point, or zero if point does not exist.
Throws:
FFTException - if spectral data are not available.

setMagnitude

public void setMagnitude(int u,
                         int v,
                         float mag)
                  throws FFTException
Modifies magnitude at any point in the spectrum.
Parameters:
u - horizontal spatial frequency
v - vertical spatial frequency
mag - new magnitiude for specified point
Throws:
FFTException - if spectral data are not available.

setPhase

public void setPhase(int u,
                     int v,
                     float phase)
              throws FFTException
Modifies phase at any point in the spectrum.
Parameters:
u - horizontal spatial frequency
v - vertical spatial frequency
phase - new phase for specified point
Throws:
FFTException - if spectral data are not available.

idealLowPassFilter

public void idealLowPassFilter(double radius)
                        throws FFTException
Performs ideal low pass filtering on the spectrum.
Parameters:
radius - filter radius
Throws:
FFTException - if spectral data are not available or filter radius is invalid.

idealHighPassFilter

public void idealHighPassFilter(double radius)
                         throws FFTException
Performs ideal high pass filtering on the spectrum.
Parameters:
radius - filter radius
Throws:
FFTException - if spectral data are not available or filter radius is invalid.

idealBandPassFilter

public void idealBandPassFilter(double radius,
                                double delta)
                         throws FFTException
Performs ideal band pass filtering on the spectrum.
Parameters:
radius - filter radius
delta - band width
Throws:
FFTException - if spectral data are not available or filter parameters are invalid.

idealBandStopFilter

public void idealBandStopFilter(double radius,
                                double delta)
                         throws FFTException
Performs ideal band stop filtering on the spectrum.
Parameters:
radius - filter radius
delta - band width
Throws:
FFTException - if spectral data are not available or filter parameters are invalid.

butterworthLowPassFilter

public void butterworthLowPassFilter(double radius)
                              throws FFTException
Performs order-1 Butterworth low pass filtering of the spectrum.
Parameters:
radius - filter radius
Throws:
FFTException - if spectral data are not available or filter parameters are invalid.

butterworthLowPassFilter

public void butterworthLowPassFilter(int n,
                                     double radius)
                              throws FFTException
Performs Butterworth low pass filtering of the spectrum.
Parameters:
n - order of filter
radius - filter radius
Throws:
FFTException - if spectral data are not available or filter parameters are invalid.

butterworthHighPassFilter

public void butterworthHighPassFilter(double radius)
                               throws FFTException
Performs order-1 Butterworth high pass filtering of the spectrum.
Parameters:
radius - filter radius
Throws:
FFTException - if spectral data are not available or filter parameters are invalid.

butterworthHighPassFilter

public void butterworthHighPassFilter(int n,
                                      double radius)
                               throws FFTException
Performs Butterworth high pass filtering of the spectrum.
Parameters:
n - order of filter
radius - filter radius
Throws:
FFTException - if spectral data are not available or filter parameters are invalid.

butterworthBandPassFilter

public void butterworthBandPassFilter(double radius,
                                      double delta)
                               throws FFTException
Performs order-1 Butterworth band pass filtering of the spectrum.
Parameters:
radius - filter radius
delta - band width
Throws:
FFTException - if spectral data are not available or filter parameters are invalid.

butterworthBandPassFilter

public void butterworthBandPassFilter(int n,
                                      double radius,
                                      double delta)
                               throws FFTException
Performs Butterworth band pass filtering of the spectrum.
Parameters:
n - order of filter
radius - filter radius
delta - band width
Throws:
FFTException - if spectral data are not available or filter parameters are invalid.

butterworthBandStopFilter

public void butterworthBandStopFilter(double radius,
                                      double delta)
                               throws FFTException
Performs order-1 Butterworth band stop filtering of the spectrum.
Parameters:
radius - filter radius
delta - band width
Throws:
FFTException - if spectral data are not available or filter parameters are invalid.

butterworthBandStopFilter

public void butterworthBandStopFilter(int n,
                                      double radius,
                                      double delta)
                               throws FFTException
Performs Butterworth band stop filtering of the spectrum.
Parameters:
n - order of filter
radius - filter radius
delta - band width
Throws:
FFTException - if spectral data are not available or filter parameters are invalid.