Class AlgorithmWaveletThreshold

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.WindowListener, java.lang.Runnable, java.util.EventListener

    public class AlgorithmWaveletThreshold
    extends AlgorithmBase

    In hard thresholding a wavelet coefficient whose magnitude is below the product of threshold and the maximum wavelet magnitude is zeroed, and a wavelet coefficient whose magnitude is greater than or equal to the product is left unchanged. In soft thresholding a wavelet coefficient whose magnitude is below the product of threshold and the maximum wavelet magnitude is zeroed, and a wavelet coefficient whose magnitude is greater than or equal to the product has its magnitude decreased by the product. Generally, soft thresholding is a better choice. The signal reconstructed with the coefficients left after hard thresholding may have undesirable artifacts including sidelobes. Then, an inverse wavelet transform is performed. The image is stripped down to its original size. The data is clamped so as not to exceed the bounds of the data type of the image into which it is imported. This is a simple method of reducing white noise.

    The forward and inverse Daubechies wavelet transform routines are taken from Numerical Recipes in C The Art of Scientific Computing, 2nd edition, by William H. Press, Saul A. Teukolsky, William T. Vetterling, and Brian P. Flannery, Cambridge University Press, 1997, Chapter 13.10, pp. 591 - 606. The wavelet routines daub4, pwt, wt1, wtn, and pwtset in Numerical Recipes in C are in the public domain. See {@link http://www.nr.com/public-domain.html} for more information.

    The wavelet transform is mathematically defined only within a signal; image applications need to solve the boundary problem. 4 different techniques exist:

    1. Mirror image replication
    2. Zero padding
    3. Linear extrapolation
    4. Circular convolution

    In this module zero padding is used. As stated in the Medx 3.4 User's Guide in Chapter 17 on Advanced Image Processing Techniques: "The mirror condition can only be used with symmetric wavelet basis." "Daubechies wavelet bases are non-symmetrical orthogonal wavelets with compact support and are good for data suppression. Only the periodic boundary condition should be used when using the Daubechies wavelet basis." In Empirical Evaluation of Boundary Policies for Wavelet-based Image Coding by Claudia Schremmer zero padding, circular convolution, and mirror image padding are compared. She concludes that mirror padding works best with regard to quality, zero padding performs worst with regard to quality, and circular convolution is midway between the 2. The matlab wavelet toolbox literature says that "the disadvantage of zero padding is that discontinuities are artificially created at the border." Mirror padding "has the disadvantage of artificially creating discontinuities of the first derivative at the border, but this method works well in general for images." Extrapolation "works well in general for smooth signals." The wavelet toolbox uses mirror padding as its default mode. How much padding is required? Claudia Schremmer states: "With padding, the coefficients of the signal on either side of the border are padded with filter_length - 2 coefficients. Consequently, each signal coefficient enters into filter_length/2 calculations of convolution, and the transform is reversible."

    The image is expanded so that all dimensions are powers of 2 and there is zero padding going past each original boundary by the coefficient number - 2. The image is transformed into wavelet coefficients.

    • Field Detail

      • INVERSE

        public static final int INVERSE
        FORWARD and INVERSE are 2 possible transformDir values
        See Also:
        Constant Field Values
      • DAUB4

        public static final int DAUB4
        underlying wavelet filter For 4 coefficients the routine daub4 is considerably faster than pwt. DAUB4 implements a Daubechies 4-coefficient wavelet filter. PWT implements Daubechies filters with 4, 12, and 20 coefficients. DAUB4 and PWT use different default centerings. In spite of the faster speed of DAUB4, the dialog is designed only to call PWT so that the user only sees changes due to the number of coefficients and is not confused by changes in centering. Reference on NONNEGATIVE_GARROTE and SCAD thresholding: "Wavelet Estimators in Nonparametric Regression: A Comparative Simulation Study" by Anestis Antoniadis, Jeremie Bigot, and Theofanis Sapatinas, Journal of Statistical Software, Vol. 6, Issue 6, pp. 1-83, 2001.
        See Also:
        Constant Field Values
      • C0

        public static final double C0
        coefficents for DAUB4 wavelet filter.
        See Also:
        Constant Field Values
      • c4

        public static final double[] c4
        coefficients for the PWT filter.
      • c12

        public static final double[] c12
        DOCUMENT ME!
      • c20

        public static final double[] c20
        DOCUMENT ME!
      • aArray

        private float[] aArray
        DOCUMENT ME!
      • aCutoff

        private float aCutoff
        DOCUMENT ME!
      • aExp

        private float[] aExp
        DOCUMENT ME!
      • aLog

        private float[] aLog
        DOCUMENT ME!
      • aMax

        private float aMax
        DOCUMENT ME!
      • arrayLength

        private int arrayLength
        DOCUMENT ME!
      • belowThreshold

        private int belowThreshold
        DOCUMENT ME!
      • cc

        private double[] cc
        DOCUMENT ME!
      • cm2

        private final int cm2
        DOCUMENT ME!
      • cNum

        private final int cNum
        DOCUMENT ME!
      • cr

        private double[] cr
        DOCUMENT ME!
      • dataType

        private int dataType
        DOCUMENT ME!
      • doWaveletImage

        private final boolean doWaveletImage
        DOCUMENT ME!
      • extents

        private int[] extents
        DOCUMENT ME!
      • filterType

        private final int filterType
        DOCUMENT ME!
      • foundSize

        private boolean foundSize
        DOCUMENT ME!
      • ioff

        private int ioff
        DOCUMENT ME!
      • joff

        private int joff
        DOCUMENT ME!
      • minSize

        private int minSize
        DOCUMENT ME!
      • nDims

        private int nDims
        DOCUMENT ME!
      • newArrayLength

        private int newArrayLength
        DOCUMENT ME!
      • newExtents

        private int[] newExtents
        DOCUMENT ME!
      • newXDim

        private int newXDim
        DOCUMENT ME!
      • newYDim

        private int newYDim
        DOCUMENT ME!
      • newZDim

        private int newZDim
        DOCUMENT ME!
      • offsetX

        private int offsetX
        DOCUMENT ME!
      • offsetY

        private int offsetY
        DOCUMENT ME!
      • offsetZ

        private int offsetZ
        DOCUMENT ME!
      • threshold

        private final float threshold
        DOCUMENT ME!
      • thresholdType

        private final int thresholdType
        DOCUMENT ME!
      • transformDir

        private int transformDir
        DOCUMENT ME!
      • waveletImage

        private ModelImage waveletImage
        DOCUMENT ME!
      • xDim

        private int xDim
        DOCUMENT ME!
      • yDim

        private int yDim
        DOCUMENT ME!
      • zDim

        private int zDim
        DOCUMENT ME!
      • xy

        private int xy
        DOCUMENT ME!
      • newXY

        private int newXY
        DOCUMENT ME!
    • Constructor Detail

      • AlgorithmWaveletThreshold

        public AlgorithmWaveletThreshold​(ModelImage srcImg,
                                         int filterType,
                                         int cNum,
                                         int thresholdType,
                                         float threshold,
                                         boolean doWaveletImage)
        Creates a new AlgorithmWaveletThreshold object.
        Parameters:
        srcImg - source image model
        filterType - wavelet filter
        cNum - number of coefficients in the pwt filter
        thresholdType - HARD or SOFT thresholding
        threshold - fraction of maximum magnitude below which coefficients are zeroed
        doWaveletImage - display wavelet transform image in log magnitude if true
        userInterface - DOCUMENT ME!
      • AlgorithmWaveletThreshold

        public AlgorithmWaveletThreshold​(ModelImage destImg,
                                         ModelImage srcImg,
                                         int filterType,
                                         int cNum,
                                         int thresholdType,
                                         float threshold,
                                         boolean doWaveletImage)
        Creates a new AlgorithmWaveletThreshold object.
        Parameters:
        destImg - image model where result image is to be stored
        srcImg - source image model
        filterType - wavelet filter
        cNum - number of coefficients in the pwt filter
        thresholdType - HARD or SOFT thresholding
        threshold - fraction of maximum magnitude below which coefficients are zeroed
        doWaveletImage - display log maagnitude wavelet transform image if true
        userInterface - DOCUMENT ME!
    • Method Detail

      • finalize

        public void finalize()
        Prepare this class for destruction.
        Overrides:
        finalize in class AlgorithmBase
      • getWaveletImage

        public ModelImage getWaveletImage()
        Accessor that returns the image.
        Returns:
        the wavelet image
      • daub4

        private void daub4​(float[] a,
                           int n)
        DOCUMENT ME!
        Parameters:
        a - data vector to which Daubechies 4-coefficient wavelet filter or its transpose (for transformDir == INVERSE) is applied
        n - DOCUMENT ME!
      • pwt

        private void pwt​(float[] a,
                         int n)
        DOCUMENT ME!
        Parameters:
        a - data to which wavelet filter (for transformDir == FORWARD) or to which transpose wavelet filter is applied (for transformDir == INVERSE)
        n - Used hierarchically by routines wt1 and wtn
      • wt1

        private void wt1​(float[] a)
        DOCUMENT ME!
        Parameters:
        a - data replaced by its wavelet transform for transformDir == FORWARD or by its inverse wavelet transform for transformDir == INVERSE One dimensional discrete wavelet transform. Note that the length of a must be an integer power of 2
      • wtn

        private void wtn​(float[] a)
        DOCUMENT ME!
        Parameters:
        a - data replaced by its wavelet transform for transformDir == FORWARD or by its inverse wavelet transform for transformDir == INVERSE n-dimensional discrete wavelet transform. Note that the length of each dimension of a must be an integer power of 2