Main Content

Display Interior Labels by Adjusting Volume Overlay Properties

This example shows how to reveal labels on the interior of a labeled volumetric image by adjusting the transparency of the volume.

By default, the volshow function renders the exterior of a volume as opaque. This visualization is not very informative when there are labels inside of the volume. To see the labels inside the volume, you can increase the transparency of the volume or change the rendering style. Using these approaches, you can see the interior labels and still recognize the details of the exterior surface of the volume.

Display Discrete Labels with Label Overlay Rendering

Load a volumetric image and corresponding labels. The volume has three classes and a background label, 0.

dataDir = fullfile(toolboxdir("images"),"imdata","BrainMRILabeled");
load(fullfile(dataDir,"images","vol_001.mat"));
load(fullfile(dataDir,"labels","label_001.mat"));

Display the volume with the labels as an overlay, and zoom in on the volume. The volume appears opaque with the default visualization settings. When you have labeled data, the default value of the OverlayRenderingStyle property is "LabelOverlay". This value is appropriate when the labels are discrete, such as these labels.

hVolume = volshow(vol,OverlayData=label);
viewer = hVolume.Parent;
viewer.CameraZoom = 2;

Apply Gradient Opacity Rendering Style to Volume

Set the RenderingStyle property of the volume to "GradientOpacity". The gradient opacity rendering style applies a localized transparency when sequential voxels have similar intensities. The effect is that regions in the volume with uniform intensity more transparent, while voxels that have large gradients in intensity around them are relatively more opaque. This rendering style is particularly helpful when you want to view inside of a volume while still visualizing the defining features of the volume. You can adjust the amount of transparency using the GradientOpacityValue property.

hVolume.RenderingStyle = "GradientOpacity";

The volume is more transparent. However, both the colored labels and the colored background appear through the volume. To make the labels more distinguishable, change the background color to white and remove the background gradient.

viewer.BackgroundColor="white";
viewer.BackgroundGradient="off";

Adjust Volume and Label Transparency

The labels inside the volume are now visible, but they are hard to distinguish from the rest of the volume. Make the volume data more transparent by decreasing the Alphamap property.

hVolume.Alphamap = linspace(0,0.2,256);

You can also increase the opacity of the labels by increasing the OverlayAlphamap property.

hVolume.OverlayAlphamap = 0.8;

Only two labels are easily visible. The third label in yellow is mostly hidden within the red and green labels, and only a few voxels of yellow are visible on the surface. You can hide individual labels by adjusting the OverlayAlphamap property. Set all elements of OverlayAlphamap, except for the element corresponding to the yellow label, to 0. The yellow label corresponds to the value 2 in the label data and is the third element of the alphamap.

hVolume.OverlayAlphamap = [0 0 0.8 0];

Display Continuous Labels with Gradient Overlay Rendering

Instead of discrete labels, suppose you want to overlay continuous data over the volume. Continuous data could be statistical voxel measurements such as heatmaps and activation maps, or image data from other imaging modalities. In this case, suitable values of the OverlayRenderingStyle are "VolumeOverlay" and "GradientOverlay".

Load another image modality and overlay it with the original volume data using the "GradientOverlay" overlay rendering style. Specify the same scene display settings as for the earlier sections of the example.

vol2 = load(fullfile(dataDir,"images","vol_003.mat"));
vol2 = vol2.vol;
viewerContinuous = viewer3d(BackgroundColor="white",BackgroundGradient="off",CameraZoom=2);
hVolumeContinuous = volshow(vol,OverlayData=vol2,Parent=viewerContinuous,Alphamap=linspace(0,0.2,256), ...
    OverlayRenderingStyle="GradientOverlay",RenderingStyle="GradientOpacity");

Increase the visibility of the interior labels by decreasing the values of the OverlayAlphamap property.

hVolumeContinuous.OverlayAlphamap=linspace(0,0.5,256);

See Also

|

Related Topics