Class CAAMMathUtil


  • public class CAAMMathUtil
    extends java.lang.Object
    This is the Java modified version of C++ active appearance model API (AAM_API). It is modified with a subset of required functions for automatic MRI prostate segmentation. AAM-API LICENSE - file: license.txt This software is freely available for non-commercial use such as research and education. Please see the full disclaimer below. All publications describing work using this software should cite the reference given below. Copyright (c) 2000-2003 Mikkel B. Stegmann, mbs@imm.dtu.dk IMM, Informatics & Mathematical Modelling DTU, Technical University of Denmark Richard Petersens Plads, Building 321 DK-2800 Lyngby, Denmark http://www.imm.dtu.dk/~aam/ REFERENCES Please use the reference below, when writing articles, reports etc. where the AAM-API has been used. A draft version the article is available from the homepage. I will be happy to receive pre- or reprints of such articles. /Mikkel ------------- M. B. Stegmann, B. K. Ersboll, R. Larsen, "FAME -- A Flexible Appearance Modelling Environment", IEEE Transactions on Medical Imaging, IEEE, 2003 (to appear) ------------- 3RD PART SOFTWARE The software is partly based on the following libraries: - The Microsoft(tm) Vision Software Developers Kit, VisSDK - LAPACK DISCLAIMER This software is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any non-commercial purpose, and to alter it, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. -- No guarantees of performance accompany this software, nor is any responsibility assumed on the part of the author or IMM. This software is provided by Mikkel B. Stegmann and IMM ``as is'' and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall IMM or Mikkel B. Stegmann be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. $Revision: 1.4 $ $Date: 2003/04/23 14:49:15 $ Utility math/statistical methods for the AAM project. This is the mathematical / statistical garbage bin. It consists of methods that for some reason haven't found its way into other (and more meaningful) classes. methods are static, so there is never need for an instantiation of this class.
    Author:
    Ruida Cheng
    • Constructor Detail

      • CAAMMathUtil

        public CAAMMathUtil()
    • Method Detail

      • Hist

        public static void Hist​(CDVector v,
                                double min,
                                double max,
                                CDVector hist,
                                int nbins,
                                boolean normalize,
                                boolean transform)
        Calculates the histogram of a vector within [min;max] with optional nomalization.
        Parameters:
        v - Input vector.
        min - Value for the first bin (values lower are clamped to min).
        max - Value for the last bin (values lower are clamped to max).
        hist - Output histogram vector.
        nbins - The number of bins. Default 256.
        normalize - Optional normalization, i.e. make the histogram entries sum to 1. Default true.
        transform - Optional transformation of v into 'nbins' integer intervals between [min;max]. Default false.
      • CumSum

        public void CumSum​(CDVector v,
                           CDVector cumsum,
                           boolean normalize)
        Cumulative sum of elements.
        Parameters:
        v - Input vector.
        cumsum - Output vector containing the cumulative sum of elements.
        normalize - Optional normalization of output, i.e. cumsum[end] = 1.0. Default true.
      • MutualInformation

        public static double MutualInformation​(CDVector v1,
                                               CDVector v2,
                                               int nbins)
        Calulates the Mutual Information (MI) between two vectors. See e.g. C. Studholme et al. or Viola et al.
        Parameters:
        v1 - Signal 1.
        v2 - Signal 2.
        nbins - The number of bins in the single and joint histograms. Default 256.
        Returns:
        The Mutual Information (MI).
      • GaussianHistogramMatching

        public void GaussianHistogramMatching​(CDVector v,
                                              CDVector out,
                                              int nbins,
                                              CDVector gaussLUT)
        Maps the distibution of v into an approximate Gaussian distribution.
        Parameters:
        v - Input vector.
        out - Output vector.
        nbins - Number of bins used to approx the distribution. Default 256.
        gaussLUT - If not null, the calulated LUT is returned here.
      • ExpandMatrix2DyadicSize

        public void ExpandMatrix2DyadicSize​(CDMatrix m,
                                            CDMatrix dyad)
        This method expands a matrix to have dynamic size, i.e. nrows and ncols that are powers of two. Expansion are done using zero-padding.
        Parameters:
        m - Input matrix.
        dyad - Output dynamic version.
      • CalcElementVar

        public static void CalcElementVar​(java.util.Vector<CDVector> vVectors,
                                          CDVector varVec)
        Wrapper to calculate element variables.
        Parameters:
        vVectors - Input set of vectors.
        varVec - A vector containing the variance of each component in cVectors.
      • CalcElementVar

        public static void CalcElementVar​(java.util.Vector<CDVector> vVectors,
                                          CDVector varVec,
                                          CDVector vpMean)
        Calculates the variance of each component in a set of vectors.
        Parameters:
        cVectors - Input set of vectors.
        varVec - A vector containing the variance of each component in cVectors.
        vpMean - Optional vector pointer to return the mean vector in.
      • LinearStretchMinMax

        public static void LinearStretchMinMax​(CDVector v,
                                               double new_min,
                                               double new_max)
        Maps a vector linearly from [min;max] to [new_min;new_max].
        Parameters:
        v - Input vector.
        new_min - Desired minimum.
        new_max - Desired maximum.
      • LinearStretchClamp

        public void LinearStretchClamp​(CDVector v,
                                       double x1,
                                       double x2,
                                       double new_min,
                                       double new_max)
        Maps a vector linearly from [x1;x2] to [new_min;new_max]. Values outside [x1;x2] are clamped to x1, x2 respectively.
        Parameters:
        v - Input vector.
        x1 - Starting point of stretch.
        x2 - Ending point of stretch.
        new_min - Desired minimum.
        new_max - Desired maximum.
      • MeanFilter

        public void MeanFilter​(CDMatrix in,
                               CDMatrix out)
        Performs a 3x3 mean filtering of a matrix.
        Parameters:
        in - Input matrix.
        out - Output mean filtered matrix.
      • ZeroMeanUnitLength

        public static void ZeroMeanUnitLength​(CDVector v)
        Normalises a vector to zero mean and unit length.
        Parameters:
        v - Input vector.
      • PseudoInv

        public void PseudoInv​(CDMatrix A,
                              CDMatrix P)
        Calculates the pseudo inverse of a matrix.
        Parameters:
        A - Input matrix.
        P - Pseudo inverse of A.