Class AlgorithmFrequencyFilter
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.filters.AlgorithmFrequencyFilter
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmFrequencyFilter extends AlgorithmBase
AlgorithmFrequencyFilter.java.- Author:
- William Gandler and Matthew J. McAuliffe Processing images by filtering in the frequency domain is a 3 step
process: 1.) Performing a forward fast fourier transform to convert a spatial image into its frequency
image. 2.) Enhancing some frequency components of the image and attenuating other frequency components of
the image by mulitplying by a lowpass, highpass, bandpass, or bandstop filter. Frequency filters may be
constructed with 1 of 3 methods - finite impulse response filters constructed with Hamming windows, Gaussian
filters, Butterworth, and Chebyshev filters. However, for the Gaussian filters only lowpass and highpass filters are
available. 3.) Performing an inverse fast fourier transform to convert from the frequency domain back into
the spatial domain. This software module performs all 3 steps in one combined process. AlgorithmFFT is used
to perform the steps one at a time and examine the Frequency space images.
The module also creates a Gabor filter, which is essentially a tilted Gaussian with 2 unequal axes at an offset (freqU, freqV) from the origin. A Gabor filter only responds to a texture having both a particular frequency and a particular orientation. Note that a filter and its mirror image reflected across the u and v frequency axes produce identical frequency responses.
This module also performs homomorphic fitering in which if any data is zero or negative a positive constant is added to all pixels to give a minimum value of 1. Then the log of the data is taken, the fast fourier transform is performed, the high frequencies are multiplied by a gain greater than 1 while the low frequencies are multiplied by a gain less than 1, the inverse fast fourier transform is performed, and the exponential of the the data is taken. Optionally, a specified percentage of the data can be clamped at the low end and/or at the high end. Finally, the data is rescaled so that the original minimum and maximum values are achieved. Only Butterworth filters are used with homomorphic filters in this module. References on homomorphic filters: 1.) Digital Image Processing Second Edition by Rafael C. Gonzalez and Richard E. Woods, Prentice-Hall, Inc., 2002, Chapter 4.5, pp. 191-194. 2.) "Butterworth equations for homomorphic filtering of images" by Holger. G. Adelmann, Computers in Medicine and Biology, Vol. 28, 1998, pp. 169-181.
The core algorithm of this module, the fast fourier transform algorithm found in exec(), requires that all the dimensions of an N-dimensional dataset be powers of 2. To be able to use this algorithm on datasets with arbitrary dimensions, the data is zero padded to powers of 2 before applying the forward fast fourier transform and stripped down to the original dimensions after applying the inverse fast fourier transform. The powers of 2 are not kept identical because symmetrical Fourier pictures are not required.
The typical full sequence is as follows: 1.) Data from a real spatial image is exported into a float array realData. 2.) An equally sized float array called imagData is created and filled with zeros. 3.) realData and imagData are enlarged to the powers of two. If finite impulse repsonse filters are constructed with Hamming windows and no cropping, the new dimension size is equal to the minimum power of two number that equals or exceeds the original dimension size + kDim - 1, where kDim is the diameter of a circular or spherical convolution kernel. If finite impulse response filters with Hamming windows and cropping or infinite impulse response Gaussian or Butterworth or Chebyshev filters are used, the new dimension size is equal to the minimum power of two number that equals or exceeds the original dimension size. The data is padded with zeros at the end of each dimension. 4.) exec() is invoked to run the fast fourier transform algorithm. 5.) If Butterworth or Gaussian or Gabor or Chebyshev filters are used, the center algorithm is invoked to reorder the data so that frequencies with the lowest magnitudes are at the center. If finite impulse response filters with windows are used: 6a.) An ideal filter kernel is constructed in the spatial domain. 7a.) A Hamming window kernel is constructed in the spatial domain. 8a.) The ideal kernel and the Hamming window kernel are multiplied together. 9a.) The kernel is zero padded up to the same dimensions that the image data was. 10a.) exec() is run to obtain the FFT of the kernel. If Gaussian or Butterworth or Chebyshev filters are used: For Gaussian and Butterworth and Chebyshev filters the transfer functions affect the real and imaginary parts of the FFT of the image in exactly the same manner. These filters are zero-phase- shift filters because they do not alter the phase of the transform. Since these filters are conjugate symmetric, the inverse FFTs of these filters are purely real. Since this filtering is equivalent to convolving to real 2D data sets, the result must be purely real. 6b.) The real part of the FFT is set equal to the appropriate filter magnitude and the imaginary part is set equal to zero. This filter has the same dimensions as the padded image data. 11.) The data FFT is set equal to the product of the data FFT and the filter FFT. 12.) The inverse FFT process is invoked. The complex data is exported into the 2 float arrays realData and imagData. There should be no need for zero padding at this point since the dimensions should already be all powers of 2 from before. 13.) If Butterworth or Gaussian or Chebyshev filters are used, the center() routine is invoked to restore the data to its original ordering. 14.) exec() is invoked to run the inverse fast fourier transform algorithm. 15.) The realData now holds the correct response if Gaussian or Butterworth or Chebyshev filtering was used. If FIR filtering with windows was used then realData holds a version of the correct response shifted by (kDim - 1)/2 toward the end of each dimension. The imagData should contain only roundoff error. 16.) For FIR filters shift the data back by (kDim - 1)/2 toward the start of each dimension. 17.) Stripping is performed to return the image to its original dimensions. 18.) The realData() is imported into the the new spatial image.
Methods included calculate the magnitude and phase as shown below:
magnitude = ( (realData)^2 + (imagData)^2 )^(1/2); phase = arctan(imagData/realData);
-
-
Field Summary
Fields Modifier and Type Field Description private int
arrayLength
DOCUMENT ME!static int
BANDPASS
DOCUMENT ME!static int
BANDSTOP
DOCUMENT ME!static int
BUTTERWORTH
DOCUMENT ME!static int
CHEBYSHEV_TYPE_I
static int
CHEBYSHEV_TYPE_II
private int
constructionMethod
DOCUMENT ME!private boolean
createGabor
DOCUMENT ME!private int[]
dimLengths
DOCUMENT ME!private boolean
doCrop
DOCUMENT ME!static int
ELLIPTIC
private int[]
end
DOCUMENT ME!private double
epsilon
private double
f1
DOCUMENT ME!private double
f2
DOCUMENT ME!static int
FILTER
DOCUMENT ME!private int
filterOrder
DOCUMENT ME!private int
filterType
DOCUMENT ME!private float[]
finalData
DOCUMENT ME!static int
FORWARD
DOCUMENT ME!private float
freqU
Variables used in Gabor filter.private float
freqV
DOCUMENT ME!static int
GABOR
DOCUMENT ME!private ModelImage
gaborImage
static int
GAUSSIAN
DOCUMENT ME!private float
highGain
DOCUMENT ME!static int
HIGHPASS
DOCUMENT ME!private float
highTruncated
DOCUMENT ME!static int
HOMOMORPHIC
DOCUMENT ME!private float[]
iKernel
DOCUMENT ME!private float[]
imagData
DOCUMENT ME!private boolean
image25D
DOCUMENT ME!private boolean
imageCrop
DOCUMENT ME!private float[]
imagKernelData
DOCUMENT ME!static int
INVERSE
DOCUMENT ME!private int
kDim
DOCUMENT ME!static int
LAPLACIAN
DOCUMENT ME!private float
lowGain
DOCUMENT ME!static int
LOWPASS
DOCUMENT ME!private float
lowTruncated
DOCUMENT ME!private float[]
magData
DOCUMENT ME!private float
maximum
DOCUMENT ME!private float
minimum
DOCUMENT ME!private int
ndim
DOCUMENT ME!private int
newArrayLength
DOCUMENT ME!private int[]
newDimLengths
DOCUMENT ME!private int
newSliceSize
DOCUMENT ME!private boolean
onlyFrequencyFilter
private float[]
phaseData
DOCUMENT ME!private float[]
realData
DOCUMENT ME!private float[]
realKernelData
DOCUMENT ME!private double
rs
private byte[]
sData
DOCUMENT ME!private float
sigmaU
DOCUMENT ME!private float
sigmaV
DOCUMENT ME!private int[]
start
DOCUMENT ME!private float
theta
DOCUMENT ME!private int
transformDir
DOCUMENT ME!static int
WINDOW
DOCUMENT ME!private float[]
wKernel
DOCUMENT ME!private boolean
zeroPad
DOCUMENT ME!-
Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStopped
-
-
Constructor Summary
Constructors Constructor Description AlgorithmFrequencyFilter(ModelImage srcImg, boolean image25D, boolean imageCrop)
Constructor used in Laplacian medialness option of live wire cost function.AlgorithmFrequencyFilter(ModelImage srcImg, boolean image25D, boolean imageCrop, int kernelDiameter, int filterType, double freq1, double freq2, int constructionMethod, int filterOrder, double epsilon, double rs, boolean onlyFrequencyFilter)
Creates a new AlgorithmFrequencyFilter object.AlgorithmFrequencyFilter(ModelImage srcImg, boolean image25D, float freq1, int filterOrder, float lowGain, float highGain, float lowTruncated, float highTruncated)
This constructor is only used for HOMOMORPHIC filters.AlgorithmFrequencyFilter(ModelImage srcImg, float freqU, float freqV, float sigmaU, float sigmaV, float theta, boolean createGabor)
Constructor used for Gabor transform.AlgorithmFrequencyFilter(ModelImage destImg, ModelImage srcImg, boolean image25D, boolean imageCrop, int kernelDiameter, int filterType, double freq1, double freq2, int constructionMethod, int filterOrder, double epsilon, double rs, boolean onlyFrequencyFilter)
Creates a new AlgorithmFrequencyFilter object.AlgorithmFrequencyFilter(ModelImage destImg, ModelImage srcImg, boolean image25D, float freq1, int filterOrder, float lowGain, float highGain, float lowTruncated, float highTruncated)
This constructor is only used for HOMOMORPHIC filters.AlgorithmFrequencyFilter(ModelImage destImg, ModelImage srcImg, float freqU, float freqV, float sigmaU, float sigmaV, float theta, boolean createGabor)
Constructor used for Gabor transform.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
calcInPlace()
This function replaces the original image with a new image that is either the FFT, the filtered FFT, or the inverse FFT of the original or filtered image.private void
calcStoreInDest()
This function produces a new image that is either the FFT, the filtered FFT, or the inverse FFT of the original or filtered image.private void
center(float[] rData, float[] iData)
Centers the FFT for display purposes.private double
Chebyshev(int order, double w)
private void
edgeStrip(float[] rData, int z)
This function edge strips the realData after the inverse FFT to return to the original dimensions that were present before the forward FFT was performed.private void
exec(float[] rData, float[] iData, int z)
This is the method that calculates the FFT Perform a data centering operation after the forward FFT Perform a data centering operation before the inverse FFT Note that a frequency filter operation performs a forward FFT.void
finalize()
Prepares this class for destruction.ModelImage
getGabor()
DOCUMENT ME!float[]
getImaginaryData()
Returns reference to imaginary data array.float[]
getMagData()
Returns reference to magnitude data array.float[]
getPhaseData()
Returns reference to phase data array.float[]
getRealData()
Returns reference to real data array.byte[]
getSData()
DOCUMENT ME!private void
hammingKernel2D()
Builds a hamming kernel in 2 dimensions.private void
hammingKernel3D()
Builds a hamming kernel in 3 dimensions.private void
idealBPKernel2D(double FLow, double FHigh)
Builds the idealized bandpass kernel in 2 dimensions.private void
idealBPKernel3D(double FLow, double FHigh)
Builds the idealized bandpass kernel in 2 dimensions.private void
idealBSKernel2D(double FLow, double FHigh)
Builds the idealized bandstop kernel in 2 dimensions.private void
idealBSKernel3D(double FLow, double FHigh)
Builds the idealized bandstop kernel in 3 dimensions.private void
idealHPKernel2D(double cutoffFreq)
Builds the idealized highpass kernel in 2 dimensions.private void
idealHPKernel3D(double cutoffFreq)
Builds the idealized highpass kernel in 3 dimensions.private void
idealLPKernel2D(double cutoffFreq)
Builds the idealized lowpass kernel in 2 dimensions.private void
idealLPKernel3D(double cutoffFreq)
Builds the idealized lowpass kernel in 3 dimensions.private void
magnitude()
Calculates magnitude from real and imaginary parts magnitude = ( (realData)^2 + (imagData)^2 )^(1/2);private void
makeButterworthFilter(double fr1, double fr2)
DOCUMENT ME!private void
makeChebyshevTypeIFilter(double fr1, double fr2)
private void
makeChebyshevTypeIIFilter(double fr1, double fr2)
private void
makeComplexData()
makeComplexData -private void
makeEllipticFilter(double fr1, double fr2)
private void
makeGaborFilter(float freqU, float freqV, float sigmaU, float sigmaV, float theta, boolean createGabor)
DOCUMENT ME!private void
makeGaussianFilter(double rmsFreq)
DOCUMENT ME!private void
makeHomomorphicFilter(double fr1)
DOCUMENT ME!private void
makeKernelData()
sets the kernel variables.private void
phase(float[] phase)
Calculates phase from real and imaginary parts.private void
restoreFinalData()
DOCUMENT ME!void
runAlgorithm()
Starts the program.private void
shiftBack(float[] rData)
Shifts the FFT data back from the center for processing purposes and inverse FFT.private void
zeroAround()
If a cropping operation was performed, shift the data back to the center and put zeros around the edges.-
Methods inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
actionPerformed, addListener, addProgressChangeListener, calculateImageSize, calculatePrincipleAxis, computeElapsedTime, computeElapsedTime, convertIntoFloat, delinkProgressToAlgorithm, delinkProgressToAlgorithmMulti, displayError, errorCleanUp, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, generateProgressValues, getDestImage, getElapsedTime, getMask, getMaxProgressValue, getMinProgressValue, getNumberOfThreads, getProgress, getProgressChangeListener, getProgressChangeListeners, getProgressModulus, getProgressStep, getProgressValues, getSrcImage, isCompleted, isImage25D, isMultiThreadingEnabled, isRunningInSeparateThread, isThreadStopped, linkProgressToAlgorithm, linkProgressToAlgorithm, makeProgress, notifyListeners, removeListener, removeProgressChangeListener, run, setCompleted, setImage25D, setMask, setMaxProgressValue, setMinProgressValue, setMultiThreadingEnabled, setNumberOfThreads, setProgress, setProgressModulus, setProgressStep, setProgressValues, setProgressValues, setRunningInSeparateThread, setSrcImage, setStartTime, setThreadStopped, startMethod, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
INVERSE
public static final int INVERSE
DOCUMENT ME!- See Also:
- Constant Field Values
-
FILTER
public static final int FILTER
DOCUMENT ME!- See Also:
- Constant Field Values
-
FORWARD
public static final int FORWARD
DOCUMENT ME!- See Also:
- Constant Field Values
-
LOWPASS
public static final int LOWPASS
DOCUMENT ME!- See Also:
- Constant Field Values
-
HIGHPASS
public static final int HIGHPASS
DOCUMENT ME!- See Also:
- Constant Field Values
-
BANDPASS
public static final int BANDPASS
DOCUMENT ME!- See Also:
- Constant Field Values
-
BANDSTOP
public static final int BANDSTOP
DOCUMENT ME!- See Also:
- Constant Field Values
-
HOMOMORPHIC
public static final int HOMOMORPHIC
DOCUMENT ME!- See Also:
- Constant Field Values
-
LAPLACIAN
public static final int LAPLACIAN
DOCUMENT ME!- See Also:
- Constant Field Values
-
WINDOW
public static final int WINDOW
DOCUMENT ME!- See Also:
- Constant Field Values
-
GAUSSIAN
public static final int GAUSSIAN
DOCUMENT ME!- See Also:
- Constant Field Values
-
BUTTERWORTH
public static final int BUTTERWORTH
DOCUMENT ME!- See Also:
- Constant Field Values
-
GABOR
public static final int GABOR
DOCUMENT ME!- See Also:
- Constant Field Values
-
CHEBYSHEV_TYPE_I
public static final int CHEBYSHEV_TYPE_I
- See Also:
- Constant Field Values
-
CHEBYSHEV_TYPE_II
public static final int CHEBYSHEV_TYPE_II
- See Also:
- Constant Field Values
-
ELLIPTIC
public static final int ELLIPTIC
- See Also:
- Constant Field Values
-
arrayLength
private int arrayLength
DOCUMENT ME!
-
filterOrder
private int filterOrder
DOCUMENT ME!
-
constructionMethod
private int constructionMethod
DOCUMENT ME!
-
createGabor
private boolean createGabor
DOCUMENT ME!
-
dimLengths
private int[] dimLengths
DOCUMENT ME!
-
doCrop
private boolean doCrop
DOCUMENT ME!
-
end
private int[] end
DOCUMENT ME!
-
f1
private double f1
DOCUMENT ME!
-
f2
private double f2
DOCUMENT ME!
-
filterType
private int filterType
DOCUMENT ME!
-
finalData
private float[] finalData
DOCUMENT ME!
-
freqU
private float freqU
Variables used in Gabor filter.
-
freqV
private float freqV
DOCUMENT ME!
-
highGain
private float highGain
DOCUMENT ME!
-
highTruncated
private float highTruncated
DOCUMENT ME!
-
iKernel
private float[] iKernel
DOCUMENT ME!
-
imagData
private float[] imagData
DOCUMENT ME!
-
image25D
private boolean image25D
DOCUMENT ME!
-
imageCrop
private boolean imageCrop
DOCUMENT ME!
-
imagKernelData
private float[] imagKernelData
DOCUMENT ME!
-
kDim
private int kDim
DOCUMENT ME!
-
lowGain
private float lowGain
DOCUMENT ME!
-
lowTruncated
private float lowTruncated
DOCUMENT ME!
-
magData
private float[] magData
DOCUMENT ME!
-
minimum
private float minimum
DOCUMENT ME!
-
maximum
private float maximum
DOCUMENT ME!
-
ndim
private int ndim
DOCUMENT ME!
-
newArrayLength
private int newArrayLength
DOCUMENT ME!
-
newDimLengths
private int[] newDimLengths
DOCUMENT ME!
-
newSliceSize
private int newSliceSize
DOCUMENT ME!
-
phaseData
private float[] phaseData
DOCUMENT ME!
-
realData
private float[] realData
DOCUMENT ME!
-
realKernelData
private float[] realKernelData
DOCUMENT ME!
-
sData
private byte[] sData
DOCUMENT ME!
-
sigmaU
private float sigmaU
DOCUMENT ME!
-
sigmaV
private float sigmaV
DOCUMENT ME!
-
start
private int[] start
DOCUMENT ME!
-
theta
private float theta
DOCUMENT ME!
-
transformDir
private int transformDir
DOCUMENT ME!
-
wKernel
private float[] wKernel
DOCUMENT ME!
-
zeroPad
private boolean zeroPad
DOCUMENT ME!
-
gaborImage
private ModelImage gaborImage
-
epsilon
private double epsilon
-
rs
private double rs
-
onlyFrequencyFilter
private boolean onlyFrequencyFilter
-
-
Constructor Detail
-
AlgorithmFrequencyFilter
public AlgorithmFrequencyFilter(ModelImage srcImg, boolean image25D, boolean imageCrop)
Constructor used in Laplacian medialness option of live wire cost function.- Parameters:
srcImg
- source image modelimage25D
- if true processes each slice of a 3D image independentlyimageCrop
- if true crop image if largest image dimension + kDim - 1 exceeds the smallest power of 2 number >= the largest dimension
-
AlgorithmFrequencyFilter
public AlgorithmFrequencyFilter(ModelImage srcImg, float freqU, float freqV, float sigmaU, float sigmaV, float theta, boolean createGabor)
Constructor used for Gabor transform.- Parameters:
srcImg
- Source image modelfreqU
- Frequency along U axis before rotation by theta range -1 to 1freqV
- Frequency along V axis before rotation by theta range -1 to 1sigmaU
- Standard deviation along prerotated U axissigmaV
- Standard deviation along prerotated V axistheta
- Rotation in radianscreateGabor
- If true, produce an image of the Gabor filter
-
AlgorithmFrequencyFilter
public AlgorithmFrequencyFilter(ModelImage srcImg, boolean image25D, float freq1, int filterOrder, float lowGain, float highGain, float lowTruncated, float highTruncated)
This constructor is only used for HOMOMORPHIC filters.- Parameters:
srcImg
- source image modelimage25D
- If true, processes each slice of a 3D image independentlyfreq1
- cutoff frequency, transition frequency from low to high gainfilterOrder
- order of the Butterworth filterlowGain
-highGain
- > 1, gain at high frequencieslowTruncated
- part of low histogram end truncatedhighTruncated
- part of high histogram end truncated
-
AlgorithmFrequencyFilter
public AlgorithmFrequencyFilter(ModelImage destImg, ModelImage srcImg, float freqU, float freqV, float sigmaU, float sigmaV, float theta, boolean createGabor)
Constructor used for Gabor transform.- Parameters:
destImg
- Destination image modelsrcImg
- Source image modelfreqU
- Frequency along U axis before rotation by theta range -1 to 1freqV
- Frequency along V axis before rotation by theta range -1 to 1sigmaU
- Standard deviation along prerotated U axissigmaV
- Standard deviation along prerotated V axistheta
- Rotation in radianscreateGabor
- If true, produce an image of the Gabor filter
-
AlgorithmFrequencyFilter
public AlgorithmFrequencyFilter(ModelImage destImg, ModelImage srcImg, boolean image25D, float freq1, int filterOrder, float lowGain, float highGain, float lowTruncated, float highTruncated)
This constructor is only used for HOMOMORPHIC filters.- Parameters:
destImg
- image model where result image is to be storedsrcImg
- source image modelimage25D
- If true, processes each slice of a 3D image independentlyfreq1
- cutoff frequency, transition frequency from low to high gainfilterOrder
- order of the Butterworth filterlowGain
-highGain
- > 1, gain at high frequencieslowTruncated
- part of low histogram end truncatedhighTruncated
- part of high histogram end truncated
-
AlgorithmFrequencyFilter
public AlgorithmFrequencyFilter(ModelImage srcImg, boolean image25D, boolean imageCrop, int kernelDiameter, int filterType, double freq1, double freq2, int constructionMethod, int filterOrder, double epsilon, double rs, boolean onlyFrequencyFilter)
Creates a new AlgorithmFrequencyFilter object.- Parameters:
srcImg
- source image modelimage25D
- if true processes each slice of a 3D image independentlyimageCrop
- if true crop image if largest image dimension + kDim - 1 exceeds the smallest power of 2 number >= the largest dimensionkernelDiameter
- convolution kernel diameter - must be an odd integer >= 3filterType
- LOWPASS, HIGHPASS, BANDPASS, or BANDSTOPfreq1
- cutoff frequency in LOWPASS and HIGHPASS lower frequency in BANDPASS and BANDSTOPfreq2
- higher frequency in BANDPASS and BANDSTOP User inputs f1 and f2 going from 0.0 to 1.0. Program multiplies these numbers by PI for FIR filters.constructionMethod
- WINDOW for window finite impulse response, GAUSSIAN, or BUTTERWORTHfilterOrder
- order of a Butterworth or Chebyshev filterepsilon
- Maximum Chebyshev filter ripple or Elliptic passband ripple in decibelsrs
- decibels stopband is down in EllipticonlyFrequencyFilter
-
-
AlgorithmFrequencyFilter
public AlgorithmFrequencyFilter(ModelImage destImg, ModelImage srcImg, boolean image25D, boolean imageCrop, int kernelDiameter, int filterType, double freq1, double freq2, int constructionMethod, int filterOrder, double epsilon, double rs, boolean onlyFrequencyFilter)
Creates a new AlgorithmFrequencyFilter object.- Parameters:
destImg
- image model where result image is to be storedsrcImg
- source image modelimage25D
- if true processes each slice of a 3D image independentlyimageCrop
- if true crop image if largest image dimension + kDim - 1 exceeds the smallest power of 2 number >= the largest dimensionkernelDiameter
- convolution kernel diameter - must be an odd integer >= 3filterType
- LOWPASS, HIGHPASS, BANDPASS, or BANDSTOPfreq1
- cutoff frequency in LOWPASS and HIGHPASS lower frequency in BANDPASS and BANDSTOPfreq2
- higher frequency in BANDPASS and BANDSTOP User inputs f1 and f2 going from 0.0 to 1.0. Program multiplies these numbers by PI for FIR filters.constructionMethod
- WINDOW for window finite impulse response, GAUSSIAN, or BUTTERWORTHfilterOrder
- order of the Butterworth or Chebyshev filterepsilon
- Maximum Chebyshev filter ripple or Elliptic passband ripple in decibelsrs
- decibels stopband is down in EllipticonlyFrequencyFilter
-
-
-
Method Detail
-
finalize
public void finalize()
Prepares this class for destruction.- Overrides:
finalize
in classAlgorithmBase
-
getImaginaryData
public float[] getImaginaryData()
Returns reference to imaginary data array.- Returns:
- the reference the the imaginary datat array
-
getMagData
public float[] getMagData()
Returns reference to magnitude data array.- Returns:
- the reference to the magnitude data array
-
getPhaseData
public float[] getPhaseData()
Returns reference to phase data array.- Returns:
- the reference to the phase data array
-
getRealData
public float[] getRealData()
Returns reference to real data array.- Returns:
- the reference the the real datat array
-
getSData
public byte[] getSData()
DOCUMENT ME!- Returns:
- sData
-
getGabor
public ModelImage getGabor()
DOCUMENT ME!- Returns:
- sData
-
runAlgorithm
public void runAlgorithm()
Starts the program.- Specified by:
runAlgorithm
in classAlgorithmBase
-
calcInPlace
private void calcInPlace()
This function replaces the original image with a new image that is either the FFT, the filtered FFT, or the inverse FFT of the original or filtered image.
-
calcStoreInDest
private void calcStoreInDest()
This function produces a new image that is either the FFT, the filtered FFT, or the inverse FFT of the original or filtered image.
-
center
private void center(float[] rData, float[] iData)
Centers the FFT for display purposes.- Parameters:
rData
- real data bufferiData
- imaginary data buffer
-
edgeStrip
private void edgeStrip(float[] rData, int z)
This function edge strips the realData after the inverse FFT to return to the original dimensions that were present before the forward FFT was performed.- Parameters:
rData
- DOCUMENT ME!z
- DOCUMENT ME!
-
exec
private void exec(float[] rData, float[] iData, int z)
This is the method that calculates the FFT Perform a data centering operation after the forward FFT Perform a data centering operation before the inverse FFT Note that a frequency filter operation performs a forward FFT.- Parameters:
rData
- real data bufferiData
- imaginary data bufferz
- slice number in image25D processing, 0 otherwise
-
hammingKernel2D
private void hammingKernel2D()
Builds a hamming kernel in 2 dimensions.
-
hammingKernel3D
private void hammingKernel3D()
Builds a hamming kernel in 3 dimensions.
-
idealBPKernel2D
private void idealBPKernel2D(double FLow, double FHigh)
Builds the idealized bandpass kernel in 2 dimensions.- Parameters:
FLow
- defines the cutoff frequecy at low freqs.FHigh
- defines the cutoff frequecy at high freqs.
-
idealBPKernel3D
private void idealBPKernel3D(double FLow, double FHigh)
Builds the idealized bandpass kernel in 2 dimensions.- Parameters:
FLow
- defines the cutoff frequecy at low freqs.FHigh
- defines the cutoff frequecy at high freqs.
-
idealBSKernel2D
private void idealBSKernel2D(double FLow, double FHigh)
Builds the idealized bandstop kernel in 2 dimensions.- Parameters:
FLow
- defines the cutoff frequecy at low freqs.FHigh
- defines the cutoff frequecy at high freqs.
-
idealBSKernel3D
private void idealBSKernel3D(double FLow, double FHigh)
Builds the idealized bandstop kernel in 3 dimensions.- Parameters:
FLow
- defines the cutoff frequecy at low freqs.FHigh
- defines the cutoff frequecy at high freqs.
-
idealHPKernel2D
private void idealHPKernel2D(double cutoffFreq)
Builds the idealized highpass kernel in 2 dimensions.- Parameters:
cutoffFreq
- defines the cutoff frequecy
-
idealHPKernel3D
private void idealHPKernel3D(double cutoffFreq)
Builds the idealized highpass kernel in 3 dimensions.- Parameters:
cutoffFreq
- defines the cutoff frequecy
-
idealLPKernel2D
private void idealLPKernel2D(double cutoffFreq)
Builds the idealized lowpass kernel in 2 dimensions.- Parameters:
cutoffFreq
- defines the cutoff frequecy
-
idealLPKernel3D
private void idealLPKernel3D(double cutoffFreq)
Builds the idealized lowpass kernel in 3 dimensions.- Parameters:
cutoffFreq
- defines the cutoff frequecy
-
magnitude
private void magnitude()
Calculates magnitude from real and imaginary parts magnitude = ( (realData)^2 + (imagData)^2 )^(1/2);
-
makeEllipticFilter
private void makeEllipticFilter(double fr1, double fr2)
-
Chebyshev
private double Chebyshev(int order, double w)
-
makeChebyshevTypeIFilter
private void makeChebyshevTypeIFilter(double fr1, double fr2)
-
makeChebyshevTypeIIFilter
private void makeChebyshevTypeIIFilter(double fr1, double fr2)
-
makeButterworthFilter
private void makeButterworthFilter(double fr1, double fr2)
DOCUMENT ME!- Parameters:
fr1
- DOCUMENT ME!fr2
- DOCUMENT ME!
-
makeComplexData
private void makeComplexData()
makeComplexData -
-
makeGaborFilter
private void makeGaborFilter(float freqU, float freqV, float sigmaU, float sigmaV, float theta, boolean createGabor)
DOCUMENT ME!- Parameters:
freqU
- DOCUMENT ME!freqV
- DOCUMENT ME!sigmaU
- DOCUMENT ME!sigmaV
- DOCUMENT ME!theta
- DOCUMENT ME!createGabor
- DOCUMENT ME!
-
makeGaussianFilter
private void makeGaussianFilter(double rmsFreq)
DOCUMENT ME!- Parameters:
rmsFreq
- DOCUMENT ME!
-
makeHomomorphicFilter
private void makeHomomorphicFilter(double fr1)
DOCUMENT ME!- Parameters:
fr1
- DOCUMENT ME!
-
makeKernelData
private void makeKernelData()
sets the kernel variables.
-
phase
private void phase(float[] phase)
Calculates phase from real and imaginary parts.- Parameters:
phase
- = arctan(imagData/realData);
-
restoreFinalData
private void restoreFinalData()
DOCUMENT ME!
-
shiftBack
private void shiftBack(float[] rData)
Shifts the FFT data back from the center for processing purposes and inverse FFT.- Parameters:
rData
- DOCUMENT ME!
-
zeroAround
private void zeroAround()
If a cropping operation was performed, shift the data back to the center and put zeros around the edges.
-
-