Class VolumeImage
- java.lang.Object
-
- gov.nih.mipav.view.renderer.WildMagic.Render.VolumeImage
-
- All Implemented Interfaces:
java.io.Serializable
public class VolumeImage extends java.lang.Object implements java.io.Serializable
The VolumeImage class provides an interface between the MIPAV ModelImage and the 2D and 3D Textures used to render the ModelImage on the GPU. The VolumeImage creates the supporting Texture and GraphicImage objects that pass the ModelImage data to the GPU. It also creates Texture and GraphicsImage objects for the ModelImage Look-up Table (LUT) and the ModelImage opacity transfer function. Other textures that are used for advanced volume rendering, such as a normal map for surface rendering, and the gradient-magnitude and laplace images for the multi-histogram rendering are calculated and passed on-demand to the GPU when the user selects these options in the Volume-Renderer user-interface. The VolumeImage data structure handles all GPU content for rendering one ModelImage. All Textures and GraphicsImages are initialized and stored in the VolumeImage. When needed by the renderer they are loaded onto the GPU. Any images that are derived from the ModelImage: Normal map, Gradient Magnitude, Laplace, are either read from file or calculated and then written to file. The supporting files are stored in a directory on disk located next to the original ModelImage. The directory is named with the ModelImage name followed by "_RenderFiles".- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private WildMagic.LibFoundation.Mathematics.Vector2f[]
m_akGradientMagMinMax
3D sub-images (4D data)private WildMagic.LibFoundation.Mathematics.Vector2f[]
m_akHistoTCoord
Texture coordinates for displaying histogram in 2Dprivate boolean
m_bGMInit
Set to true if the Gradient Magnitude texture map has been initialized.private boolean
m_bHistoInit
Set to true when the multi-histogram histogram texture has been initialized.private boolean
m_bNormalsInit
Set to true if the Normal Map has been initialized.private float
m_fDRRNormalize
private float
m_fMax
Image scale factors for display in 3Dprivate float
m_fX
Image scale factors for display in 3Dprivate float
m_fY
Image scale factors for display in 3Dprivate float
m_fZ
Image scale factors for display in 3Dprivate int
m_iMaxExtent
private int
m_iTimeSlice
Current position in time (4D data)private int
m_iTimeSteps
Total number of time-slices (4D data)private WildMagic.LibGraphics.Rendering.GraphicsImage
m_kColorMap
Data storage for color map:private WildMagic.LibGraphics.Rendering.Texture
m_kColorMapTarget
Texture object for color map:private java.lang.String
m_kDir
Directory for calculated imagesprivate WildMagic.LibGraphics.Rendering.GraphicsImage[]
m_kHisto
Histogram data for multi-histogram interfaceprivate WildMagic.LibGraphics.Rendering.Texture
m_kHistoTarget
Texture object for data:private ModelImage
m_kImage
Reference to ModelImage imageprivate ModelImage
m_kImageGM
private ModelLUT
m_kLUT
ModelLUTprivate WildMagic.LibGraphics.Rendering.GraphicsImage[]
m_kNormal
Data storage for normals:private WildMagic.LibGraphics.Rendering.Texture
m_kNormalMapTarget
Texture object for normal map:private WildMagic.LibGraphics.Rendering.GraphicsImage
m_kOpacityMap_GM
GraphicsImage contains GM opacity transfer function data:private WildMagic.LibGraphics.Rendering.Texture
m_kOpacityMapTarget_GM
Texture contains texture filter modes and GraphicsImage for opacity transfer function:private java.lang.String
m_kPostfix
Image name post-fix typically either 'A' or 'B'private ModelRGB
m_kRGBT
ModelRGBprivate WildMagic.LibGraphics.Rendering.Texture
m_kScratchTarget
Texture object for GPU computations:private WildMagic.LibGraphics.Rendering.GraphicsImage
m_kSurfaceImage
Data storage for surfaces:private WildMagic.LibGraphics.Rendering.Texture
m_kSurfaceTarget
Texture object for surfaces:private WildMagic.LibGraphics.Rendering.GraphicsImage[]
m_kVolume
Data storage for volume:private WildMagic.LibGraphics.Rendering.GraphicsImage[]
m_kVolumeGM
Data storage for volume gradient magnitude:private WildMagic.LibGraphics.Rendering.Texture
m_kVolumeGMTarget
Texture object for volume gradient magnitude data:private WildMagic.LibGraphics.Rendering.Texture
m_kVolumeTarget
Texture object for data:private TransferFunction
opacityTransferFn
private static long
serialVersionUID
protected java.util.Vector<WildMagic.LibFoundation.Mathematics.ColorRGB>
surfaceColor
A vector of BitSet masks, one for each surface loaded into the viewer.protected java.util.Vector<java.util.BitSet>
surfaceMask
A vector of BitSet masks, one for each surface loaded into the viewer.protected java.util.Vector<java.lang.String>
surfaceNames
A vector of the mask names, so they can be accessed by name:
-
Constructor Summary
Constructors Constructor Description VolumeImage()
VolumeImage(boolean bClone, ModelImage kImage, java.lang.String kPostfix, ViewJProgressBar kProgress, int iProgress)
Create a Volume image with the input ModelImage.VolumeImage(boolean bClone, ModelImage kImage, java.lang.String kPostfix, ViewJProgressBar kProgress, int iProgress, boolean initGradientMagnitude)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addNormals(ModelImage kImage, int iTimeSlice)
static boolean
checkImage(ModelImage kImage1, ModelImage kImage2)
Checks that the two input images match extents, units of measure and resolutions.protected float
computeIntegralNormalizationFactor()
In order to map line integrals of image intensity to RGB colors where each color channel is 8 bits, it is necessary to make sure that the integrals are in [0,255].void
CopyNormalFiles(int i, ModelImage kImage)
When the ModelImage data is rendered as a solid surface, the Normal map is used in the rendering.private WildMagic.LibGraphics.Rendering.GraphicsImage
createGM_Laplace(ModelImage kImageGM, ModelImage kImageL, WildMagic.LibGraphics.Rendering.GraphicsImage kVolumeImage, int iTimeSlice, boolean bSwap)
static ModelImage
CreateImageFromTexture(WildMagic.LibGraphics.Rendering.GraphicsImage kImage)
Read the current Volume Texture from the GPU and return a new ModelImage of that data.static ModelImage
CreateImageFromTexture(WildMagic.LibGraphics.Rendering.GraphicsImage kImage, boolean bSwap)
Copy the data from the input GraphicsImage and return a new ModelImage of that data.void
dispose()
Memory cleanup.private void
GenerateHistogram(WildMagic.LibGraphics.Rendering.GraphicsImage[] kImage, WildMagic.LibGraphics.Rendering.GraphicsImage[] kImageGM, java.lang.String kPostFix, int start, int end)
Generate 2D histogram from the input image and the gradient-magnitudevoid
GenerateNormalFiles(VolumeTriPlanarInterface parentFrame)
This function is called when the user selects the Surface or Composite Surface volume rendering option.WildMagic.LibGraphics.Rendering.Texture
GetColorMapTarget()
Return the Color Map Texture.float
getDRRNorm()
Return the normalization factor for DDR rendering mode.static ModelImage
getGradientMagnitude(ModelImage kImage, int i)
Calculates and stores the gradient magnitude images (3D or 4D) for the input image.ModelImage
GetGradientMagnitudeImage()
float
GetGradientMagnitudeMax()
float
GetGradientMagnitudeMin()
WildMagic.LibFoundation.Mathematics.Vector2f
GetGradientMagnitudeMinMax()
WildMagic.LibGraphics.Rendering.Texture
GetGradientMapTarget()
Return the Gradient Magnitude Texture.WildMagic.LibGraphics.Rendering.Texture
GetHistoTarget()
Returns the multi-histogram histogram Texture.WildMagic.LibFoundation.Mathematics.Vector2f[]
GetHistoTCoords()
Return the texture coordinates for the multi-histogram histogram texture.ModelImage
GetImage()
Return the ModelImage volume data.ModelStorageBase
getLUT()
Return the Volume RGBT.ModelLUT
GetLUT()
Return the ModelImage LUT.int
GetMaxExtent()
WildMagic.LibGraphics.Rendering.Texture
GetNormalMapTarget()
Return the Normal map Texture.TransferFunction
getOpacityFn()
WildMagic.LibGraphics.Rendering.Texture
GetOpacityMapGMTarget()
Return the gradient magnitude opacity transfer function Texture.java.lang.String
GetPostfix()
Return the postfix for this VolumeImage.ModelRGB
GetRGB()
Return the Volume RGBT.float
GetScaleMax()
The ModelImage Volume max-scale factor.float
GetScaleX()
The ModelImage Volume x-scale factor.float
GetScaleY()
The ModelImage Volume y-scale factor.float
GetScaleZ()
The ModelImage Volume z-scale factor.WildMagic.LibGraphics.Rendering.Texture
GetScratchTarget()
WildMagic.LibGraphics.Rendering.Texture
GetSurfaceTarget()
Return the surface mask Texture.int
GetTimeSlice()
Returns the current rendered time-slice for 4D images.float
GetTransferedValue(int x, int y, int z)
WildMagic.LibGraphics.Rendering.Texture
GetVolumeTarget()
Return the Texture containing the volume data.java.nio.Buffer
GetVolumeTargetBuffer()
Return the Buffer containing the volume data, which is stored in the Texture GrapicsImage.private void
init(ViewJProgressBar kProgress, int iProgress, boolean initGradientMagnitude)
Initialize the VolumeImage with the ModelImage data.private WildMagic.LibGraphics.Rendering.GraphicsImage
initColorMap()
static WildMagic.LibGraphics.Rendering.GraphicsImage
InitColorMap(WildMagic.LibGraphics.Rendering.Texture kTexture, WildMagic.LibGraphics.Rendering.GraphicsImage kImage, ModelStorageBase kLUT, java.lang.String kPostFix)
Initialize the textures for the color lookup table.private void
initImages()
Intializes the Textures and GraphicsImages used to render the ModelImage this VolumeImage represents.private void
initImagesColor()
private void
initLUT()
Create a new LUT for the input image.WildMagic.LibGraphics.Rendering.GraphicsImage
InitOpacityMap(ModelImage kImage, java.lang.String kPostFix)
Initialize the GraphicsImage for the opacity lookup table.private void
InitScale()
Initialize the scale factors.private WildMagic.LibGraphics.Rendering.GraphicsImage
initVolumeData(ModelImage kImage, int iTimeSlice, WildMagic.LibGraphics.Rendering.Texture kVolumeTexture, java.lang.String kImageName, boolean bSwap, boolean bRescale)
boolean
IsColorImage()
Return true if the Volume image is a color image.boolean
isHistoInit()
Returns true if the multi-histogram histogram texture has been initialized, false otherwise.private static ModelImage
ReadFromDisk(java.lang.String kImageName, java.lang.String kDir)
Reads an image from disk.private void
readObject(java.io.ObjectInputStream in)
void
ReleaseVolume()
Release the Textures containing the volume data.void
removeSurfaceMask(java.lang.String name)
Delete the surface mask, using the name of the mask as reference.private WildMagic.LibGraphics.Rendering.GraphicsImage
resetVolumeData(ModelImage kImage, int iTimeSlice, WildMagic.LibGraphics.Rendering.GraphicsImage kGraphicsImage, WildMagic.LibGraphics.Rendering.Texture kVolumeTexture, java.lang.String kImageName, boolean bSwap, boolean bRescale)
void
SetGradientMagnitude(ModelImage kGradientMagnitude, boolean bComputeLaplace, java.lang.String kPostfix)
Called when the user selects the Gradient Magnitude option or the Multi-Histogram option in the Volume Renderer.void
SetRGBT(ModelRGB kRGBT)
Sets the ModelRGB for the iImage.void
setSurfaceMask(java.lang.String name, WildMagic.LibFoundation.Mathematics.ColorRGB color, java.util.BitSet mask)
Add a new surface mask.void
setSurfaceMaskColor(java.lang.String name, WildMagic.LibFoundation.Mathematics.ColorRGB color)
Delete the surface mask, using the name of the mask as reference.void
SetTimeSlice(int iSlice)
Sets the time slices for 4D data.private float
TransferValue(float value)
private void
update4D()
Go to the next 3D volume sub-image for the 4D animation.void
update4D(boolean bForward)
Updates the current time slice.void
UpdateData(ModelImage kImage, boolean reload)
Update the image data.static WildMagic.LibGraphics.Rendering.GraphicsImage
UpdateData(ModelImage kImage, int iTimeSlice, ModelImage kNewImage, WildMagic.LibGraphics.Rendering.GraphicsImage kVolumeImage, WildMagic.LibGraphics.Rendering.Texture kVolumeTexture, java.lang.String kImageName, boolean bSwap, boolean bRescale)
When a ModelImage changes on the CPU, this function is used to update the ModelImage data on the CPU.void
UpdateData(ModelImage kImage, ModelLUT kLUT, boolean reload)
Changes the underlying image data and LUT.static WildMagic.LibGraphics.Rendering.GraphicsImage
UpdateData(ModelSimpleImage kImage, java.lang.String kImageName)
Creates a new GraphicsImage for the input ModelSimpleImage.private boolean
UpdateImages(ModelImage kImage, WildMagic.LibGraphics.Rendering.Texture kOpacityTexture, WildMagic.LibGraphics.Rendering.GraphicsImage kOpacityMap, TransferFunction kTransfer)
Called when the opacity transfer function changes.void
UpdateImages(ModelLUT kLUT)
Update the LUT for the ModelImage.void
UpdateImages(ModelStorageBase kLUT)
Update the LUT for the ModelImage.boolean
UpdateImages(TransferFunction kTransfer, int iImage, ModelImage kImage)
Update the transfer function for the image iImage.static void
UpdateImages(WildMagic.LibGraphics.Rendering.Texture kColorTexture, WildMagic.LibGraphics.Rendering.GraphicsImage kColorMap, ModelLUT kLUT)
When the LUT changes, this function updates the LUT data on the GPU.private boolean
UpdateImages2(ModelImage kImage, WildMagic.LibGraphics.Rendering.Texture kOpacityTexture, WildMagic.LibGraphics.Rendering.GraphicsImage kOpacityMap, TransferFunction kTransfer)
Update the opacity transfer function.private void
updateMask()
private void
writeObject(java.io.ObjectOutputStream out)
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
m_kImage
private ModelImage m_kImage
Reference to ModelImage image
-
m_kImageGM
private ModelImage m_kImageGM
-
m_kOpacityMap_GM
private WildMagic.LibGraphics.Rendering.GraphicsImage m_kOpacityMap_GM
GraphicsImage contains GM opacity transfer function data:
-
m_kOpacityMapTarget_GM
private WildMagic.LibGraphics.Rendering.Texture m_kOpacityMapTarget_GM
Texture contains texture filter modes and GraphicsImage for opacity transfer function:
-
m_kVolume
private WildMagic.LibGraphics.Rendering.GraphicsImage[] m_kVolume
Data storage for volume:
-
m_kVolumeTarget
private WildMagic.LibGraphics.Rendering.Texture m_kVolumeTarget
Texture object for data:
-
m_kNormal
private WildMagic.LibGraphics.Rendering.GraphicsImage[] m_kNormal
Data storage for normals:
-
m_bNormalsInit
private boolean m_bNormalsInit
Set to true if the Normal Map has been initialized.
-
m_kNormalMapTarget
private WildMagic.LibGraphics.Rendering.Texture m_kNormalMapTarget
Texture object for normal map:
-
m_kScratchTarget
private WildMagic.LibGraphics.Rendering.Texture m_kScratchTarget
Texture object for GPU computations:
-
m_kColorMap
private WildMagic.LibGraphics.Rendering.GraphicsImage m_kColorMap
Data storage for color map:
-
m_kColorMapTarget
private WildMagic.LibGraphics.Rendering.Texture m_kColorMapTarget
Texture object for color map:
-
m_kVolumeGM
private WildMagic.LibGraphics.Rendering.GraphicsImage[] m_kVolumeGM
Data storage for volume gradient magnitude:
-
m_bGMInit
private boolean m_bGMInit
Set to true if the Gradient Magnitude texture map has been initialized.
-
m_kVolumeGMTarget
private WildMagic.LibGraphics.Rendering.Texture m_kVolumeGMTarget
Texture object for volume gradient magnitude data:
-
m_kSurfaceImage
private WildMagic.LibGraphics.Rendering.GraphicsImage m_kSurfaceImage
Data storage for surfaces:
-
m_kSurfaceTarget
private WildMagic.LibGraphics.Rendering.Texture m_kSurfaceTarget
Texture object for surfaces:
-
m_kLUT
private ModelLUT m_kLUT
ModelLUT
-
m_kRGBT
private ModelRGB m_kRGBT
ModelRGB
-
m_fX
private float m_fX
Image scale factors for display in 3D
-
m_fY
private float m_fY
Image scale factors for display in 3D
-
m_fZ
private float m_fZ
Image scale factors for display in 3D
-
m_fMax
private float m_fMax
Image scale factors for display in 3D
-
m_iMaxExtent
private int m_iMaxExtent
-
m_kPostfix
private java.lang.String m_kPostfix
Image name post-fix typically either 'A' or 'B'
-
m_kDir
private java.lang.String m_kDir
Directory for calculated images
-
m_kHisto
private WildMagic.LibGraphics.Rendering.GraphicsImage[] m_kHisto
Histogram data for multi-histogram interface
-
m_bHistoInit
private boolean m_bHistoInit
Set to true when the multi-histogram histogram texture has been initialized.
-
m_kHistoTarget
private WildMagic.LibGraphics.Rendering.Texture m_kHistoTarget
Texture object for data:
-
m_akHistoTCoord
private WildMagic.LibFoundation.Mathematics.Vector2f[] m_akHistoTCoord
Texture coordinates for displaying histogram in 2D
-
m_fDRRNormalize
private float m_fDRRNormalize
-
m_iTimeSlice
private int m_iTimeSlice
Current position in time (4D data)
-
m_iTimeSteps
private int m_iTimeSteps
Total number of time-slices (4D data)
-
m_akGradientMagMinMax
private WildMagic.LibFoundation.Mathematics.Vector2f[] m_akGradientMagMinMax
3D sub-images (4D data)
-
opacityTransferFn
private TransferFunction opacityTransferFn
-
surfaceMask
protected java.util.Vector<java.util.BitSet> surfaceMask
A vector of BitSet masks, one for each surface loaded into the viewer.
-
surfaceNames
protected java.util.Vector<java.lang.String> surfaceNames
A vector of the mask names, so they can be accessed by name:
-
surfaceColor
protected java.util.Vector<WildMagic.LibFoundation.Mathematics.ColorRGB> surfaceColor
A vector of BitSet masks, one for each surface loaded into the viewer.
-
-
Constructor Detail
-
VolumeImage
public VolumeImage()
-
VolumeImage
public VolumeImage(boolean bClone, ModelImage kImage, java.lang.String kPostfix, ViewJProgressBar kProgress, int iProgress)
Create a Volume image with the input ModelImage. The supporting images for advanced volume rendering, such as the normal map, gradient magnitude and laplace images are generated on-demand and stored in a directory for later use. The directory is created if it does not already exist, with the ModelImage name + "_RenderFiles" as the directory name.- Parameters:
bClone
- , when true clone the input ModelImage, when false reference the ModelImagekImage
- input ModelImagekPostfix
- Postfix for images 'A' or 'B'kProgress
- progress bariProgress
- progress bar increment
-
VolumeImage
public VolumeImage(boolean bClone, ModelImage kImage, java.lang.String kPostfix, ViewJProgressBar kProgress, int iProgress, boolean initGradientMagnitude)
-
-
Method Detail
-
CreateImageFromTexture
public static ModelImage CreateImageFromTexture(WildMagic.LibGraphics.Rendering.GraphicsImage kImage, boolean bSwap)
Copy the data from the input GraphicsImage and return a new ModelImage of that data. Any changes to the GraphicsImage that occur only on the GPU can first be written from the GPU back into the GraphicsImage CPU data storage. This enables calculations that are performed on the GPU to be written back into a ModelImage data structure.- Parameters:
kImage
- Graphics Image to copybSwap
- when true convert from RGBA (graphics format) to ARGB (ModelImage format)- Returns:
- new ModelImage from Volume Texture on GPU.
-
InitColorMap
public static WildMagic.LibGraphics.Rendering.GraphicsImage InitColorMap(WildMagic.LibGraphics.Rendering.Texture kTexture, WildMagic.LibGraphics.Rendering.GraphicsImage kImage, ModelStorageBase kLUT, java.lang.String kPostFix)
Initialize the textures for the color lookup table.- Parameters:
kLUT
- the new LUT.kRGBT
- the new RGB table.kPostfix
- the string postfix to concatenate to the "ColorMap" image name.- Returns:
- GraphicsImage, the new GraphicsImage storing the colormap lookup table.
-
initColorMap
private WildMagic.LibGraphics.Rendering.GraphicsImage initColorMap()
-
UpdateData
public static WildMagic.LibGraphics.Rendering.GraphicsImage UpdateData(ModelImage kImage, int iTimeSlice, ModelImage kNewImage, WildMagic.LibGraphics.Rendering.GraphicsImage kVolumeImage, WildMagic.LibGraphics.Rendering.Texture kVolumeTexture, java.lang.String kImageName, boolean bSwap, boolean bRescale)
When a ModelImage changes on the CPU, this function is used to update the ModelImage data on the CPU.- Parameters:
kImage
- Modified ModelImage to copy into the GPU Texture and GraphicsImageiTimeSlice
- time value for 4D image, 0 otherwisekNewImage
- a new ModelImage (always 3D) that the data or data subset for 4D image can be copied into (when non-null).kVolumeImage
- GraphicsImage that will hold the ModelImage datakVolumeTexture
- Texture object containing the GraphicsImagekImageName
- new image name for the new ModelImage.bSwap
- when true swap the ARGB (ModelImage) color data representation to a RGBA (GPU) color representation.- Returns:
-
initVolumeData
private WildMagic.LibGraphics.Rendering.GraphicsImage initVolumeData(ModelImage kImage, int iTimeSlice, WildMagic.LibGraphics.Rendering.Texture kVolumeTexture, java.lang.String kImageName, boolean bSwap, boolean bRescale)
-
resetVolumeData
private WildMagic.LibGraphics.Rendering.GraphicsImage resetVolumeData(ModelImage kImage, int iTimeSlice, WildMagic.LibGraphics.Rendering.GraphicsImage kGraphicsImage, WildMagic.LibGraphics.Rendering.Texture kVolumeTexture, java.lang.String kImageName, boolean bSwap, boolean bRescale)
-
addNormals
private void addNormals(ModelImage kImage, int iTimeSlice)
-
createGM_Laplace
private WildMagic.LibGraphics.Rendering.GraphicsImage createGM_Laplace(ModelImage kImageGM, ModelImage kImageL, WildMagic.LibGraphics.Rendering.GraphicsImage kVolumeImage, int iTimeSlice, boolean bSwap)
-
UpdateData
public static WildMagic.LibGraphics.Rendering.GraphicsImage UpdateData(ModelSimpleImage kImage, java.lang.String kImageName)
Creates a new GraphicsImage for the input ModelSimpleImage. The ModelSimpleImage data is referenced by the new GraphicsImage and will be passed to the GPU as a texture.- Parameters:
kImage
- input ModelSimpleImage.kImageName
- name for the GraphicsImage.- Returns:
- a new GraphcisImage.
-
UpdateImages
public static void UpdateImages(WildMagic.LibGraphics.Rendering.Texture kColorTexture, WildMagic.LibGraphics.Rendering.GraphicsImage kColorMap, ModelLUT kLUT)
When the LUT changes, this function updates the LUT data on the GPU.- Parameters:
kColorTexture
- the color-map Texture object.kColorMap
- the color-map GraphicsImage object (stores data).kLUT
- the updated or new LUT.
-
CopyNormalFiles
public void CopyNormalFiles(int i, ModelImage kImage)
When the ModelImage data is rendered as a solid surface, the Normal map is used in the rendering. The Normal map is calculated on the GPU by one of the GLSL shader programs. This function is called after the GPU calculation has finished and the GPU data has been copied into a new ModelImage on the CPU the new ModelImage then contains the Normal map information, which is written into a file and copied into the Normal map GraphicsImage used to render the original ModelImage.- Parameters:
i
- current 3D sub-image for 4D data. If the data is 3D this value should be 0.kImage
- a new ModelImage containing the calculated Normals.
-
CreateImageFromTexture
public static ModelImage CreateImageFromTexture(WildMagic.LibGraphics.Rendering.GraphicsImage kImage)
Read the current Volume Texture from the GPU and return a new ModelImage of that data.- Returns:
- new ModelImage from Volume Texture on GPU.
-
dispose
public void dispose()
Memory cleanup.
-
GenerateNormalFiles
public void GenerateNormalFiles(VolumeTriPlanarInterface parentFrame)
This function is called when the user selects the Surface or Composite Surface volume rendering option. If the normals have already been initialized the function returns. Otherwise the function checks if the normals are available in a file on disk, and if so if they match the parameters (size, units, resolutions) of the original ModelImage. If the files match they are used and the Normal map is read from file. Otherwise this function launches the GPU-based Normal calculation. That calculation when finished calls the CopyNormalFiles which writes the calculated normals to disk and updates the Normal map on the GPU for rendering.
-
GetColorMapTarget
public WildMagic.LibGraphics.Rendering.Texture GetColorMapTarget()
Return the Color Map Texture.- Returns:
- Volume color map Texture.
-
getDRRNorm
public float getDRRNorm()
Return the normalization factor for DDR rendering mode.- Returns:
- normalization factor for DDR rendering mode.
-
GetGradientMapTarget
public WildMagic.LibGraphics.Rendering.Texture GetGradientMapTarget()
Return the Gradient Magnitude Texture.- Returns:
- Gradient Magnitude Texture.
-
isHistoInit
public boolean isHistoInit()
Returns true if the multi-histogram histogram texture has been initialized, false otherwise.- Returns:
- true if the multi-histogram histogram texture has been initialized, false otherwise.
-
GetHistoTarget
public WildMagic.LibGraphics.Rendering.Texture GetHistoTarget()
Returns the multi-histogram histogram Texture.- Returns:
- the multi-histogram histogram Texture.
-
GetHistoTCoords
public WildMagic.LibFoundation.Mathematics.Vector2f[] GetHistoTCoords()
Return the texture coordinates for the multi-histogram histogram texture.- Returns:
- the texture coordinates for the multi-histogram histogram texture.
-
GetGradientMagnitudeImage
public ModelImage GetGradientMagnitudeImage()
-
GetGradientMagnitudeMinMax
public WildMagic.LibFoundation.Mathematics.Vector2f GetGradientMagnitudeMinMax()
-
GetGradientMagnitudeMin
public float GetGradientMagnitudeMin()
-
GetGradientMagnitudeMax
public float GetGradientMagnitudeMax()
-
GetImage
public ModelImage GetImage()
Return the ModelImage volume data.- Returns:
- ModelImage volume data.
-
GetLUT
public ModelLUT GetLUT()
Return the ModelImage LUT.- Returns:
- Volume LUT.
-
GetNormalMapTarget
public WildMagic.LibGraphics.Rendering.Texture GetNormalMapTarget()
Return the Normal map Texture.- Returns:
- Normal map Texture.
-
GetScratchTarget
public WildMagic.LibGraphics.Rendering.Texture GetScratchTarget()
-
GetOpacityMapGMTarget
public WildMagic.LibGraphics.Rendering.Texture GetOpacityMapGMTarget()
Return the gradient magnitude opacity transfer function Texture.- Returns:
- gradient magnitude opacity transfer function Texture.
-
GetPostfix
public java.lang.String GetPostfix()
Return the postfix for this VolumeImage.- Returns:
- postfix for this VolumeImage.
-
getLUT
public ModelStorageBase getLUT()
Return the Volume RGBT.- Returns:
- Volume RGBT.
-
GetRGB
public ModelRGB GetRGB()
Return the Volume RGBT.- Returns:
- Volume RGBT.
-
GetTransferedValue
public float GetTransferedValue(int x, int y, int z)
-
TransferValue
private float TransferValue(float value)
-
GetScaleMax
public float GetScaleMax()
The ModelImage Volume max-scale factor.- Returns:
- Volume max-scale factor.
-
GetMaxExtent
public int GetMaxExtent()
-
GetScaleX
public float GetScaleX()
The ModelImage Volume x-scale factor.- Returns:
- Volume x-scale factor.
-
GetScaleY
public float GetScaleY()
The ModelImage Volume y-scale factor.- Returns:
- Volume y-scale factor.
-
GetScaleZ
public float GetScaleZ()
The ModelImage Volume z-scale factor.- Returns:
- Volume z-scale factor.
-
GetSurfaceTarget
public WildMagic.LibGraphics.Rendering.Texture GetSurfaceTarget()
Return the surface mask Texture.- Returns:
- surface mask Texture.
-
setSurfaceMask
public void setSurfaceMask(java.lang.String name, WildMagic.LibFoundation.Mathematics.ColorRGB color, java.util.BitSet mask)
Add a new surface mask.- Parameters:
name
- surface name.mask
- surface mask volume.
-
updateMask
private void updateMask()
-
removeSurfaceMask
public void removeSurfaceMask(java.lang.String name)
Delete the surface mask, using the name of the mask as reference.- Parameters:
name
- the surface name.
-
setSurfaceMaskColor
public void setSurfaceMaskColor(java.lang.String name, WildMagic.LibFoundation.Mathematics.ColorRGB color)
Delete the surface mask, using the name of the mask as reference.- Parameters:
name
- the surface name.
-
GetTimeSlice
public int GetTimeSlice()
Returns the current rendered time-slice for 4D images. Otherwise returns 0.- Returns:
- the current rendered time-slice for 4D images. Otherwise returns 0.
-
GetVolumeTarget
public WildMagic.LibGraphics.Rendering.Texture GetVolumeTarget()
Return the Texture containing the volume data.- Returns:
- Texture containing the volume data.
-
GetVolumeTargetBuffer
public java.nio.Buffer GetVolumeTargetBuffer()
Return the Buffer containing the volume data, which is stored in the Texture GrapicsImage.- Returns:
- Buffer containing the volume data.
-
InitOpacityMap
public WildMagic.LibGraphics.Rendering.GraphicsImage InitOpacityMap(ModelImage kImage, java.lang.String kPostFix)
Initialize the GraphicsImage for the opacity lookup table.- Parameters:
kImage
- the ModelImage the opacity transfer function applies to.kPostfix
- the string postfix to concatenate to the "OpacityMap" image name.- Returns:
- GraphicsImage, the new GraphicsImage storing opacity lookup table.
-
IsColorImage
public boolean IsColorImage()
Return true if the Volume image is a color image.- Returns:
- true if the Volume image is a color image.
-
ReleaseVolume
public void ReleaseVolume()
Release the Textures containing the volume data. Once Textures are released, they will be re-loaded onto the GPU during the next frame.
-
SetGradientMagnitude
public void SetGradientMagnitude(ModelImage kGradientMagnitude, boolean bComputeLaplace, java.lang.String kPostfix)
Called when the user selects the Gradient Magnitude option or the Multi-Histogram option in the Volume Renderer.- Parameters:
kGradientMagnitude
- pre-computed GradientMagnitude image or nullbComputeLaplace
- when true the Laplace image and multi-histogram histogram Textures are computed.kPostfix
- GraphicsImage postfix string.
-
SetRGBT
public void SetRGBT(ModelRGB kRGBT)
Sets the ModelRGB for the iImage.- Parameters:
kRGBT
- new ModelRGB
-
SetTimeSlice
public void SetTimeSlice(int iSlice)
Sets the time slices for 4D data.- Parameters:
iSlice
- new time slice value.
-
update4D
public void update4D(boolean bForward)
Updates the current time slice.- Parameters:
bForward
- when true the time advances on step forward or wraps to the beginning. When false the time moves backward.
-
UpdateData
public void UpdateData(ModelImage kImage, boolean reload)
Update the image data.- Parameters:
kImage
- the modified ModelImagebCopytoCPU
- when true the data is copied from the GPU GraphicsImage into the ModelImage
-
UpdateData
public void UpdateData(ModelImage kImage, ModelLUT kLUT, boolean reload)
Changes the underlying image data and LUT. If the new image data is a different size than then previous one, recreate the volume image on the GPU, otherwise just overwrite it with the new data.- Parameters:
kImage
-kLUT
-reload
-
-
UpdateImages
public void UpdateImages(ModelLUT kLUT)
Update the LUT for the ModelImage.- Parameters:
kLUT
- new LUT for ModelImage.
-
UpdateImages
public void UpdateImages(ModelStorageBase kLUT)
Update the LUT for the ModelImage.- Parameters:
kLUT
- new LUT for ModelImage.
-
UpdateImages
public boolean UpdateImages(TransferFunction kTransfer, int iImage, ModelImage kImage)
Update the transfer function for the image iImage.- Parameters:
kTransfer
- the new opacity transfer functioniImage
- the image to modify (0 = volume image, 2 = gradient mag)kImage
- GradientMagitude image.- Returns:
- boolean true when updated, false otherwise.
-
computeIntegralNormalizationFactor
protected float computeIntegralNormalizationFactor()
In order to map line integrals of image intensity to RGB colors where each color channel is 8 bits, it is necessary to make sure that the integrals are in [0,255]. Producing a theoretical maximum value of a line integral is not tractable in an application. This method constructs an approximate maximum by integrating along each line of voxels in the image with line directions parallel to the coordinate axes. The 'processRay' call adjusts the line integrals using the estimate, but still clamps the integrals to 255 since the estimate might not be the true maximum.- Returns:
- float Integral normalization factor.
-
checkImage
public static boolean checkImage(ModelImage kImage1, ModelImage kImage2)
Checks that the two input images match extents, units of measure and resolutions. The images may had different sizes (3D or 4D) the first 3-dimensions must match.- Parameters:
kImage1
-kImage2
-- Returns:
- true if the images match extends, units and resolutions.
-
GenerateHistogram
private void GenerateHistogram(WildMagic.LibGraphics.Rendering.GraphicsImage[] kImage, WildMagic.LibGraphics.Rendering.GraphicsImage[] kImageGM, java.lang.String kPostFix, int start, int end)
Generate 2D histogram from the input image and the gradient-magnitude- Parameters:
kImage
- input GraphicsImage containing the ModelImage datakImageGM
- input GraphcisImage containing the Gradient Magnitude data.kPostFix
- post-fix for the image name.
-
getGradientMagnitude
public static ModelImage getGradientMagnitude(ModelImage kImage, int i)
Calculates and stores the gradient magnitude images (3D or 4D) for the input image. Or reads from disk. The data is stored in the GraphicsImage data structures and will be passed to the GPU to use in rendering.- Parameters:
kImage
- input imagekGradientMagnitude
- input Gradient Magnitude image, or null.bComputeLaplace
- when true the Laplace image is also calculated or read from dis. private void GradientMagnitudeImage(final ModelImage kImage, ModelImage kGradientMagnitude, boolean bComputeLaplace) { if ( !m_bGMInit ) { ModelImage[] kImageGM = new ModelImage[m_iTimeSteps]; String[] kImageName = new String[m_iTimeSteps]; for (int i = 0; i < m_iTimeSteps; i++) { kImageName[i] = ModelImage.makeImageName(kImage.getFileInfo(0).getFileName(), new String("_GM_" + i)); if ( kGradientMagnitude != null && checkImage(kImage, kGradientMagnitude )) { m_kVolumeGM[i] = VolumeImage.UpdateData(kGradientMagnitude, i, null, m_kVolumeGM[i], m_kVolumeGMTarget, m_kVolumeGM[i].GetName(), true, false); ModelImage.saveImage( kGradientMagnitude, kImageName[i] + ".xml", m_kDir ); } else { kImageGM[i] = ReadFromDisk(kImageName[i] + ".xml", m_kDir); if ( kImageGM[i] != null && !checkImage(kImage, kImageGM[i] ) ) { kImageGM[i].disposeLocal(); kImageGM[i] = null; } if (kImageGM[i] == null) { JDialogGradientMagnitude kCalcMagnitude = new JDialogGradientMagnitude(null, m_akImages[i]); kCalcMagnitude.setVisible(false); kCalcMagnitude.setOutputNewImage(true); kCalcMagnitude.setDisplayProgressBar(true); kCalcMagnitude.setSeparateThread(false); kCalcMagnitude.setSeparable(true); kCalcMagnitude.setUseOCL(true); kCalcMagnitude.actionPerformed(new ActionEvent(this, 0, "OK")); kImageGM[i] = kCalcMagnitude.getResultImage(); kCalcMagnitude = null; } if (kImageGM[i] == null) { System.err.println("Gradient magnitude calculation returned null"); m_kVolumeGM[i] = VolumeImage.UpdateData(kImage, i, null, m_kVolumeGM[i], m_kVolumeGMTarget, kImageName[i], true, false); } else { kImageGM[i].calcMinMax(); m_akGradientMagMinMax[i] = new Vector2f( (float)kImageGM[i].getMin(), (float)kImageGM[i].getMax() ); if ( !( bComputeLaplace && !m_kImage.isColorImage() ) ) { m_kVolumeGM[i] = VolumeImage.UpdateData(kImageGM[i], 0, null, m_kVolumeGM[i], m_kVolumeGMTarget, kImageName[i], true, false); } } } } if ( bComputeLaplace && !m_kImage.isColorImage() ) { for (int i = 0; i < m_iTimeSteps; i++) { final String kImageNameL = ModelImage.makeImageName(kImage.getFileInfo(0).getFileName(), new String( "_Laplacian_" + i)); ModelImage kImageGMGM = null; kImageGMGM = ReadFromDisk(kImageNameL + ".xml", m_kDir); if ( kImageGMGM != null && !checkImage(kImage, kImageGMGM ) ) { kImageGMGM.disposeLocal(); kImageGMGM = null; } if (kImageGMGM == null) { final JDialogLaplacian kCalcLaplacian = new JDialogLaplacian(null, m_akImages[i]); kCalcLaplacian.setVisible(false); kCalcLaplacian.setOutputNewImage(true); kCalcLaplacian.setDisplayProgressBar(true); kCalcLaplacian.setSeparateThread(false); kCalcLaplacian.setUseOCL(true); kCalcLaplacian.setSeparable(true); kCalcLaplacian.actionPerformed(new ActionEvent(this, 0, "OK")); kImageGMGM = kCalcLaplacian.getResultImage(); } if (kImageGMGM != null) { m_kVolumeGM[i] = createGM_Laplace(kImageGM[i], kImageGMGM, m_kVolumeGM[i], i, true); } else { m_kVolumeGM[i] = VolumeImage.UpdateData(kImageGM[i], 0, null, m_kVolumeGM[i], m_kVolumeGMTarget, kImageName[i], true, false); } final ViewJFrameImage kImageFrame = ViewUserInterface.getReference().getFrameContainingImage(kImageGMGM); if (kImageFrame != null) { kImageFrame.close(); } else if (kImageGMGM != null) { kImageGMGM.disposeLocal(); kImageGMGM = null; } } } m_bGMInit = true; m_kVolumeGMTarget.SetImage(m_kVolumeGM[0]); m_kVolumeGMTarget.Reload(true); for ( int i = 0; i < kImageGM.length; i++ ) { if (kImageGM[i] != null) { kImageGM[i].setImageDirectory( m_kDir ); kImageGM[i].setImageName( kImageName[i] + ".xml" ); ModelImage.saveImage(kImageGM[i], kImageName[i] + ".xml", m_kDir ); final ViewJFrameImage kImageFrame = ViewUserInterface.getReference().getFrameContainingImage(kImageGM[i]); if (kImageFrame != null) { kImageFrame.close(); } kImageGM[i].disposeLocal(); kImageGM[i] = null; } } } }
-
init
private void init(ViewJProgressBar kProgress, int iProgress, boolean initGradientMagnitude)
Initialize the VolumeImage with the ModelImage data.- Parameters:
kProgress
- progress bariProgress
- progress bar increment
-
initImages
private void initImages()
Intializes the Textures and GraphicsImages used to render the ModelImage this VolumeImage represents.
-
initImagesColor
private void initImagesColor()
-
initLUT
private void initLUT()
Create a new LUT for the input image.- Parameters:
kImage
- ModelImage.
-
InitScale
private void InitScale()
Initialize the scale factors. Based on the ModelImage Volume.
-
ReadFromDisk
private static ModelImage ReadFromDisk(java.lang.String kImageName, java.lang.String kDir)
Reads an image from disk.- Parameters:
kImageName
- image namekDir
- directory- Returns:
- ModelImage
-
readObject
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
update4D
private void update4D()
Go to the next 3D volume sub-image for the 4D animation. Updates the Textures and causes them to be reloaded onto the GPU.
-
UpdateImages
private boolean UpdateImages(ModelImage kImage, WildMagic.LibGraphics.Rendering.Texture kOpacityTexture, WildMagic.LibGraphics.Rendering.GraphicsImage kOpacityMap, TransferFunction kTransfer)
Called when the opacity transfer function changes. This function updates the Texture and causes the data to be reloaded onto the GPU.- Parameters:
kImage
- the ModelImage the transfer function applies to.kOpacityTexture
- the opacity Texture passed to the GPUkOpacityMap
- the opacity data stored in the GraphicsImagekTransfer
- the new transfer function.
-
getOpacityFn
public TransferFunction getOpacityFn()
-
UpdateImages2
private boolean UpdateImages2(ModelImage kImage, WildMagic.LibGraphics.Rendering.Texture kOpacityTexture, WildMagic.LibGraphics.Rendering.GraphicsImage kOpacityMap, TransferFunction kTransfer)
Update the opacity transfer function.- Parameters:
kImage
- the ModelImage the transfer function applies to.kOpacityTexture
- the opacity Texture passed to the GPUkOpacityMap
- the opacity data stored in the GraphicsImagekTransfer
- the new transfer function.
-
writeObject
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
-