Class CAAMShapeCollection

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<CAAMShape>, java.util.Collection<CAAMShape>, java.util.List<CAAMShape>, java.util.RandomAccess

    public class CAAMShapeCollection
    extends java.util.Vector<CAAMShape>
    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 $ Shape collection container and shape-aligner. This class act as a container for a set of shapes. Secondary it can align the set of shapes to a normalised reference frame with respect to position, scale and orientation.
    Author:
    Ruida Cheng
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private double m_dAvgSize
      The average shape size (calculated during alignment).
      private CAAMShape m_MeanShapeBeforeTS
      The meanshape prior to tangent space projection (calculated during alignment).
      private java.lang.String m_szPath
      Path to the .asf files (if any).
      • Fields inherited from class java.util.Vector

        capacityIncrement, elementCount, elementData
      • Fields inherited from class java.util.AbstractList

        modCount
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int AlignShapes()
      Alight shapes
      int AlignShapes​(boolean use_tangentspace)
      Normalizes all shapes with respect to position, scale and orientation.
      void assign​(CAAMShapeCollection shapeCollection)
      Assignment operator
      void dispose()
      dispose memory
      void Expand​(int nPixels)
      Expands all shapes (contraction can be done by using a negative nPixels).
      void Insert​(CAAMShape s)
      Inserts a shape into the collection.
      double MaxX()
      Find the maximum x component of all shapes.
      double MaxY()
      Find the maximum y component of all shapes.
      void MeanShape​(CAAMShape meanShape)
      Calcs the mean shape of all shapes.
      double MeanSize()
      Returns the average shape size *before* the aligment process.
      double MinX()
      Find the minimum x component of all shapes.
      double MinY()
      Find the minimum x component of all shapes.
      int NPoints()
      The number of points in each of shape.
      int NShapes()
      The number of shapes in the collection.
      java.lang.String Path()
      Returns the path of all shapes.
      boolean ReadImages​(java.util.Vector<ModelImage> modelImageVector)
      Wrapper to read shape from given image and VOIs vector
      boolean ReadImages​(java.util.Vector<ModelImage> modelImageVector, boolean validate)
      Reads a set of shapes in the order given in the vector of strings.
      boolean ReadShapes​(java.util.Vector<java.lang.String> asfFiles)
      Wrapper to read shapes from asf files
      boolean ReadShapes​(java.util.Vector<java.lang.String> asfFiles, boolean validate)
      Reads a set of shapes in the order given in the vector of strings.
      void ReferenceShape​(CAAMShape refShape)
      Calcs the mean shape of all aligned shapes and size it to mean size.
      void Rel2Abs()
      Convert shape from relative coordinates to abs coordinates
      void Rel2Abs​(int rfactor)
      Converts all shapes with relative coordinates to absolute.
      void Scale​(double s)
      Wrapper to scale all shape
      void Scale​(double s, boolean aroundCOG)
      Scale the shapes.
      int ToMatlab​(java.lang.String sFilename, java.lang.String sName, java.lang.String sComment, boolean fAppend)
      Writes the shapes in a (NShapes x 2*NPoints) matrix in Matlab (*.m) format.
      • Methods inherited from class java.util.Vector

        add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, forEach, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, iterator, lastElement, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeIf, removeRange, replaceAll, retainAll, set, setElementAt, setSize, size, sort, spliterator, subList, toArray, toArray, toString, trimToSize
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, stream, toArray
    • Field Detail

      • m_MeanShapeBeforeTS

        private CAAMShape m_MeanShapeBeforeTS
        The meanshape prior to tangent space projection (calculated during alignment).
      • m_dAvgSize

        private double m_dAvgSize
        The average shape size (calculated during alignment).
      • m_szPath

        private java.lang.String m_szPath
        Path to the .asf files (if any).
    • Constructor Detail

      • CAAMShapeCollection

        public CAAMShapeCollection()
        Constructor.
    • Method Detail

      • NShapes

        public int NShapes()
        The number of shapes in the collection.
      • NPoints

        public int NPoints()
        The number of points in each of shape.
      • Path

        public java.lang.String Path()
        Returns the path of all shapes.
      • MeanSize

        public double MeanSize()
        Returns the average shape size *before* the aligment process.
      • assign

        public void assign​(CAAMShapeCollection shapeCollection)
        Assignment operator
        Parameters:
        shapeCollection - shape collection reference
      • dispose

        public void dispose()
        dispose memory
      • Insert

        public void Insert​(CAAMShape s)
        Inserts a shape into the collection.
        Parameters:
        s - The input shape.
      • ToMatlab

        public int ToMatlab​(java.lang.String sFilename,
                            java.lang.String sName,
                            java.lang.String sComment,
                            boolean fAppend)
        Writes the shapes in a (NShapes x 2*NPoints) matrix in Matlab (*.m) format. The i-th row thus contains the i-th shape in xxxyy format.
        Parameters:
        sFilename - Filename including path to be written.
        sName - The matlab variable name of the matrix.
        sComment - An optional comment.
        fAppend - Addend to an existing file or overwrite.
        Returns:
        Zero on sucess, non-zero if no shapes are stored in the collection.
      • AlignShapes

        public int AlignShapes()
        Alight shapes
        Returns:
        success or not.
      • AlignShapes

        public int AlignShapes​(boolean use_tangentspace)
        Normalizes all shapes with respect to position, scale and orientation. Position normalization are done by a translation of the center of gravity to orig. Scale normalization are done by a scaling of 1/. Rotation normalization are done by minimizing the sum of squared point distances, as described by all using Singular Value Decomposition (SVD).
        Returns:
        Zero on success.
      • MeanShape

        public void MeanShape​(CAAMShape meanShape)
        Calcs the mean shape of all shapes.
        Parameters:
        meanShape - The output mean shape.
      • ReferenceShape

        public void ReferenceShape​(CAAMShape refShape)
        Calcs the mean shape of all aligned shapes and size it to mean size.
        Parameters:
        refShape - The output reference shape.
      • MinX

        public double MinX()
        Find the minimum x component of all shapes.
        Returns:
        The x-minimum.
      • MaxX

        public double MaxX()
        Find the maximum x component of all shapes.
        Returns:
        The x-maximum.
      • MinY

        public double MinY()
        Find the minimum x component of all shapes.
        Returns:
        The x-minimum.
      • MaxY

        public double MaxY()
        Find the maximum y component of all shapes.
        Returns:
        The y-maximum.
      • Scale

        public void Scale​(double s)
        Wrapper to scale all shape
        Parameters:
        s - scale factor
      • Scale

        public void Scale​(double s,
                          boolean aroundCOG)
        Scale the shapes.
        Parameters:
        s - Scale factor.
        aroundCOG - If true the scale is being done around the cog of the shape instead of around the global center.
      • Expand

        public void Expand​(int nPixels)
        Expands all shapes (contraction can be done by using a negative nPixels). xpands all shapes by moving each model point 'nPixels' perpendicular to the shape contour (that is: along the model point normal). This function will expand each outer (closed) path of the shape. No tests for crossing contours are being made as of now.
        Parameters:
        nPixels - The number of pixel to expand the shape with.
      • ReadShapes

        public boolean ReadShapes​(java.util.Vector<java.lang.String> asfFiles)
        Wrapper to read shapes from asf files
        Parameters:
        asfFiles - asf file vector
        Returns:
        success or not
      • ReadImages

        public boolean ReadImages​(java.util.Vector<ModelImage> modelImageVector)
        Wrapper to read shape from given image and VOIs vector
        Parameters:
        modelImageVector - image and voi vector
        Returns:
        success or not.
      • ReadShapes

        public boolean ReadShapes​(java.util.Vector<java.lang.String> asfFiles,
                                  boolean validate)
        Reads a set of shapes in the order given in the vector of strings.
        Parameters:
        asfFiles - Vector of asf filenames.
        validate - Validates that all shapes have the same number of points.
        Returns:
        True on a valid training set - otherwise false.
      • ReadImages

        public boolean ReadImages​(java.util.Vector<ModelImage> modelImageVector,
                                  boolean validate)
        Reads a set of shapes in the order given in the vector of strings.
        Parameters:
        asfFiles - Vector of asf filenames.
        validate - Validates that all shapes have the same number of points.
        Returns:
        True on a valid training set - otherwise false.
      • Rel2Abs

        public void Rel2Abs()
        Convert shape from relative coordinates to abs coordinates
      • Rel2Abs

        public void Rel2Abs​(int rfactor)
        Converts all shapes with relative coordinates to absolute. Unfortunately this requires to read the headers of all host images. VisSDK does not provide any operation for this. Thus, all images are one by one read into memory and discarded again to obtain height and width. Very costly :-(
        Parameters:
        rfactor - Optional reduction factor. Performs a scaling of the the shape by 1/rfactor. Default 1 i.e. no scaling.