Interactive Segmentation

<< Click to Display Table of Contents >>

Navigation:  XStream® HDVR® SDK > Implementation Concepts > Segmentation >

Interactive Segmentation

Previous pageReturn to chapter overviewNext page

C++ C++ Java Java .NET .NET

Summary

 

The XStream® HDVR® SDK supports a real-time segmentation method called Interactive Segmentation. This technique allows one to manipulate the segmentation state interactively in real-time. Users may change multiple segmentation parameters in quick succession and view the changes on-screen as they happen. The Interactive Segmentation functions can be connected to a user interface device, such as a mouse, allowing the user to manipulate one or more segmentation parameters simultaneously in an intuitive fashion. Visually manipulating segmentation state in this manner can provide for much easier and faster segmentation of complex regions and material types than hand tuning numbers in a user interface dialog.

 

InteractiveSegmentation

Segmentation of the airway using Interactive Segmentation

 

Interactive Segmentation

 

Before Interactive Segmentation can be used it must first be enabled. This is done with the IVolumeSegmentationContext::EnableInteractiveSeg() method. This method is used to designate which render engines will be used to visualize the segmentation state as it is altered by the Interactive Segmentation methods. The IVolumeSegmentationContext::EnableInteractiveSeg() method takes two input parameters. The first is the number of render engines to be attached to the Interactive Segmentation algorithm. The second parameter is an array of pointers to IRenderEngineContext objects. The length of the array of IRenderEngineContext objects is given by the first input parameter. These engines will be updated as the segmentation state changes during the Interactive Segmentation cycle.

 

After the Interactive Segmentation algorithm is enabled, an Interactive Segmentation cycle is begun with a call to IVolumeSegmentationContext::InteractiveSegInit(). This method takes three parameters. The first parameter is the address of a SEGMENTATION_PARAMS structure containing the segmentation parameters to be applied. The second and third parameters are the address of variables that will be set with the size of the segmented region in voxels and cubic dataset units, usually cubic millimeters.

 

When using Interactive Segmentation, label volume 7 cannot be used as a segmentation target as it is used as a workspace buffer by the Interactive Segmentation algorithm.

 

Once an Interactive Segmentation cycle has been started with the IVolumeSegmentationContext::InteractiveSegInit() method, the label volume may be continuously re-segmented in real time with successive calls to the IVolumeSegmentationContext::InteractiveSegReSegment() method. This method takes the same three parameters as the IVolumeSegmentationContext::InteractiveSegInit() method. The IVolumeSegmentationContext::InteractiveSegReSegment() method may be called successively as many times as desired, with the values in the input SEGMENTATION_PARAMS structure being changed each time by a user interface device or component.

 

When an Interactive Segmentation cycle is complete, it is ended with a call to the IVolumeSegmentationContext::InteractiveSegEnd() method. The segmentation state is then permanently applied to the label volume. If the user is not satisfied with the segmentation state applied during an Interactive Segmentation cycle, the segmentation state may be restored to the state it was in before the initial call to IVolumeSegmentationContext::InteractiveSegInit() with a call to IVolumeSegmentationContext::InteractiveSegCancel(). This method will abort and undo the changes applied during the Interactive Segmentation cycle.

 

// Create an IVolumeSegmentationContext object.

IVolumeSegmentationContext *pSegmentationContext;

pServer->CreateVolumeSegmentation(&pSegmentationContext);

 

// Set the octree for the IVolumeSegmentationContext object. 

pSegmentationContext->Initialize(pOctree);

 

// Segmentation operations will apply to transfer function 2 (index 1).

pSegmentationContext->SetSegLabelIndex(1);

 

// Set additive segmentation.

pSegmentationContext->SetSegType(ST_ADDITIVE);

 

// Set all 8 label volumes as valid for segmentation.

pSegmentationContext->SetSegLabelMask(255, 0, 0, 0);

 

// Setup array of engines to display results of Interactive Segmentation cycle.

renderEngineArray[0] = p3D_Engine;

renderEngineArray[1] = pAxialEngine;

renderEngineArray[2] = pSagittalEngine

renderEngineArray[3] = pCoronalEngine;

 

// Enable Interactive Segmentation.

pSegmentationContext->EnableInteractiveSeg(4, renderEngineArray);

 

// Initialize a SEGMENTATION_PARAMS structure.

SEGMENTAION_PARAMS segParams;

UserDefinedParamsInit(&segParams);

 

// Begin Interactive Segmentation cycle.

h_int64 sizeVoxels = 0; 

double sizeMMs = 0;

