Class VolumeImage
java.lang.Object
gov.nih.mipav.view.renderer.WildMagic.Render.VolumeImage
- All Implemented Interfaces:
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate WildMagic.LibFoundation.Mathematics.Vector2f[]3D sub-images (4D data)private WildMagic.LibFoundation.Mathematics.Vector2f[]Texture coordinates for displaying histogram in 2Dprivate booleanSet to true if the Gradient Magnitude texture map has been initialized.private booleanSet to true when the multi-histogram histogram texture has been initialized.private booleanSet to true if the Normal Map has been initialized.private floatprivate floatImage scale factors for display in 3Dprivate floatImage scale factors for display in 3Dprivate floatImage scale factors for display in 3Dprivate floatImage scale factors for display in 3Dprivate intprivate intCurrent position in time (4D data)private intTotal number of time-slices (4D data)private WildMagic.LibGraphics.Rendering.GraphicsImageData storage for color map:private WildMagic.LibGraphics.Rendering.TextureTexture object for color map:private StringDirectory for calculated imagesprivate WildMagic.LibGraphics.Rendering.GraphicsImage[]Histogram data for multi-histogram interfaceprivate WildMagic.LibGraphics.Rendering.TextureTexture object for data:private ModelImageReference to ModelImage imageprivate ModelImageprivate ModelLUTModelLUTprivate WildMagic.LibGraphics.Rendering.GraphicsImage[]Data storage for normals:private WildMagic.LibGraphics.Rendering.TextureTexture object for normal map:private WildMagic.LibGraphics.Rendering.GraphicsImageGraphicsImage contains GM opacity transfer function data:private WildMagic.LibGraphics.Rendering.TextureTexture contains texture filter modes and GraphicsImage for opacity transfer function:private StringImage name post-fix typically either 'A' or 'B'private ModelRGBModelRGBprivate WildMagic.LibGraphics.Rendering.TextureTexture object for GPU computations:private WildMagic.LibGraphics.Rendering.GraphicsImageData storage for surfaces:private WildMagic.LibGraphics.Rendering.TextureTexture object for surfaces:private WildMagic.LibGraphics.Rendering.GraphicsImage[]Data storage for volume:private WildMagic.LibGraphics.Rendering.GraphicsImage[]Data storage for volume gradient magnitude:private WildMagic.LibGraphics.Rendering.TextureTexture object for volume gradient magnitude data:private WildMagic.LibGraphics.Rendering.TextureTexture object for data:private TransferFunctionprivate static final longprotected Vector<WildMagic.LibFoundation.Mathematics.ColorRGB> A vector of BitSet masks, one for each surface loaded into the viewer.A vector of BitSet masks, one for each surface loaded into the viewer.A vector of the mask names, so they can be accessed by name: -
Constructor Summary
ConstructorsConstructorDescriptionVolumeImage(boolean bClone, ModelImage kImage, String kPostfix, ViewJProgressBar kProgress, int iProgress) Create a Volume image with the input ModelImage.VolumeImage(boolean bClone, ModelImage kImage, String kPostfix, ViewJProgressBar kProgress, int iProgress, boolean initGradientMagnitude) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddNormals(ModelImage kImage, int iTimeSlice) static booleancheckImage(ModelImage kImage1, ModelImage kImage2) Checks that the two input images match extents, units of measure and resolutions.protected floatIn 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].voidCopyNormalFiles(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.GraphicsImagecreateGM_Laplace(ModelImage kImageGM, ModelImage kImageL, WildMagic.LibGraphics.Rendering.GraphicsImage kVolumeImage, int iTimeSlice, boolean bSwap) static ModelImageCreateImageFromTexture(WildMagic.LibGraphics.Rendering.GraphicsImage kImage) Read the current Volume Texture from the GPU and return a new ModelImage of that data.static ModelImageCreateImageFromTexture(WildMagic.LibGraphics.Rendering.GraphicsImage kImage, boolean bSwap) Copy the data from the input GraphicsImage and return a new ModelImage of that data.voiddispose()Memory cleanup.private voidGenerateHistogram(WildMagic.LibGraphics.Rendering.GraphicsImage[] kImage, WildMagic.LibGraphics.Rendering.GraphicsImage[] kImageGM, String kPostFix, int start, int end) Generate 2D histogram from the input image and the gradient-magnitudevoidGenerateNormalFiles(VolumeTriPlanarInterface parentFrame) This function is called when the user selects the Surface or Composite Surface volume rendering option.WildMagic.LibGraphics.Rendering.TextureReturn the Color Map Texture.floatReturn the normalization factor for DDR rendering mode.static ModelImagegetGradientMagnitude(ModelImage kImage, int i) Calculates and stores the gradient magnitude images (3D or 4D) for the input image.floatfloatWildMagic.LibFoundation.Mathematics.Vector2fWildMagic.LibGraphics.Rendering.TextureReturn the Gradient Magnitude Texture.WildMagic.LibGraphics.Rendering.TextureReturns the multi-histogram histogram Texture.WildMagic.LibFoundation.Mathematics.Vector2f[]Return the texture coordinates for the multi-histogram histogram texture.GetImage()Return the ModelImage volume data.getLUT()Return the Volume RGBT.GetLUT()Return the ModelImage LUT.intWildMagic.LibGraphics.Rendering.TextureReturn the Normal map Texture.WildMagic.LibGraphics.Rendering.TextureReturn the gradient magnitude opacity transfer function Texture.Return the postfix for this VolumeImage.GetRGB()Return the Volume RGBT.floatThe ModelImage Volume max-scale factor.floatThe ModelImage Volume x-scale factor.floatThe ModelImage Volume y-scale factor.floatThe ModelImage Volume z-scale factor.WildMagic.LibGraphics.Rendering.TextureWildMagic.LibGraphics.Rendering.TextureReturn the surface mask Texture.intReturns the current rendered time-slice for 4D images.floatGetTransferedValue(int x, int y, int z) WildMagic.LibGraphics.Rendering.TextureReturn the Texture containing the volume data.Return the Buffer containing the volume data, which is stored in the Texture GrapicsImage.private voidinit(ViewJProgressBar kProgress, int iProgress, boolean initGradientMagnitude) Initialize the VolumeImage with the ModelImage data.private WildMagic.LibGraphics.Rendering.GraphicsImagestatic WildMagic.LibGraphics.Rendering.GraphicsImageInitColorMap(WildMagic.LibGraphics.Rendering.Texture kTexture, WildMagic.LibGraphics.Rendering.GraphicsImage kImage, ModelStorageBase kLUT, String kPostFix) Initialize the textures for the color lookup table.private voidIntializes the Textures and GraphicsImages used to render the ModelImage this VolumeImage represents.private voidprivate voidinitLUT()Create a new LUT for the input image.WildMagic.LibGraphics.Rendering.GraphicsImageInitOpacityMap(ModelImage kImage, String kPostFix) Initialize the GraphicsImage for the opacity lookup table.private voidInitialize the scale factors.private WildMagic.LibGraphics.Rendering.GraphicsImageinitVolumeData(ModelImage kImage, int iTimeSlice, WildMagic.LibGraphics.Rendering.Texture kVolumeTexture, String kImageName, boolean bSwap, boolean bRescale) booleanReturn true if the Volume image is a color image.booleanReturns true if the multi-histogram histogram texture has been initialized, false otherwise.private static ModelImageReadFromDisk(String kImageName, String kDir) Reads an image from disk.private voidvoidRelease the Textures containing the volume data.voidremoveSurfaceMask(String name) Delete the surface mask, using the name of the mask as reference.private WildMagic.LibGraphics.Rendering.GraphicsImageresetVolumeData(ModelImage kImage, int iTimeSlice, WildMagic.LibGraphics.Rendering.GraphicsImage kGraphicsImage, WildMagic.LibGraphics.Rendering.Texture kVolumeTexture, String kImageName, boolean bSwap, boolean bRescale) voidSetGradientMagnitude(ModelImage kGradientMagnitude, boolean bComputeLaplace, String kPostfix) Called when the user selects the Gradient Magnitude option or the Multi-Histogram option in the Volume Renderer.voidSets the ModelRGB for the iImage.voidsetSurfaceMask(String name, WildMagic.LibFoundation.Mathematics.ColorRGB color, BitSet mask) Add a new surface mask.voidsetSurfaceMaskColor(String name, WildMagic.LibFoundation.Mathematics.ColorRGB color) Delete the surface mask, using the name of the mask as reference.voidSetTimeSlice(int iSlice) Sets the time slices for 4D data.private floatTransferValue(float value) private voidupdate4D()Go to the next 3D volume sub-image for the 4D animation.voidupdate4D(boolean bForward) Updates the current time slice.voidUpdateData(ModelImage kImage, boolean reload) Update the image data.static WildMagic.LibGraphics.Rendering.GraphicsImageUpdateData(ModelImage kImage, int iTimeSlice, ModelImage kNewImage, WildMagic.LibGraphics.Rendering.GraphicsImage kVolumeImage, WildMagic.LibGraphics.Rendering.Texture kVolumeTexture, 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.voidUpdateData(ModelImage kImage, ModelLUT kLUT, boolean reload) Changes the underlying image data and LUT.static WildMagic.LibGraphics.Rendering.GraphicsImageUpdateData(ModelSimpleImage kImage, String kImageName) Creates a new GraphicsImage for the input ModelSimpleImage.private booleanUpdateImages(ModelImage kImage, WildMagic.LibGraphics.Rendering.Texture kOpacityTexture, WildMagic.LibGraphics.Rendering.GraphicsImage kOpacityMap, TransferFunction kTransfer) Called when the opacity transfer function changes.voidUpdateImages(ModelLUT kLUT) Update the LUT for the ModelImage.voidUpdateImages(ModelStorageBase kLUT) Update the LUT for the ModelImage.booleanUpdateImages(TransferFunction kTransfer, int iImage, ModelImage kImage) Update the transfer function for the image iImage.static voidUpdateImages(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 booleanUpdateImages2(ModelImage kImage, WildMagic.LibGraphics.Rendering.Texture kOpacityTexture, WildMagic.LibGraphics.Rendering.GraphicsImage kOpacityMap, TransferFunction kTransfer) Update the opacity transfer function.private voidprivate void
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
m_kImage
Reference to ModelImage image -
m_kImageGM
-
m_kOpacityMap_GM
private WildMagic.LibGraphics.Rendering.GraphicsImage m_kOpacityMap_GMGraphicsImage contains GM opacity transfer function data: -
m_kOpacityMapTarget_GM
private WildMagic.LibGraphics.Rendering.Texture m_kOpacityMapTarget_GMTexture contains texture filter modes and GraphicsImage for opacity transfer function: -
m_kVolume
private WildMagic.LibGraphics.Rendering.GraphicsImage[] m_kVolumeData storage for volume: -
m_kVolumeTarget
private WildMagic.LibGraphics.Rendering.Texture m_kVolumeTargetTexture object for data: -
m_kNormal
private WildMagic.LibGraphics.Rendering.GraphicsImage[] m_kNormalData storage for normals: -
m_bNormalsInit
private boolean m_bNormalsInitSet to true if the Normal Map has been initialized. -
m_kNormalMapTarget
private WildMagic.LibGraphics.Rendering.Texture m_kNormalMapTargetTexture object for normal map: -
m_kScratchTarget
private WildMagic.LibGraphics.Rendering.Texture m_kScratchTargetTexture object for GPU computations: -
m_kColorMap
private WildMagic.LibGraphics.Rendering.GraphicsImage m_kColorMapData storage for color map: -
m_kColorMapTarget
private WildMagic.LibGraphics.Rendering.Texture m_kColorMapTargetTexture object for color map: -
m_kVolumeGM
private WildMagic.LibGraphics.Rendering.GraphicsImage[] m_kVolumeGMData storage for volume gradient magnitude: -
m_bGMInit
private boolean m_bGMInitSet to true if the Gradient Magnitude texture map has been initialized. -
m_kVolumeGMTarget
private WildMagic.LibGraphics.Rendering.Texture m_kVolumeGMTargetTexture object for volume gradient magnitude data: -
m_kSurfaceImage
private WildMagic.LibGraphics.Rendering.GraphicsImage m_kSurfaceImageData storage for surfaces: -
m_kSurfaceTarget
private WildMagic.LibGraphics.Rendering.Texture m_kSurfaceTargetTexture object for surfaces: -
m_kLUT
ModelLUT -
m_kRGBT
ModelRGB -
m_fX
private float m_fXImage scale factors for display in 3D -
m_fY
private float m_fYImage scale factors for display in 3D -
m_fZ
private float m_fZImage scale factors for display in 3D -
m_fMax
private float m_fMaxImage scale factors for display in 3D -
m_iMaxExtent
private int m_iMaxExtent -
m_kPostfix
Image name post-fix typically either 'A' or 'B' -
m_kDir
Directory for calculated images -
m_kHisto
private WildMagic.LibGraphics.Rendering.GraphicsImage[] m_kHistoHistogram data for multi-histogram interface -
m_bHistoInit
private boolean m_bHistoInitSet to true when the multi-histogram histogram texture has been initialized. -
m_kHistoTarget
private WildMagic.LibGraphics.Rendering.Texture m_kHistoTargetTexture object for data: -
m_akHistoTCoord
private WildMagic.LibFoundation.Mathematics.Vector2f[] m_akHistoTCoordTexture coordinates for displaying histogram in 2D -
m_fDRRNormalize
private float m_fDRRNormalize -
m_iTimeSlice
private int m_iTimeSliceCurrent position in time (4D data) -
m_iTimeSteps
private int m_iTimeStepsTotal number of time-slices (4D data) -
m_akGradientMagMinMax
private WildMagic.LibFoundation.Mathematics.Vector2f[] m_akGradientMagMinMax3D sub-images (4D data) -
opacityTransferFn
-
surfaceMask
A vector of BitSet masks, one for each surface loaded into the viewer. -
surfaceNames
A vector of the mask names, so they can be accessed by name: -
surfaceColor
A vector of BitSet masks, one for each surface loaded into the viewer.
-
-
Constructor Details
-
VolumeImage
public VolumeImage() -
VolumeImage
public VolumeImage(boolean bClone, ModelImage kImage, 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, String kPostfix, ViewJProgressBar kProgress, int iProgress, boolean initGradientMagnitude)
-
-
Method Details
-
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, 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, 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, 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, String kImageName, boolean bSwap, boolean bRescale) -
addNormals
-
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, 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
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
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
-
GetGradientMagnitudeMinMax
public WildMagic.LibFoundation.Mathematics.Vector2f GetGradientMagnitudeMinMax() -
GetGradientMagnitudeMin
public float GetGradientMagnitudeMin() -
GetGradientMagnitudeMax
public float GetGradientMagnitudeMax() -
GetImage
Return the ModelImage volume data.- Returns:
- ModelImage volume data.
-
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
Return the postfix for this VolumeImage.- Returns:
- postfix for this VolumeImage.
-
getLUT
Return the Volume RGBT.- Returns:
- Volume RGBT.
-
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(String name, WildMagic.LibFoundation.Mathematics.ColorRGB color, BitSet mask) Add a new surface mask.- Parameters:
name- surface name.mask- surface mask volume.
-
updateMask
private void updateMask() -
removeSurfaceMask
Delete the surface mask, using the name of the mask as reference.- Parameters:
name- the surface name.
-
setSurfaceMaskColor
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
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, 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, 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
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
Update the image data.- Parameters:
kImage- the modified ModelImagebCopytoCPU- when true the data is copied from the GPU GraphicsImage into the ModelImage
-
UpdateData
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
Update the LUT for the ModelImage.- Parameters:
kLUT- new LUT for ModelImage.
-
UpdateImages
Update the LUT for the ModelImage.- Parameters:
kLUT- new LUT for ModelImage.
-
UpdateImages
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
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, 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
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 invalid input: '<' m_iTimeSteps; i++) { kImageName[i] = ModelImage.makeImageName(kImage.getFileInfo(0).getFileName(), new String("_GM_" + i)); if ( kGradientMagnitude != null invalid input: '&'invalid input: '&' 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 invalid input: '&'invalid input: '&' !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 invalid input: '&'invalid input: '&' !m_kImage.isColorImage() ) ) { m_kVolumeGM[i] = VolumeImage.UpdateData(kImageGM[i], 0, null, m_kVolumeGM[i], m_kVolumeGMTarget, kImageName[i], true, false); } } } } if ( bComputeLaplace invalid input: '&'invalid input: '&' !m_kImage.isColorImage() ) { for (int i = 0; i invalid input: '<' 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 invalid input: '&'invalid input: '&' !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 invalid input: '<' 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
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
Reads an image from disk.- Parameters:
kImageName- image namekDir- directory- Returns:
- ModelImage
-
readObject
- Throws:
IOExceptionClassNotFoundException
-
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
-
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
- Throws:
IOException
-