Class VolumeRenderer
java.lang.Object
com.eco.bio7.spatial.VolumeRenderer
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
FieldsModifier and TypeFieldDescriptionstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes the volume.voidMust 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.floatgetDepth()Returns the depth of the volume (slices multiplied with the calibrated voxel depth and the z scale).floatint[]Returns the histogram of the intensities (256 bins, the display range of the stack) or null if no stack is loaded.ij.ImagePlusgetImage()Returns the loaded ImageJ image or null.getInfo()Returns a description of the loaded stack.intintgetMode()floatfloatgetOpacityAt(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.floatReturns the selection of the values (see setSelection).floatcom.eco.bio7.spatial.TransferFunctiondoubleThe data value of the position 1 of the transfer function.doubleThe data value of the position 0 of the transfer function.floatgetWidth()floatbooleanReturns true if a volume is loaded and displayed.booleanisLoaded()Returns true if a stack is loaded (displayed or not).booleanbooleanisShow()booleanload(ij.ImagePlus imp) Loads a stack (the current channel and frame of a hyperstack) as a volume.booleanreload()Loads the last loaded stack again (e.g., after a LUT change).voidrender(com.jogamp.opengl.GL2 gl, boolean cartesian) Renders the volume (Cartesian: centered at the origin, octant: from the origin).voidrenderSlice(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).voidsetClipping(Clipping clipping) Sets the clipping with the mask of the removed voxels (see Clipping.cutRoi and Clipping.setMask).voidsetLutColors(boolean lutColors) Use the colors of the LUT, else gray values (applied when a stack is loaded).voidsetMaxSize(int maxSize) The maximum texture size of a dimension.voidsetMode(int mode) voidsetOpacity(float opacity) The opacity of a slice (0-1) in the alpha blending mode.voidsetSampling(float sampling) The number of slices relative to the number of voxels along the slice axis.voidsetSelection(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).voidsetShow(boolean show) voidsetThreshold(float threshold) Voxels with an intensity (0-1) below or equal to the threshold are not displayed.voidsetTransferFunction(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).voidsetZScale(float zScale) Scales the calibrated depth of the volume.
-
Field Details
-
MODE_ALPHA_BLENDING
public static final int MODE_ALPHA_BLENDING- See Also:
-
MODE_MAXIMUM_INTENSITY
public static final int MODE_MAXIMUM_INTENSITY- See Also:
-
-
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
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
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
Returns the selection of the values (see setSelection). -
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
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 contextcartesian- true for the Cartesian mode
-
renderSlice
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 contextcartesian- true for the Cartesian modepolygon- the corners of the polygon (scene coordinates)
-
isLoaded
public boolean isLoaded()Returns true if a stack is loaded (displayed or not). -
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).
-