pSegmentationContext->InteractiveSegInit(&segParams, &sizeVoxels, &sizeMMs);

 

// Continuously update SEGMENTATION_PARAMS structure and re-segment.

while(bSegmentingActive) 

{

   UserDefinedUpdateSegParams(&segParams);

   pSegmentationContext->InteractiveSegReSegment(&segParams,  &sizeVoxels, &sizeMMs);

}

 

if(bSegmentationStateAccepted)

   pSegmentationContext->InteractiveSegEnd();

else

   pSegmentationContext->InteractiveSegCancel();

 

Before Interactive Segmentation can be used it must first be enabled. This is done with the hdrcIVolumeSegmentation.enableInteractiveSeg() method. This method is used to designate which render engines will be used to visualize the segmentation state as it is altered by the Interactive Segmentation methods. The hdrcIVolumeSegmentation.enableInteractiveSeg() method takes as an input parameter an array of reference to hdrcRenderEngineContext objects. These engines will be updated as the segmentation state changes during the Interactive Segmentation cycle.

 

After the Interactive Segmentation algorithm is enabled, an Interactive Segmentation cycle is begun with a call to hdrcIVolumeSegmentation.interactiveSegInit(). This method takes as input parameter a reference to a SEGMENTATION_PARAMS structure containing the segmentation parameters to be applied. The hdrcIVolumeSegmentation.interactiveSegInit() method returns a SEGMENTATION_VOLUME structure containing data on the size of the region being segmented.

 

When using Interactive Segmentation, label volume 7 cannot be used as a segmentation target as it is used as a workspace buffer by the Interactive Segmentation algorithm.

 

Once an Interactive Segmentation cycle has been started with the hdrcIVolumeSegmentation.interactiveSegInit() method, the label volume may be continuously re-segmented in real time with successive calls to the IVolumeSegmentationContext::InteractiveSegReSegment() method. This method takes as input parameter a reference to a SEGMENTATION_PARAMS structure containing the segmentation parameters to be applied. The hdrcIVolumeSegmentation.interactiveSegReSegment() method may be called successively as many times as desired, with the values in the input SEGMENTATION_PARAMS structure being changed each time by a user interface device or component. The hdrcIVolumeSegmentation.interactiveSegReSegment() method returns a SEGMENTATION_VOLUME structure containing data on the size of the region being segmented.

 

When an Interactive Segmentation cycle is complete, it is ended with a call to the hdrcIVolumeSegmentation.interactiveSegEnd() method. The segmentation state is then permanently applied to the label volume. If the user is not satisfied with the segmentation state applied during an Interactive Segmentation cycle, the segmentation state may be restored to the state it was in before the initial call to hdrcIVolumeSegmentation.interactiveSegInit() with a call to hdrcIVolumeSegmentation.interactiveSegCancel(). This method will abort and undo the changes applied during the Interactive Segmentation cycle.

 

// Create an hdrcIVolumeSegmentation object.

hdrcIVolumeSegmentation segmentationContext;

segmentationContext = server.createVolumeSegmentation();

 

// Set the octree for the IVolumeSegmentationContext object. 

segmentationContext.initialize(octree);

 

// Segmentation operations will apply to transfer function 2 (index 1).

segmentationContext.setSegLabelIndex(1);

 

// Set additive segmentation.

segmentationContext.setSegType(hdrcDefines.ST_ADDITIVE);

 

// Set all 8 label volumes as valid for segmentation.

segmentationContext.setSegLabelMask(255, 0, 0, 0);

 

// Setup array of engines to display results of Interactive Segmentation cycle.

renderEngineArray[0] = p3D_Engine;

renderEngineArray[1] = pAxialEngine;

renderEngineArray[2] = pSagittalEngine

renderEngineArray[3] = pCoronalEngine;

 

// Enable Interactive Segmentation.

segmentationContext.enableInteractiveSeg(renderEngineArray);

 

// Initialize a SEGMENTATION_PARAMS structure.

SEGMENTAION_PARAMS segParams;

UserDefinedParamsInit(segParams);

 

// Begin Interactive Segmentation cycle.

SEGMENTATION_VOLUME segVolume;

segVolume = segmentationContext.interactiveSegInit(segParams);

 

// Continuously update SEGMENTATION_PARAMS structure and re-segment.

while(bSegmentingActive) 

{

   UserDefinedUpdateSegParams(segParams);

   segVolume = segmentationContext.interactiveSegReSegment(segParams);

}

 

if(bSegmentationStateAccepted)

   segmentationContext.interactiveSegEnd();

else

   segmentationContext.interactiveSegCancel();