Class ModelImage3DLayout

java.lang.Object
gov.nih.mipav.view.renderer.flythroughview.ModelImage3DLayout

public class ModelImage3DLayout extends Object
Used to store the information and layout which describes a volume of data.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Stores the indexes into a linear array for the samples to use in computing finite difference based gradients as follows:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final float[]
    Array of exact Euclidean distances (in sample coordinates) to each of the 26-connected neighbors corresponding to the relative indexes in m_aiOffsetNeighbors27 array.
    private final float[]
    Array of exact Euclidean distances to each of the 26-connected neighbors scaled by the size of each sample along each axis and corresponding to the relative indexes in m_aiOffsetNeighbors27 array.
    private final int[]
    Array of 27 index offsets used by the getOffsetXYZNeighbors27 method.
    private final int[]
    Array of 8 index offsets used by the getIndexNeighborsVoxel method.
    private final Point3D[]
    Array of 27 index offsets used by the getIndexNeighbors27 method.
    final boolean
    Flag set to reverse order of "real" X coordinates assigned to samples.
    final boolean
    Flag set to reverse order of "real" Y coordinates assigned to samples.
    final boolean
    Flag set to reverse order of "real" Z coordinates assigned to samples.
    final float
    "Real" coordinate of sample at the 0 index along the X axis.
    final float
    "Real" coordinate of sample at the 0 index along the X axis.
    final float
    "Real" coordinate of sample at the 0 index along the X axis.
    final float
    Spacing between each sample along X axis.
    final float
    Spacing between each sample along Y axis.
    final float
    Spacing between each sample along Z axis.
    final int
    Number of samples in volume along X axis.
    final int
    Number of samples in volume along Y axis.
    final int
    Number of samples in volume along Z axis.
    Index offsets used by the getIndexNeighborsGradient method.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ModelImage3DLayout(int iDimX, int iDimY, int iDimZ, float fSpacingX, float fSpacingY, float fSpacingZ, float fOffsetX, float fOffsetY, float fOffsetZ)
    Create a volume with the specified dimensions.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    getDistanceNeighbors27(float[] afDistances)
    Fill an array of distances to the 26-connected neighbors for any given sample where the distances are the Euclidean distances in sample coordinates.
    int
    getIndex(int iX, int iY, int iZ)
    Compute the index in a linear data array dimensioned to store all the samples of this volume.
    int
    getIndexChecked(int iX, int iY, int iZ)
    Compute the index in a linear data array dimensioned to store all the samples of this volume.
    int
    Get the amount to increment the linear array index for each increment in the x coordinate index.
    int
    Get the amount to increment the linear array index for each increment in the y coordinate index.
    int
    Get the amount to increment the linear array index for each increment in the z coordinate index.
    void
    getIndexNeighbors27(int iIndexCenter, int[] aiIndexes)
    Fill an array of indexes for a linear array of volume values.
    void
    getIndexNeighbors27(int iX, int iY, int iZ, int[] aiIndexes)
    Fill an array of indexes for a linear array of volume values.
    void
    getIndexNeighborsGradient(int iX, int iY, int iZ, ModelImage3DLayout.GradientNeighbors kNeighbors)
    Retrieve the indexes for the 6-connected neighbors of the specified sample which are used to compute the gradient.
    void
    getIndexNeighborsVoxel(int iX, int iY, int iZ, int[] aiIndexes)
    Fill an array of indexes for a linear array of volume values.
    int
    getIndexX(int iIndex)
    Get X sample coordinate from a linear array index for volume data.
    int
    getIndexY(int iIndex)
    Get Y sample coordinate from a linear array index for volume data.
    int
    getIndexZ(int iIndex)
    Get Z sample coordinate from a linear array index for volume data.
    int
    Query the total number of samples for a volume with these parameters.
    void
    Fill in the array of offsets to the 26-connected neighbors for any given sample in the volume.
    float
    getRealDistance(int iX1, int iY1, int iZ1, int iX2, int iY2, int iZ2)
    Given the coordinates of two points in sample space of the volume, compute the real distance betwen them by taking into consideration the spacing between samples in the volume along each axis.
    void
    getRealDistanceNeighbors27(float[] afDistances)
    Fill an array of distances to the 26-connected neighbors for any given sample where the distances are the real Euclidean distances scaled by the size of the sample along each axis.
    void
    getRealPoint(int iX, int iY, int iZ, WildMagic.LibFoundation.Mathematics.Vector3f kPoint)
    Compute the "real" coordinates of the sample in the volume at the specified sample coordinate indexes.
    WildMagic.LibFoundation.Mathematics.Vector3f
    getSamplePoint(float x, float y, float z)
    Convert the input "real" coordinates into sample coordinates.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • m_bReverseX

      public final boolean m_bReverseX
      Flag set to reverse order of "real" X coordinates assigned to samples.
    • m_bReverseY

      public final boolean m_bReverseY
      Flag set to reverse order of "real" Y coordinates assigned to samples.
    • m_bReverseZ

      public final boolean m_bReverseZ
      Flag set to reverse order of "real" Z coordinates assigned to samples.
    • m_fOffsetX

      public final float m_fOffsetX
      "Real" coordinate of sample at the 0 index along the X axis.
    • m_fOffsetY

      public final float m_fOffsetY
      "Real" coordinate of sample at the 0 index along the X axis.
    • m_fOffsetZ

      public final float m_fOffsetZ
      "Real" coordinate of sample at the 0 index along the X axis.
    • m_fSpacingX

      public final float m_fSpacingX
      Spacing between each sample along X axis.
    • m_fSpacingY

      public final float m_fSpacingY
      Spacing between each sample along Y axis.
    • m_fSpacingZ

      public final float m_fSpacingZ
      Spacing between each sample along Z axis.
    • m_iDimX

      public final int m_iDimX
      Number of samples in volume along X axis.
    • m_iDimY

      public final int m_iDimY
      Number of samples in volume along Y axis.
    • m_iDimZ

      public final int m_iDimZ
      Number of samples in volume along Z axis.
    • m_afDistanceNeighbors27

      private final float[] m_afDistanceNeighbors27
      Array of exact Euclidean distances (in sample coordinates) to each of the 26-connected neighbors corresponding to the relative indexes in m_aiOffsetNeighbors27 array.
    • m_afRealDistanceNeighbors27

      private final float[] m_afRealDistanceNeighbors27
      Array of exact Euclidean distances to each of the 26-connected neighbors scaled by the size of each sample along each axis and corresponding to the relative indexes in m_aiOffsetNeighbors27 array.
    • m_aiOffsetNeighbors27

      private final int[] m_aiOffsetNeighbors27
      Array of 27 index offsets used by the getOffsetXYZNeighbors27 method.
    • m_aiOffsetNeighborsVoxel

      private final int[] m_aiOffsetNeighborsVoxel
      Array of 8 index offsets used by the getIndexNeighborsVoxel method.
    • m_akOffsetXYZNeighbors27

      private final Point3D[] m_akOffsetXYZNeighbors27
      Array of 27 index offsets used by the getIndexNeighbors27 method.
    • m_kOffsetNeighborsGradient

      private final ModelImage3DLayout.GradientNeighbors m_kOffsetNeighborsGradient
      Index offsets used by the getIndexNeighborsGradient method.
  • Constructor Details

    • ModelImage3DLayout

      public ModelImage3DLayout(int iDimX, int iDimY, int iDimZ, float fSpacingX, float fSpacingY, float fSpacingZ, float fOffsetX, float fOffsetY, float fOffsetZ)
      Create a volume with the specified dimensions.
      Parameters:
      iDimX - number of samples along the X axis
      iDimY - number of samples along the Y axis
      iDimZ - number of samples along the Z axis
      fSpacingX - spacing between samples along the X axis. Value can be negative to indicated a reverse direction for real coords.
      fSpacingY - spacing between samples along the Y axis Value can be negative to indicated a reverse direction for real coords.
      fSpacingZ - spacing between samples along the Z axis Value can be negative to indicated a reverse direction for real coords.
      fOffsetX - X coordinate of samples at X sample index 0
      fOffsetY - Y coordinate of samples at Y sample index 0
      fOffsetZ - Z coordinate of samples at Z sample index 0
  • Method Details

    • getDistanceNeighbors27

      public void getDistanceNeighbors27(float[] afDistances)
      Fill an array of distances to the 26-connected neighbors for any given sample where the distances are the Euclidean distances in sample coordinates.
      Parameters:
      afDistances - must be an array with at least 27 entries where these entries will be filled in with the Euclidean distances for the 26-connected neighbors of any given sample in the volume. The ordering of the distances corresponds to the ordering of the relative linear array indexes returned by the getOffsetNeighbors27 method. Note that the [0] entry is for the center sample (always a distance of zero), and the remaining 26 entries are for the neighbor samples distances.
    • getIndex

      public int getIndex(int iX, int iY, int iZ)
      Compute the index in a linear data array dimensioned to store all the samples of this volume. The index is determined by the specified 3D coordinate indexes. No checking is made to ensure that the coordinate indexes are in their respective ranges.
      Parameters:
      iX - sample X coordinate index
      iY - sample Y coordinate index
      iZ - sample Z coordinate index
      Returns:
      1D index into linear array
    • getIndexChecked

      public int getIndexChecked(int iX, int iY, int iZ)
      Compute the index in a linear data array dimensioned to store all the samples of this volume. The index is determined by the specified 3D coordinate indexes. Each coordinate index is checked to ensure that it is within its respective coordinate ranges.
      Parameters:
      iX - sample X coordinate index
      iY - sample Y coordinate index
      iZ - sample Z coordinate index
      Returns:
      1D index into linear array or -1 if any of the indexes are outside their respective coordinate ranges
    • getIndexIncX

      public int getIndexIncX()
      Get the amount to increment the linear array index for each increment in the x coordinate index.
      Returns:
      int Positive linear array index increment.
    • getIndexIncY

      public int getIndexIncY()
      Get the amount to increment the linear array index for each increment in the y coordinate index.
      Returns:
      int Positive linear array index increment.
    • getIndexIncZ

      public int getIndexIncZ()
      Get the amount to increment the linear array index for each increment in the z coordinate index.
      Returns:
      int Positive linear array index increment.
    • getIndexNeighbors27

      public void getIndexNeighbors27(int iIndexCenter, int[] aiIndexes)
      Fill an array of indexes for a linear array of volume values. These indexes are for the specified sample and the indexes of the immediate 26-connected neighbors.

      Unexpected results occur, e.g. invalid sample indexes, if the center sample specified by the indexes is for one on the border of the volume.

      Parameters:
      iIndexCenter - linear volume data array index center sample
      aiIndexes - must be an array with at least 27 entries where these entries will be filled in with the indexes for linear volume data array for the specified sample and its 26-connected neighbors. Note that the [0] entry is for the center sample, but there is no specified ordering for the 26 neighbor samples.
    • getIndexNeighbors27

      public void getIndexNeighbors27(int iX, int iY, int iZ, int[] aiIndexes)
      Fill an array of indexes for a linear array of volume values. These indexes are for the specified sample and the indexes of the immediate 26-connected neighbors.

      Unexpected results occur, e.g. invalid sample indexes, if the center sample specified by the indexes is for one on the border of the volume.

      Parameters:
      iX - sample X coordinate index for center sample
      iY - sample Y coordinate index for center sample
      iZ - sample Z coordinate index for center sample
      aiIndexes - must be an array with at least 27 entries where these entries will be filled in with the indexes for linear volume data array for the specified sample and its 26-connected neighbors. Note that the [0] entry is for the center sample, but there is no specified ordering for the 26 neighbor samples.
    • getIndexNeighborsGradient

      public void getIndexNeighborsGradient(int iX, int iY, int iZ, ModelImage3DLayout.GradientNeighbors kNeighbors)
      Retrieve the indexes for the 6-connected neighbors of the specified sample which are used to compute the gradient. If the sample is along any border of the volume, then the indexes for a forward/reverse finite difference are returned which would involve the sample itself but only for the axis where the sample is along its corresponding border. Otherwise, the samples are returned for computing finite central difference.

      Unexpected results occur, e.g. invalid sample indexes, if the center sample specified by the indexes is for one on the border of the volume.

      Parameters:
      iX - sample X coordinate index for center sample
      iY - sample Y coordinate index for center sample
      iZ - sample Z coordinate index for center sample
      kNeighbors - contains the indexes for the 6-connected neighbors used to compute the gradient
    • getIndexNeighborsVoxel

      public void getIndexNeighborsVoxel(int iX, int iY, int iZ, int[] aiIndexes)
      Fill an array of indexes for a linear array of volume values. These indexes are for the specified sample and the indexes of the immediate neighbor samples that comprise a voxel. Of the 8 neighboring samples returned for a voxel, the specified sample will have the smallest of the coordinate indexes, i.e., the "minimum" corner sample.

      Unexpected results occur, e.g. invalid sample indexes, if the specified sample is along any of the maximum borders of the volume (given by an sample coordinate index being the maximum for the corresponding axis).

      Parameters:
      iX - sample X coordinate index for "minimum" corner sample
      iY - sample Y coordinate index for "minimum" corner sample
      iZ - sample Z coordinate index for "minimum" corner sample
      aiIndexes - must be an array with at least 8 entries where these entries will be filled in with the indexes for linear volume data array for the specified sample and its voxel neighbors. Note that the [0] entry is for the specified sample, but there is no specified ordering for the other 7 neighbor samples.
    • getIndexX

      public int getIndexX(int iIndex)
      Get X sample coordinate from a linear array index for volume data.
      Parameters:
      iIndex - linear array index
      Returns:
      X sample coordinate
    • getIndexY

      public int getIndexY(int iIndex)
      Get Y sample coordinate from a linear array index for volume data.
      Parameters:
      iIndex - linear array index
      Returns:
      Y sample coordinate
    • getIndexZ

      public int getIndexZ(int iIndex)
      Get Z sample coordinate from a linear array index for volume data.
      Parameters:
      iIndex - linear array index
      Returns:
      Z sample coordinate
    • getNumSamples

      public int getNumSamples()
      Query the total number of samples for a volume with these parameters.
      Returns:
      number of voxels
    • getOffsetXYZNeighbors27

      public void getOffsetXYZNeighbors27(Point3D[] akOffsetXYZ)
      Fill in the array of offsets to the 26-connected neighbors for any given sample in the volume.
      Parameters:
      akOffsetXYZ - must be an array with at least 27 enties where these entries will be filled in with the XYZ index offsets for the 26-connected neighbors of any given sample in the volume. The ordering of the offsets corresponds to the ordering of the relative linear array indexes returned by the getIndexNeighbors27 method. Note that the [0] entry is for the center sample (always XYZ offsets of zero), and the remaining 26 entries are for the neighbor samples.
    • getRealDistance

      public float getRealDistance(int iX1, int iY1, int iZ1, int iX2, int iY2, int iZ2)
      Given the coordinates of two points in sample space of the volume, compute the real distance betwen them by taking into consideration the spacing between samples in the volume along each axis.
      Parameters:
      iX1 - X-axis sample coordinate of first point
      iY1 - Y-axis sample coordinate of first point
      iZ1 - Z-axis sample coordinate of first point
      iX2 - X-axis sample coordinate of second point
      iY2 - Y-axis sample coordinate of second point
      iZ2 - Z-axis sample coordinate fo second point
      Returns:
      computed "real" distance between two samples in volume
    • getRealDistanceNeighbors27

      public void getRealDistanceNeighbors27(float[] afDistances)
      Fill an array of distances to the 26-connected neighbors for any given sample where the distances are the real Euclidean distances scaled by the size of the sample along each axis.
      Parameters:
      afDistances - must be an array with at least 27 entries where these entries will be filled in with the Euclidean distances for the 26-connected neighbors of any given sample in the volume. The ordering of the distances corresponds to the ordering of the relative linear array indexes returned by the getOffsetNeighbors27 method. Note that the [0] entry is for the center sample (always a distance of zero), and the remaining 26 entries are for the neighbor samples distances.
    • getRealPoint

      public void getRealPoint(int iX, int iY, int iZ, WildMagic.LibFoundation.Mathematics.Vector3f kPoint)
      Compute the "real" coordinates of the sample in the volume at the specified sample coordinate indexes.
      Parameters:
      iX - sample X coordinate index
      iY - sample Y coordinate index
      iZ - sample Z coordinate index
      kPoint - Point3f into which the computed coordinates are stored
    • getSamplePoint

      public WildMagic.LibFoundation.Mathematics.Vector3f getSamplePoint(float x, float y, float z)
      Convert the input "real" coordinates into sample coordinates.
      Parameters:
      kRealPoint - Point3f These are the "real" coordinates.
      Returns:
      Point3f This is a new instance containing the interpolated sample coordinates converted from the input real coordinates.