Class ChirpZTransform
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.filters.ChirpZTransform
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class ChirpZTransform extends AlgorithmBase
- Author:
- ilb This is a port of code in the file czt.py by John Garrett. MIT License Copyright (c) 2020 John Garrett Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. The chirp Z-transform (CZT) is a generalization of the discrete Fourier transform (DFT). While the DFT samples the Z plane at uniformly-spaced points along the unit circle, the chirp Z-transform samples along spiral arcs in the Z-plane, corresponding to straight lines in the S plane. The DFT, real DFT, and zoom DFT can be calculated as special cases of the CZT. References ---------- - [L. Rabiner, R. Schafer and C. Rader, "The chirp z-transform algorithm, "*IEEE Transactions on Audio and Electroacoustics*, vol. 17, no. 2, pp. 86-92, Jun. 1969, doi: 10.1109/TAU.1969.1162034.](https://web.ece.ucsb.edu/Faculty/Rabiner/ece259/Reprints/015_czt.pdf) - [V. Sukhoy and A. Stoytchev, "Generalizing the inverse FFT off the unit circle," *Scientific Reports*, vol. 9, no. 14443, Oct. 2019, doi: 10.1038/s41598-019-50234-9.](https://doi.org/10.1038/s41598-019-50234-9) - [Chirp Z-Transform (Wikipedia)](https://en.wikipedia.org/wiki/Chirp_Z-transform) - [Discrete Fourier Transform (Wikipedia)](https://en.wikipedia.org/wiki/Discrete_Fourier_transform)
-
-
Field Summary
Fields Modifier and Type Field Description private double[]
A
private java.lang.String
f_method
private boolean
forward
private int
M
private int
MN
private int
N
private double[][]
output
private boolean
simple
private java.lang.String
t_method
private ViewUserInterface
UI
private double[]
W
private double[][]
x
private double[][]
X
private double[][]
xX
-
Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStopped
-
-
Constructor Summary
Constructors Constructor Description ChirpZTransform()
ChirpZTransform(double[][] output, double[][] xX, int MN, double[] W, double[] A, boolean simple, java.lang.String t_method, java.lang.String f_method, boolean forward)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private double[][]
_circulant_multiply(double[][] corg, double[][] xorg, java.lang.String f_method)
private void
_czt(double[][] output, double[][] x, int M, double[] W, double[] A)
private double[][]
_fft(double[][] x)
private double[][]
_ifft(double[][] y)
private double[]
_signal_model(double[] tt)
private double[][]
_skew_circulant_multiply(double[][] c, double[][] x, java.lang.String f_method)
private double[][]
_toeplitz_mult_ce(double[][] r, double[][] c, double[][] x, java.lang.String f_method)
private double[][]
_toeplitz_mult_pd(double[][] r, double[][] c, double[][] x, java.lang.String f_method)
private void
assert_almost_equal(double[][] actual, double[][] desired, int decimal, java.lang.String actualString, java.lang.String desiredString)
private double
log2(double input)
void
runAlgorithm()
Actually runs the algorithm.void
test_compare_different_czt_methods()
Starts the program.private double[][][]
toeplitz(double[][] c, double[][] r)
private double
zabs(double zr, double zi)
zabs computes the absolute value or magnitude of a double precision complex variable zr + j*zi.private void
zdiv(double ar, double ai, double br, double bi, double[] cr, double[] ci)
complex divide c = a/b.private void
zexp(double ar, double ai, double[] br, double[] bi)
complex exponential function b = exp(a).private void
zlog(double ar, double ai, double[] br, double[] bi, int[] ierr)
complex logarithm b = clog(a).private void
zmlt(double ar, double ai, double br, double bi, double[] cr, double[] ci)
complex multiply c = a * b.private void
zpow(double zr, double zi, double a, double[] br, double[] bi, int[] ierr)
b = z**a = exp(a*log(z))-
Methods inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
actionPerformed, addListener, addProgressChangeListener, calculateImageSize, calculatePrincipleAxis, computeElapsedTime, computeElapsedTime, convertIntoFloat, delinkProgressToAlgorithm, delinkProgressToAlgorithmMulti, displayError, errorCleanUp, finalize, 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
-
UI
private ViewUserInterface UI
-
xX
private double[][] xX
-
x
private double[][] x
-
X
private double[][] X
-
MN
private int MN
-
M
private int M
-
N
private int N
-
W
private double[] W
-
A
private double[] A
-
simple
private boolean simple
-
t_method
private java.lang.String t_method
-
f_method
private java.lang.String f_method
-
output
private double[][] output
-
forward
private boolean forward
-
-
Method Detail
-
test_compare_different_czt_methods
public void test_compare_different_czt_methods()
Starts the program.
-
assert_almost_equal
private void assert_almost_equal(double[][] actual, double[][] desired, int decimal, java.lang.String actualString, java.lang.String desiredString)
-
runAlgorithm
public void runAlgorithm()
Description copied from class:AlgorithmBase
Actually runs the algorithm. Implemented by inheriting algorithms.- Specified by:
runAlgorithm
in classAlgorithmBase
-
_toeplitz_mult_pd
private double[][] _toeplitz_mult_pd(double[][] r, double[][] c, double[][] x, java.lang.String f_method)
-
_toeplitz_mult_ce
private double[][] _toeplitz_mult_ce(double[][] r, double[][] c, double[][] x, java.lang.String f_method)
-
_skew_circulant_multiply
private double[][] _skew_circulant_multiply(double[][] c, double[][] x, java.lang.String f_method)
-
_circulant_multiply
private double[][] _circulant_multiply(double[][] corg, double[][] xorg, java.lang.String f_method)
-
_fft
private double[][] _fft(double[][] x)
-
_ifft
private double[][] _ifft(double[][] y)
-
log2
private double log2(double input)
-
toeplitz
private double[][][] toeplitz(double[][] c, double[][] r)
-
zabs
private double zabs(double zr, double zi)
zabs computes the absolute value or magnitude of a double precision complex variable zr + j*zi.- Parameters:
zr
- doublezi
- double- Returns:
- double
-
zpow
private void zpow(double zr, double zi, double a, double[] br, double[] bi, int[] ierr)
b = z**a = exp(a*log(z))- Parameters:
zr
-zi
-a
-br
-bi
-ierr
-
-
zlog
private void zlog(double ar, double ai, double[] br, double[] bi, int[] ierr)
complex logarithm b = clog(a).- Parameters:
ar
- doubleai
- doublebr
- double[]bi
- double[]ierr
- int[] ierr = 0, normal return ierr = 1, z = cmplx(0.0, 0.0)
-
zexp
private void zexp(double ar, double ai, double[] br, double[] bi)
complex exponential function b = exp(a).- Parameters:
ar
- doubleai
- doublebr
- double[]bi
- double[]
-
zdiv
private void zdiv(double ar, double ai, double br, double bi, double[] cr, double[] ci)
complex divide c = a/b.- Parameters:
ar
- doubleai
- doublebr
- doublebi
- doublecr
- double[]ci
- double[]
-
zmlt
private void zmlt(double ar, double ai, double br, double bi, double[] cr, double[] ci)
complex multiply c = a * b.- Parameters:
ar
- doubleai
- doublebr
- doublebi
- doublecr
- double[]ci
- double[]
-
_signal_model
private double[] _signal_model(double[] tt)
-
_czt
private void _czt(double[][] output, double[][] x, int M, double[] W, double[] A)
-
-