Class VolumeRenderer

java.lang.Object
com.eco.bio7.spatial.VolumeRenderer

public class VolumeRenderer extends Object
Renders an ImageJ stack as a volume with a 3D texture. The volume is drawn with slices along the axis which is most aligned with the view direction (back to front). The color of a voxel is the color of the LUT (or gray) and the alpha value the intensity (scaled to the display range of the image). Opacity and threshold are applied while rendering. The colors, the size of the texture and the stack are applied when a stack is loaded!
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes the volume.
    void
    Must be called if the OpenGL context has been created again.
    Returns the selection of the loaded stack (e.g., the range of the threshold of the image) or ValueSelection.ALL.
    Returns the LUT of the loaded stack (for a transfer function with the colors of the image) or null.
    int[]
    Returns the size of the texture (width, height, depth) or null.
    float
    Returns the depth of the volume (slices multiplied with the calibrated voxel depth and the z scale).
    float
     
    int[]
    Returns the histogram of the intensities (256 bins, the display range of the stack) or null if no stack is loaded.
    ij.ImagePlus
    Returns the loaded ImageJ image or null.
    Returns a description of the loaded stack.
    int
     
    int
     
    float
     
    float
    getOpacityAt(double rx, double ry, double rz)
    Returns the opacity (0 - 1) of the displayed voxel at the relative position (0 - 1, y = 0 is the first row) or 0.
    float
     
    Returns the selection of the values (see setSelection).
    float
     
    com.eco.bio7.spatial.TransferFunction
     
    double
    The data value of the position 1 of the transfer function.
    double
    The data value of the position 0 of the transfer function.
    float
     
    float
     
    boolean
    Returns true if a volume is loaded and displayed.
    boolean
    Returns true if a stack is loaded (displayed or not).
    boolean
     
    boolean
     
    boolean
    load(ij.ImagePlus imp)
    Loads a stack (the current channel and frame of a hyperstack) as a volume.
    boolean
    Loads the last loaded stack again (e.g., after a LUT change).
    void
    render(com.jogamp.opengl.GL2 gl, boolean cartesian)
    Renders the volume (Cartesian: centered at the origin, octant: from the origin).
    void
    renderSlice(com.jogamp.opengl.GL2 gl, boolean cartesian, List<double[]> polygon)
    Renders a cross-section of the volume (an opaque polygon with the colors of the voxels, e.g., the cutting plane of Clipping).
    void
    Sets the clipping with the mask of the removed voxels (see Clipping.cutRoi and Clipping.setMask).
    void
    setLutColors(boolean lutColors)
    Use the colors of the LUT, else gray values (applied when a stack is loaded).
    void
    setMaxSize(int maxSize)
    The maximum texture size of a dimension.
    void
    setMode(int mode)
     
    void
    setOpacity(float opacity)
    The opacity of a slice (0-1) in the alpha blending mode.
    void
    setSampling(float sampling)
    The number of slices relative to the number of voxels along the slice axis.
    void
    Sets the values of the stack which are displayed (used by the next load, a loaded stack is loaded again): ValueSelection.ALL (the default), ValueSelection.IMAGE_THRESHOLD (the values in the threshold of the image in ImageJ, e.g., only the particles), a range of values (ValueSelection.range) or the labels of a segmentation (ValueSelection.labels).
    void
    setShow(boolean show)
     
    void
    setThreshold(float threshold)
    Voxels with an intensity (0-1) below or equal to the threshold are not displayed.
    void
    setTransferFunction(com.eco.bio7.spatial.TransferFunction tf)
    Sets a transfer function for the colors and the opacities of the voxels (the intensity 0 - 255 is the position 0 - 1 of the function, the display range of the stack).
    void
    setZScale(float zScale)
    Scales the calibrated depth of the volume.

    Methods inherited from class Object

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

  • Constructor Details

    • VolumeRenderer

      public VolumeRenderer()
  • Method Details

    • load

      public boolean load(ij.ImagePlus imp)
      Loads a stack (the current channel and frame of a hyperstack) as a volume. Must be called again if the stack, the LUT or the display range have been changed!
      Parameters:
      imp - the ImageJ image
      Returns:
      true if the stack has been loaded
    • reload

      public boolean reload()
      Loads the last loaded stack again (e.g., after a LUT change).
      Returns:
      true if the stack has been loaded
    • setTransferFunction

      public void setTransferFunction(com.eco.bio7.spatial.TransferFunction tf)
      Sets a transfer function for the colors and the opacities of the voxels (the intensity 0 - 255 is the position 0 - 1 of the function, the display range of the stack). null uses the colors of the LUT and the intensity as opacity. The texture is created again (the stack is not loaded again).
      Parameters:
      tf - the transfer function (copied) or null
    • setClipping

      public void setClipping(Clipping clipping)
      Sets the clipping with the mask of the removed voxels (see Clipping.cutRoi and Clipping.setMask). The texture is created again after a change of the mask.
      Parameters:
      clipping - the clipping or null
    • setSelection

      public void setSelection(ValueSelection selection)
      Sets the values of the stack which are displayed (used by the next load, a loaded stack is loaded again): ValueSelection.ALL (the default), ValueSelection.IMAGE_THRESHOLD (the values in the threshold of the image in ImageJ, e.g., only the particles), a range of values (ValueSelection.range) or the labels of a segmentation (ValueSelection.labels). The other voxels are transparent.
      Parameters:
      selection - the selection (null = all values)
    • getSelection

      public ValueSelection getSelection()
      Returns the selection of the values (see setSelection).
    • getActiveSelection

      public ValueSelection getActiveSelection()
      Returns the selection of the loaded stack (e.g., the range of the threshold of the image) or ValueSelection.ALL.
    • getImage

      public ij.ImagePlus getImage()
      Returns the loaded ImageJ image or null.
    • getOpacityAt

      public float getOpacityAt(double rx, double ry, double rz)
      Returns the opacity (0 - 1) of the displayed voxel at the relative position (0 - 1, y = 0 is the first row) or 0.
    • getDataSize

      public int[] getDataSize()
      Returns the size of the texture (width, height, depth) or null.
    • getValueMin

      public double getValueMin()
      The data value of the position 0 of the transfer function.
    • getValueMax

      public double getValueMax()
      The data value of the position 1 of the transfer function.
    • getTransferFunction

      public com.eco.bio7.spatial.TransferFunction getTransferFunction()
    • getHistogram

      public int[] getHistogram()
      Returns the histogram of the intensities (256 bins, the display range of the stack) or null if no stack is loaded.
    • getColorModel

      public ColorModel getColorModel()
      Returns the LUT of the loaded stack (for a transfer function with the colors of the image) or null.
    • clear

      public void clear()
      Removes the volume.
    • contextLost

      public void contextLost()
      Must be called if the OpenGL context has been created again. The texture is then created again with the next rendering.
    • isDisplayed

      public boolean isDisplayed()
      Returns true if a volume is loaded and displayed.
    • render

      public void render(com.jogamp.opengl.GL2 gl, boolean cartesian)
      Renders the volume (Cartesian: centered at the origin, octant: from the origin). Must be called after the opaque objects of the scene.
      Parameters:
      gl - the OpenGL context
      cartesian - true for the Cartesian mode
    • renderSlice

      public void renderSlice(com.jogamp.opengl.GL2 gl, boolean cartesian, List<double[]> polygon)
      Renders a cross-section of the volume (an opaque polygon with the colors of the voxels, e.g., the cutting plane of Clipping). Empty voxels (below the threshold) are not drawn. The volume does not need to be displayed (see setShow).
      Parameters:
      gl - the OpenGL context
      cartesian - true for the Cartesian mode
      polygon - the corners of the polygon (scene coordinates)
    • isLoaded

      public boolean isLoaded()
      Returns true if a stack is loaded (displayed or not).
    • getInfo

      public String getInfo()
      Returns a description of the loaded stack.
    • getWidth

      public float getWidth()
    • getHeight

      public float getHeight()
    • getDepth

      public float getDepth()
      Returns the depth of the volume (slices multiplied with the calibrated voxel depth and the z scale).
    • isShow

      public boolean isShow()
    • setShow

      public void setShow(boolean show)
    • getMode

      public int getMode()
    • setMode

      public void setMode(int mode)
    • getOpacity

      public float getOpacity()
    • setOpacity

      public void setOpacity(float opacity)
      The opacity of a slice (0-1) in the alpha blending mode.
    • getThreshold

      public float getThreshold()
    • setThreshold

      public void setThreshold(float threshold)
      Voxels with an intensity (0-1) below or equal to the threshold are not displayed.
    • getSampling

      public float getSampling()
    • setSampling

      public void setSampling(float sampling)
      The number of slices relative to the number of voxels along the slice axis.
    • getZScale

      public float getZScale()
    • setZScale

      public void setZScale(float zScale)
      Scales the calibrated depth of the volume.
    • getMaxSize

      public int getMaxSize()
    • setMaxSize

      public void setMaxSize(int maxSize)
      The maximum texture size of a dimension. Larger stacks are reduced (applied when a stack is loaded).
    • isLutColors

      public boolean isLutColors()
    • setLutColors

      public void setLutColors(boolean lutColors)
      Use the colors of the LUT, else gray values (applied when a stack is loaded).