Files needed to complete this tutorial: SpineConnected.mhd
Creating a Surface Model Using Marching Cubes and VTK Libraries
This tutorial crates a surface model of the image produced from the “Segmenting a 3D-Image”
tutorial. The surface model is created using blocks from the SimVTK libraries. To create
a surface model, certain blocks are needed. You will need a reader, filter, mapper,
actor, renderer and a display block. So make sure your Matlab directory path is set to
the SimVTK library directory.
- Create a new model.
Open the library SimvtkIO. Drag the vtkMetaImageReader into the created model. This
block takes care of reading in the input file and converting it from ITK information to
VTK information. This is necessary since the input image was produced using ITK blocks.
Double click the vtkMetaImageReader and leave everything to the default values
except for the FileName parameter. Click on the arrow on the right of the field
and choose ‘As Parameter’. This will create an input field with the name
FileName value. In that field enter the name of the input file. Ex.
- Close the SimvtkIO library.
Open the SimvtkImaging library. Drag the vtkImageGaussianSmooth block into the
model. Connect the vtkMetaImageReader to it. This block is needed to smooth the
image and create a better display.
Double click the vtkImageGaussianSmooth to enter the following parameters:
- Dimensionality value: 3
- RadiusFactor value: 5
- StandardDeviation value: 2
When complete, your dialog box should look similar to:
- Close the SimvtkImaging library.
Open the SimvtkGraphics library, and drag the vtkMarchingCubes block into the model.
Connect the vtkImageGaussianSmooth block to it.
Double click the vtkMarchingCubes block to change the Value parameter. Click on the
arrow on the right of the parameter field and select As Input from the pull down
menu. In the Value Number Wanted field enter 1. This will create another input called
value to the block. It should look like this:
- Close the SimvtkGraphics library.
In the Simulink Library Browser Double click the Commonly Used Blocks icon
that can be found on the right hand side of the window. Then select the constant
block and drag it into your model.
Examples are below:
- Double click the Constant block and enter 127 as a constant value. Set the
sample time to inf.
Connect the Constant block to the vtkMarchingCubes value port. Hold ctrl and click
on the Constant block and then on the vtkMarchingCubes block.
Open the vtkRendering library and drag the vtkDataSetMapper to the model. The mapper
maps data sets to graphic primitives and acts as an interface with the graphics model.
- Connect the vtkMarchingCubes block to the vtkDataSetMapper block.
- Double click the block and check the box self as output.
Next, drag the vtkActor block from the vtkRendering library into the model. The
actor creates a scene with objects in it, in this case the spine. The object is
viewed by a virtual camera and lights.
Check the boxes Mapper as input and Self as output. Leave everything else as is.
Connect the vtkDataSetMapper output (self port) to the vtkActor mapper port.
- Drag the vtkRenderer block from the vtkRendering library into the model.
Double click the vtkRenderer block. Enter 1 in the Actor input field box and check
the self as output box.
- Connect the vtkActor block to the vtkRenderer block.
Drag the vtkRendererWindow block from the vtkRendering library into the model.
This block creates the rendering window for the display.
Double click the vtkRendererWindow block and input 1 in the Renderer inputs field.
Check the Self as output box.
Finally, drag the vtkRenderWindowInteractor block from the vtkRendering library
into the model.
Double click the block to change the parameters. Check the box: RenderWindow as
input. And uncheck the box: Self as Output.
- Connect the vtkRendererWindow to the vtkRenderWindowInteractor.
- The final model should look like (click to enlarge):
In order for the window to stay open until you wish to close the model. Change the
field next to the play button to: inf.
- Click the play button. You should see something like this:
You can click on the spine and move it as you wish. This is performed by the
> Continue onto the Multimodal Spine Registration tutorial.