Creating a Surface Model

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.

  1. Create a new model.
  2. 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.
  3. 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.
    ‘SpineConnected.mhd’.
  4. Close the SimvtkIO library.
  5. 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.
  6. 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:

  7. Close the SimvtkImaging library.
  8. Open the SimvtkGraphics library, and drag the vtkMarchingCubes block into the model.
    Connect the vtkImageGaussianSmooth block to it.
  9. 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:
  10. Close the SimvtkGraphics library.
  11. 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:

  12. Double click the Constant block and enter 127 as a constant value. Set the
    sample time to inf.
  13. Connect the Constant block to the vtkMarchingCubes value port. Hold ctrl and click
    on the Constant block and then on the vtkMarchingCubes block.
  14. 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.
  15. Connect the vtkMarchingCubes block to the vtkDataSetMapper block.
  16. Double click the block and check the box self as output.
  17. 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.
  18. 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.

  19. Drag the vtkRenderer block from the vtkRendering library into the model.
  20. Double click the vtkRenderer block. Enter 1 in the Actor input field box and check
    the self as output box.
  21. Connect the vtkActor block to the vtkRenderer block.
  22. Drag the vtkRendererWindow block from the vtkRendering library into the model.
    This block creates the rendering window for the display.
  23. Double click the vtkRendererWindow block and input 1 in the Renderer inputs field.
    Check the Self as output box.
  24. Finally, drag the vtkRenderWindowInteractor block from the vtkRendering library
    into the model.
  25. Double click the block to change the parameters. Check the box: RenderWindow as
    input. And uncheck the box: Self as Output.
  26. Connect the vtkRendererWindow to the vtkRenderWindowInteractor.
  27. The final model should look like (click to enlarge):
  28. 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.
  29. Click the play button. You should see something like this:
  30. You can click on the spine and move it as you wish. This is performed by the
    vtkRenderWindowInteractor block.

> Continue onto the Multimodal Spine Registration tutorial.

Comments are closed.