Region Selection

<< Click to Display Table of Contents >>

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

Region Selection

Previous pageReturn to chapter overviewNext page

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

Summary

 

One of the segmentation techniques supported by the XStream® HDVR® SDK is region selection. This technique involves outlining a 2D polygonal overlay region on a rendered image of the dataset. This 2D overlay is then projected into 3D space through the volume, as rendered from the perspective of an IRenderEngineContext (or hdrcRenderEngineContext) object passed to the region selection SDK method. The non-transparent voxels inside the selected region are then segmented to the active transfer function.

 

For more information on preparing a dataset for segmentation and setting an active transfer function, see Segmentation. An area of the dataset can be selected for region selection segmentation either programmatically using SDK methods, or a selection region can be drawn onto a rendered image using the Freehand Cut mouse adaptor.

 

At least one image must be rendered before Region Selection can be applied.

 

FHC_Pre

Region selected with Freehand Cut

FHC_Post

Selected region after segmentation

 

Region Selection

 

In C++, segmentation by region selection is implemented by the IVolumeSegmentationContext::FreeHandCut() method. This method takes seven input parameters. The first is a pointer to an IRenderEngineContext object that will be used to render the 2D image upon which the region selection points will be projected. The second and third parameters are the number of points outlining the selection region, and an array of POINT structures defining the points that make up the polygonal selection region. The fourth parameter is a value from the ENUM_FHC_MODE enumeration that controls which voxels within the outlined selection region will be captured by the segmentation operation. FHC_WHOLE_VOLUME will cause all non-transparent (visible) voxels within a 3 dimensional projection of the outlined selection region into the volume to be segmented. FHC_SURFACE_ONLY will segment only voxels in the top layer of the perceived volume surface. FHC_FIRST_LAYER is similar to FHC_WHOLE_VOLUME, but the segmentation will penetrate only until it first reaches a non-visible voxel. Therefore, visible voxels behind the transparent region will not be segmented as they would be when using FHC_WHOLE_VOLUME mode. FHC_COMPLETE_VOLUME will segment all voxels, visible or not. The fifth parameter is the index of the label volume to segment the voxels into. The final two parameters are the width and height of the image upon which the region selection points will be projected. All voxels inside the outlined region are then segmented according to the region selection mode.

 

In C++, segmentation by region selection is implemented by the hdrcIVolumeSegmentation::freeHandCut() method. This method takes seven input parameters. The first is a pointer to an hdrcRenderEngineContext object that will be used to render the 2D image upon which the region selection points will be projected. The second and third parameters are the number of points outlining the selection region, and an array of POINT structures defining the points that make up the polygonal selection region. The fourth parameter is a value from the ENUM_FHC_MODE enumeration that controls which voxels within the outlined selection region will be captured by the segmentation operation. FHC_WHOLE_VOLUME will cause all non-transparent (visible) voxels within a 3 dimensional projection of the outlined selection region into the volume to be segmented. FHC_SURFACE_ONLY will segment only voxels in the top layer of the perceived volume surface. FHC_FIRST_LAYER is similar to FHC_WHOLE_VOLUME, but the segmentation will penetrate only until it first reaches a non-visible voxel. Therefore, visible voxels behind the transparent region will not be segmented as they would be when using FHC_WHOLE_VOLUME mode. FHC_COMPLETE_VOLUME will segment all voxels, visible or not. The fifth parameter is the index of the label volume to segment the voxels into. The final two parameters are the width and height of the image upon which the region selection points will be projected. All voxels inside the outlined region are then segmented according to the region selection mode.

 

FreehandCutEx3

Behavior of the ENUM_FHC_MODE options.

 

 

// Create an IVolumeSegmentationContext object.

IVolumeSegmentationContext *pSegmentationContext;

pServer->CreateVolumeSegmentation(&pSegmentationContext);

 

// Set the octree for the IVolumeSegmentationContext object. 

pSegmentationContext->Initialize(pOctree);

 

// Set points to outline the upper left quadrant of the dataset as rendered by the

// IRenderEngineContext object passed to the IVolumeSegmentationContext::FreeHandCut() method.

// The points for a Freehand Cut would ideally be gathered from a mouse click and drag operation.

// Consider using the Freehand Cut segmentation mouse adaptor.

int renderWidth = 1024;

int renderHeight = 1024;

 

POINT pointArray[4];

pointArray[0].x = 0;

pointArray[0].y = 0;

 

pointArray[1].x = renderWidth / 2;

pointArray[1].y = 0;

 

pointArray[2].x = renderWidth / 2;

pointArray[2].y = renderHeight / 2;

 

pointArray[3].x = 0;

pointArray[3].y = renderHeight / 2;

 

// The IVolumeSegmentationContext object can now be used for applying a segmentation.

pSegmentationContext->FreeHandCut(pEngine, 4, pointArray, FHC_WHOLE_VOLUME, 1, renderWidth, renderHeight);

 

// Create an hdrcIVolumeSegmentation object.

hdrcIVolumeSegmentation segmentationContext;

segmentationContext = server.createVolumeSegmentation();

 

// Set the octree for the IVolumeSegmentationContext object. 

segmentationContext.initialize(octree);

 

// Set points to outline the upper left quadrant of the dataset as rendered by the

// hdrcRenderEngineContext object passed to the hdrcIVolumeSegmentation::FreeHandCut() method.

// The points for a Freehand Cut would ideally be gathered from a mouse click and drag operation.

// Consider using the Freehand Cut segmentation mouse adaptor.

int renderWidth = 1024;

int renderHeight = 1024;

 

POINT[] pointArray = new POINT[4];

pointArray[0].x = 0;

pointArray[0].y = 0;

 

pointArray[1].x = renderWidth / 2;

pointArray[1].y = 0;

 

pointArray[2].x = renderWidth / 2;

pointArray[2].y = renderHeight / 2;

 

pointArray[3].x = 0;

pointArray[3].y = renderHeight / 2;

 

// The IVolumeSegmentationContext object can now be used for applying a segmentation.

segmentationContext.FreeHandCut(engine, pointArray, hdrcDefines.FHC_WHOLE_VOLUME, 1, renderWidth, renderHeight);

 

// Create an hdrcIVolumeSegmentation object.

hdrcIVolumeSegmentation segmentationContext;

segmentationContext = server.createVolumeSegmentation();

 

// Set the octree for the IVolumeSegmentationContext object. 

segmentationContext.initialize(octree);

 

// Set points to outline the upper left quadrant of the dataset as rendered by the

// hdrcRenderEngineContext object passed to the hdrcIVolumeSegmentation::FreeHandCut() method.

// The points for a Freehand Cut would ideally be gathered from a mouse click and drag operation.

// Consider using the Freehand Cut segmentation mouse adaptor.

int renderWidth = 1024;

int renderHeight = 1024;

 

POINT[] pointArray = new POINT[4];

pointArray[0].x = 0;

pointArray[0].y = 0;

 

pointArray[1].x = renderWidth / 2;

pointArray[1].y = 0;

 

pointArray[2].x = renderWidth / 2;

pointArray[2].y = renderHeight / 2;

 

pointArray[3].x = 0;

pointArray[3].y = renderHeight / 2;

 

// The IVolumeSegmentationContext object can now be used for applying a segmentation.

segmentationContext.FreeHandCut(engine, pointArray, hdrcDefines.__Fields.FHC_WHOLE_VOLUME, 1, renderWidth, renderHeight);