public class JRenderer3D extends Object
The next section describes the basic scheme for rendering 3D scenes. After initializing a new 3D scene, objects are added, drawing parameters and global render parameters have to be set. At the end a rendering is performed that is written to an image, which can be displayed with ImageJ.
// Setup 3D rendering JRenderer3D jRenderer3D; jRenderer3D = new JRenderer3D(xCenter, yCenter, zCenter); // size of the // rendered image // Set or add one or more 3D objects like points or spheres: jRenderer3D.addPoint3D(250, 250, 20, 20, Color.WHITE); // Or lines, texts, cubes: jRenderer3D.add3DCube(0, 0, 0, xSize, ySize, zSize, 0xFF000000); // Set one image for a surface plot jRenderer3D.setSurfacePlot(imp); // Or set a volume (a 3D-stack) jRenderer3D.setVolume(imagePlus); // set the volume // Set the drawing modes jRenderer3D.setPoints3DDrawMode(JRenderer3D.POINTS_SPHERES); jRenderer3D.setSurfacePlotLut(JRenderer3D.LUT_ORANGE); // select a LUT jRenderer3D.setSurfacePlotLight(0.5); // set lighting jRenderer3D.setSurfacePlotMode(JRenderer3D.SURFACEPLOT_MESH); // set plot // mode to mesh // Set global parameters jRenderer3D.setBackgroundColor(0xFF000050); // dark blue background jRenderer3D.setZAspect(4); // set the z-aspect ratio to 4 jRenderer3D.setTransformScale(1.5); // scale factor jRenderer3D.setTransformRotationXYZ(80, 0, 160); // rotation angles (in // degrees) // Render the image jRenderer3D.doRendering(); // Get the rendered new image Image image = jRenderer3D.getImage(); // And display it: ImagePlus impNew = new ImagePlus("Rendered Image", image); impNew.show(); impNew.updateAndDraw();
Surface plots can be generate from all image types. Selections, which can be non-rectangular, are supported.
The luminance of an image is interpreted as height for the plot. Internally the image is scaled to a 256x256 image using nearest neighbor sampling. Other dimensions for this image can be set by the setSurfacePlotGridSize method.
The surface plot has several drawing modes which av be set by setSurfacePlotMode:
Display Colors can be chosen from the original color, grayscale, different LUTs and orange.
Noisy images can be smoothed using the applySurfaceSmoothingFilter method. Setting lighting with the setSurfacePlotLight methode gives the impression that the plot was illuminated and so improves the visibility of small differences.
Stacks can be shown as volumes or slices. 8, 16 and 32 bit stacks are supported. RGB-stacks are not supported for the moment.
The display mode of a volume may be set with the setVolumeDrawMode method by using these constants:
The setVolumeCutDistance method sets the distance of the slice. For volume rendering only voxels further away than this distance are displayed. The z-aspect ratio of a volume is read automatically, but it can also be set using the setTransformZAspectRatio.
Different LUTs can be used for display by using the setVolumeLut method.
Before rendering a scene a geometrical transform is applied. Rotation angles for the x, y, and z-coordinate achses may be set by the setTransformRotation* methods. the global scale is set by the setTransformScale method. JRenderer3D assumes the following coordinate system:
The z-axis is pointing towards the viewer. The orientation of the z-axis may be changed with the method setTransformZOrientation. The entire scene is centered to the center coordinates that are passed with the constructor of JRenderer3D.
The 3D scene is rendered to an image buffer. The initial size of this buffer is 512x512 pixels: This size can be changed with the setBufferSize method.
Modifier and Type | Field and Description |
---|---|
static int |
LUT_BLACK
3D representations of objects are drawn in black.
|
static int |
LUT_BLUE
3D representations of objects are drawn in blue.
|
static int |
LUT_FIRE
3D representations of objects are drawn with fire colors.
|
static int |
LUT_GRADIENT
3D representations of objects are cored according to their gradient.
|
static int |
LUT_GRADIENT2 |
static int |
LUT_GRAY
3D representations of objects are drawn with grayscale colors.
|
static int |
LUT_ORANGE
3D representations of objects are drawn in orange.
|
static int |
LUT_ORIGINAL
3D represenations of objects are drawn with their original colors.
|
static int |
LUT_SPECTRUM
3D representations of objects are drawn with spectrum colors.
|
static int |
LUT_THERMAL
3D representations of objects are drawn with thermal colors.
|
static int |
POINT_CIRCLE
Draws a point as a (2D) circle.
|
static int |
POINT_DOT
Draws a point as a dot.
|
static int |
POINT_SPHERE
Draws a point as a sphere (slowest).
|
static int |
SURFACEPLOT_DOTS
Draws a surface plot using only dots, illumination is active.
|
static int |
SURFACEPLOT_DOTSNOLIGHT
Draws a surface plot using only dots, no illumination is used (fastest mode).
|
static int |
SURFACEPLOT_FILLED
Draws a filled surface plot .
|
static int |
SURFACEPLOT_ISOLINES
Draws a filled surface plot (Slowest mode).
|
static int |
SURFACEPLOT_LINES
Draws a surface plot using lines.
|
static int |
SURFACEPLOT_MESH
Draws a surface plot using a mesh.
|
static int |
VOLUME_DOTS
Draws a volume using only dots (fastest mode).
|
static int |
VOLUME_PROJECTION_TRILINEAR_FRONT
Draws a volume using trilinear interpolation projection from the front
|
static int |
VOLUME_SLICE_NEAREST_NEIGHBOR
Draws a volume using nearest neighbor interpolation.
|
static int |
VOLUME_SLICE_TRILINEAR
Draws a volume using trilinear interpolation.
|
Constructor and Description |
---|
JRenderer3D()
Creates a new JRenderer3D object.
|
JRenderer3D(double xCenter,
double yCenter,
double zCenter)
Creates a new JRenderer3D object.
|
Modifier and Type | Method and Description |
---|---|
void |
add3DCube(int xMin,
int yMin,
int zMin,
int xMax,
int yMax,
int zMax,
Color color)
Adds a cube (drawn with 12 lines) to the 3D scene.
|
void |
add3DCube(int xMin,
int yMin,
int zMin,
int xMax,
int yMax,
int zMax,
int rgb)
Adds a cube (drawn with 12 lines) to the 3D scene.
|
void |
addLine3D(int xStart,
int yStart,
int zStart,
int xEnd,
int yEnd,
int zEnd,
Color color)
Adds a single 3D line to the 3D scene.
|
void |
addLine3D(Line3D line3D)
Adds a single 3D line to the 3D scene.
|
void |
addLines3D(Line3D[] lines3D)
Adds an array of lines to the 3D scene.
|
void |
addPoint3D(int x,
int y,
int z,
int size,
Color color,
int drawMode)
Adds a point to the 3D scene.
|
void |
addPoint3D(int x,
int y,
int z,
int size,
int rgb,
int drawMode)
Adds a point to the 3D scene.
|
void |
addPoint3D(Point3D point3D)
Adds a single
Point3D to the 3D scene. |
void |
addPoints3D(Point3D[] points3D)
Adds an array with
Point3D to the 3D scene. |
void |
addText3D(String text,
int x,
int y,
int z,
Color color,
int size)
Adds a text to the 3D scene.
|
void |
addText3D(String text,
int x,
int y,
int z,
int rgb,
int size)
Adds a text to the 3D scene.
|
void |
addText3D(Text3D text3D)
Adds a single 3D text to the 3D scene.
|
void |
addText3D(Text3D[] text3D)
Adds an array of text to the 3D scene.
|
void |
addTextPair3D(Text3D text1_3D,
Text3D text2_3D) |
void |
applyTransformRotationXYZ(double changeX,
double changeY,
double changeZ)
Changes the rotation of x-, y-, and z-axis by the values of changeX and changeY.
|
void |
changeTransformRotationXYZ(double changeX,
double changeY,
double changeZ)
Changes the rotation of x-, y-, and z-axis by the values of changeX and changeY.
|
void |
changeTransformRotationXZ(double changeX,
double changeZ)
Changes the rotation of x- and z-axis by the values of changeX and changeY.
|
void |
clearCubes() |
void |
clearLines() |
void |
clearText() |
void |
doRendering()
This methods does the rendering and creates the 3D output.
|
int |
getHeight()
Returns the buffer height of the image.
|
Image |
getImage()
Returns actual rendered image.
|
Color |
getLegendTextColor() |
int |
getNumPoints3D() |
int |
getSurfacePlotMode() |
double |
getTransformRotationX() |
double |
getTransformRotationY() |
double |
getTransformRotationZ() |
double |
getTransformScale() |
double |
getTransformZAspectRatio()
Gets the z-aspect ratio (the relative z-height of a voxel).
|
int |
getWidth()
Returns the buffer width of the image.
|
void |
removeLastLine3D() |
void |
removeLastPoint3D() |
void |
setAxes(boolean axes) |
void |
setBackgroundColor(Color color)
Sets the background color of the rendered 3D presentation
|
void |
setBackgroundColor(int rgb)
Sets the background color of the rendered 3D presenation
|
void |
setBufferSize(int width,
int height)
Sets the buffer size.
|
void |
setLegend(boolean legend) |
void |
setLegendTextColor(Color legendTextColor) |
void |
setLines(boolean lines) |
void |
setMaxZValue(double maxZ) |
void |
setMinZValue(double minZ) |
void |
setSurfacePlot(ij.ImagePlus imp)
Creates the surface plot.
|
void |
setSurfacePlotGridSize(int width,
int height)
Sets the surface grid size (sampling rate).
|
void |
setSurfacePlotLight(double surfacePlot_light)
Sets the lightning for the surface plot illumination .
|
void |
setSurfacePlotLut(int surfacePlot_lutNr)
Sets the color lut for the surface plot.
|
void |
setSurfacePlotMask(ij.ImagePlus impMask) |
void |
setSurfacePlotMinMax(int surfacePlot_min,
int surfacePlot_max) |
void |
setSurfacePlotMode(int surfacePlot_plotMode)
Sets the surface plot mode.
|
void |
setSurfacePlotTexture(ij.ImagePlus impTexture) |
void |
setSurfacePlotWithTexture(ij.ImagePlus imp,
ij.ImagePlus impTexture)
Creates the surface plot with texture.
|
void |
setSurfaceSmoothingFactor(double smoothRadius)
Aplies a smoothing to the surface plot data
|
void |
setText(boolean text) |
void |
setTransformMaxDistance(double maxDistance) |
void |
setTransformPerspective(double perspective) |
void |
setTransformRotationX(double ax)
Sets the rotation on the x-axis.
|
void |
setTransformRotationXYZ(double ax,
double ay,
double az)
Sets the rotation on x-, y- and z-axis.
|
void |
setTransformRotationXZ(double ax,
double az)
Sets the rotation on both x- and z-axis.
|
void |
setTransformRotationY(double ay)
Sets the rotation on the y-axis.
|
void |
setTransformRotationZ(double az)
Sets the rotation on the z-axis.
|
void |
setTransformScale(double scale)
Sets scale of the redered 3D scene.
|
void |
setTransformZAspectRatio(double zAspectRatio)
Sets the z-aspect ratio (the relative z-height of a voxel).
|
void |
setTransformZOrientation(int zOrientation)
Chooses the coordinate system.
|
void |
setVolume(ij.ImagePlus imagePlus)
Sets a volume stack.
|
void |
setVolumeCutDistance(int volume_cutDist)
Sets the view distance.
|
void |
setVolumeDotsSubsampling(int volume_dotsDeltaX,
int volume_dotsDeltaY,
int volume_dotsDeltaZ)
Set subsampling factors (used by the drawing mode volume dots).
|
void |
setVolumeDrawMode(int volume_drawMode)
Sets the mode for drawing volumes.
|
void |
setVolumeLut(int volume_lutNr) |
void |
setVolumeThreshold(int threshold)
Sets the threshold.
|
void |
showRotation() |
void |
surfacePlotSetInverse(boolean b) |
public static final int POINT_SPHERE
public static final int POINT_CIRCLE
public static final int POINT_DOT
public static final int SURFACEPLOT_DOTSNOLIGHT
public static final int SURFACEPLOT_DOTS
public static final int SURFACEPLOT_LINES
public static final int SURFACEPLOT_MESH
public static final int SURFACEPLOT_FILLED
public static final int SURFACEPLOT_ISOLINES
public static final int VOLUME_DOTS
public static final int VOLUME_SLICE_NEAREST_NEIGHBOR
public static final int VOLUME_SLICE_TRILINEAR
public static final int VOLUME_PROJECTION_TRILINEAR_FRONT
public static final int LUT_ORIGINAL
public static final int LUT_GRAY
public static final int LUT_SPECTRUM
public static final int LUT_FIRE
public static final int LUT_THERMAL
public static final int LUT_ORANGE
public static final int LUT_BLUE
public static final int LUT_BLACK
public static final int LUT_GRADIENT
public static final int LUT_GRADIENT2
public JRenderer3D()
public JRenderer3D(double xCenter, double yCenter, double zCenter)
This has always to be the first step to generate a 3D scene.
xCenter
- The x-coordinate of the rotation / plot center.yCenter
- The y-coordinate of the rotation / plot center.zCenter
- The z-coordinate of the rotation / plot center.public void showRotation()
public Color getLegendTextColor()
public void setLegendTextColor(Color legendTextColor)
public void doRendering()
public void addPoints3D(Point3D[] points3D)
Point3D
to the 3D scene.points3D
- array with points in a threedimensional coordinate systempublic void addPoint3D(Point3D point3D)
Point3D
to the 3D scene.point3D
- the 3D point to addpublic void addPoint3D(int x, int y, int z, int size, Color color, int drawMode)
x
- y
- z
- size
- color
- drawMode
- public void addPoint3D(int x, int y, int z, int size, int rgb, int drawMode)
x
- y
- z
- size
- rgb
- drawMode
- public void setSurfacePlotMask(ij.ImagePlus impMask)
public void setSurfacePlot(ij.ImagePlus imp)
imp
- The images to be drawn in 3D.public void setSurfacePlotTexture(ij.ImagePlus impTexture)
public void setSurfacePlotWithTexture(ij.ImagePlus imp, ij.ImagePlus impTexture)
imp
- The images to be drawn in 3D.impTexture
- The image which shall be used as texturepublic void setSurfacePlotMode(int surfacePlot_plotMode)
Available options:
surfacePlot_plotMode
- the surface plot modepublic int getSurfacePlotMode()
public void setVolumeDrawMode(int volume_drawMode)
volume_drawMode
- public void setVolumeLut(int volume_lutNr)
public void setVolumeDotsSubsampling(int volume_dotsDeltaX, int volume_dotsDeltaY, int volume_dotsDeltaZ)
volume_dotsDeltaX
- subsampling factor in x directionvolume_dotsDeltaY
- subsampling factor in y directionvolume_dotsDeltaZ
- subsampling factor in z directionpublic void setVolumeCutDistance(int volume_cutDist)
volume_cutDist
- the cut distancepublic void setSurfacePlotGridSize(int width, int height)
width
- the width of surface gridheight
- the height of surface gridpublic void setTransformZOrientation(int zOrientation)
zOrientation
- public void setTransformScale(double scale)
scale
- scales the scenepublic void setTransformRotationX(double ax)
ax
- angle in degreepublic void setTransformRotationY(double ay)
ay
- angle in degreepublic void setTransformRotationZ(double az)
az
- angle in degreepublic void setTransformRotationXZ(double ax, double az)
ax
- angle of x-axis in degreeaz
- angle of z-axis in degreepublic void setTransformRotationXYZ(double ax, double ay, double az)
ax
- rotation angle of x-axis in degreeay
- rotation angle of y-axis in degreeaz
- rotation angle of z-axis in degreepublic void changeTransformRotationXZ(double changeX, double changeZ)
changeX
- change of rotation angle of x-axis in degreechangeZ
- change of rotation angle of z-axis in degreepublic void applyTransformRotationXYZ(double changeX, double changeY, double changeZ)
changeX
- change of rotation angle of x-axis in degreechangeY
- change of rotation angle of y-axis in degreechangeZ
- change of rotation angle of z-axis in degreepublic void changeTransformRotationXYZ(double changeX, double changeY, double changeZ)
changeX
- change of rotation angle of x-axis in degreechangeY
- change of rotation angle of y-axis in degreechangeZ
- change of rotation angle of z-axis in degreepublic void setBackgroundColor(int rgb)
rgb
- the background color (argb int)public void setBackgroundColor(Color color)
color
- Colorpublic void addLines3D(Line3D[] lines3D)
lines3D
- array of 3d linespublic void addLine3D(Line3D line3D)
line3D
- the 3D line to addpublic void addLine3D(int xStart, int yStart, int zStart, int xEnd, int yEnd, int zEnd, Color color)
xStart
- yStart
- zStart
- xEnd
- yEnd
- zEnd
- color
- public void clearLines()
public void addText3D(Text3D[] text3D)
text3D
- public void addText3D(String text, int x, int y, int z, Color color, int size)
text
- x
- the x position of the texty
- the y positionz
- the z positioncolor
- the text colorsize
- the font sizepublic void addText3D(String text, int x, int y, int z, int rgb, int size)
text
- x
- the x position of the texty
- the y positionz
- the z positionrgb
- the text colorsize
- the font sizepublic void addText3D(Text3D text3D)
text3D
- the 3D text to addpublic void clearText()
public void setBufferSize(int width, int height)
width
- The width to be set.height
- The height to be set.public void add3DCube(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, Color color)
xMin
- minimum value xyMin
- minimum value yzMin
- minimum value zxMax
- maximum value xyMax
- maximum value yzMax
- maximum value zcolor
- Color of cube lines (argb)public void add3DCube(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, int rgb)
xMin
- minimum value xyMin
- minimum value yzMin
- minimum value zxMax
- maximum value xyMax
- maximum value yzMax
- maximum value zrgb
- Color of cube lines (argb)public void clearCubes()
public void setVolume(ij.ImagePlus imagePlus)
imagePlus
- the volume stack to be setpublic void setSurfacePlotLut(int surfacePlot_lutNr)
surfacePlot_lutNr
- color of look-up-tablepublic void setSurfacePlotLight(double surfacePlot_light)
surfacePlot_light
- intensity value between 0 and 1 (default is 0)public void setSurfacePlotMinMax(int surfacePlot_min, int surfacePlot_max)
public void setSurfaceSmoothingFactor(double smoothRadius)
smoothRadius
- the radius of the smoothing kernelpublic void setVolumeThreshold(int threshold)
threshold
- Threshold to be set (0 .. 255).public void setTransformZAspectRatio(double zAspectRatio)
zAspectRatio
- z-aspect ratio (the relative z-ratio of a voxel) to be set.public int getWidth()
public int getHeight()
public Image getImage()
public double getTransformZAspectRatio()
public void removeLastPoint3D()
public void removeLastLine3D()
public int getNumPoints3D()
public void setTransformPerspective(double perspective)
public void setTransformMaxDistance(double maxDistance)
public void setAxes(boolean axes)
public void setLines(boolean lines)
public void setText(boolean text)
public void setLegend(boolean legend)
public void surfacePlotSetInverse(boolean b)
public double getTransformScale()
public void setMinZValue(double minZ)
public void setMaxZValue(double maxZ)
public double getTransformRotationX()
public double getTransformRotationY()
public double getTransformRotationZ()
Copyright © 2015–2021 Fiji. All rights reserved.