Lecture 4

VTK

(includes text and images from the 3rd edition of the VTK User's Guide)


Four views of the Earth


So now lets get into some specifics ...

VTK - what is it, what does it do, and why are we talking about it.

There are quite a few packages that can do visualization (scientific, information, medical, etc) out there. VTK is the one that we use in the lab. Its available for free for all major computer platforms, and there are a lot of vtk examples available on the web, so its a good package to use in this course. The basic visualization concepts remain the same though the terminology and capabilities may change from package to package.


vtk can be obtained from http://www.vtk.org/

There is an installer for windows on the main vtk page and some notes from the previous class on the 526 vtk page. Here is a nice page with hints for installing on OS-X - http://www.macresearch.org/installing_vtk_on_mac_os_x though I would also set BUILD_EXAMPLES:BOOL=ON and VTK_WRAP_TCL:BOOL=ON

You can use vtk with C++, Tcl, Python, and Java.

VTK comes with an example directory and one of the simplest ways to test your vtk install is to try running the Tcl examples. For example you can cd to VTK/Examples/Medical/tcl and then vtk Medical1.tcl

To compile the cxx examples you should be able to go into the cxx directory and type "cmake ." and then "make". On my macbook pro I needed to edit the CMakeCache.txt file to set VTK_DIR:PATH=/usr/local/VTKBuild/

Then you can run medical example 1 in VTK/Examples/Medical/Cxx with ./Medical1 /usr/local/vtkData/DATA/headsq/quarter

To make a new C project (adapted from https://visualization.hpc.mil/wiki/VTK_in_CPP)

1. Create a file called CMakeLists.txt in the source directory, containing the following, where ProjectName, Binary and SourceFile.cxx are replaced with your names.


PROJECT (ProjectName)

INCLUDE (${CMAKE_ROOT}/Modules/FindVTK.cmake)
IF (USE_VTK_FILE)
  INCLUDE(${USE_VTK_FILE})
ENDIF (USE_VTK_FILE)

ADD_EXECUTABLE(Binary SourceFile.cxx)
TARGET_LINK_LIBRARIES(Binary vtkRendering vtkIO)

2. type "cmake ." to create the Makefile. It may complain about VTK_DIR so then just edit CMakeCache.txt

3.  Create a sample cxx file, or copy one form the examples directory line Cone.cxx

3. make

4. run

5. make changes


Visualization Pipeline/Network (Chap 4 vtk)

Pretty much all of these packages have a pipeline architecture.

Data Objects - information plus methods to create, access, delete information

Process Objects - Operate on input data to generate output data


VTK has a demand driven pipeline archictecture

These various software packages work in different ways:

Explicit Execution

Implicit Execution


Memory Models


So, lets get a little more specific with an example of how we can use the vtk pipeline to go from data to a visualization.

Here is a brief demonstration of ParaView (which is built on top of vtk) with the Visible Woman dataset

From the virual human web page (http://www.nlm.nih.gov/research/visible/) "The Visible Human Male data set consists of MRI, CT and anatomical images. Axial MRI images of the head and neck and longitudinal sections of the rest of the body were obtained at 4 mm intervals. The MRI images are 256 pixel by 256 pixel resolution. Each pixel having 12 bits of grey tone resolution. The CT data consists of axial CT scans of the entire body taken at 1 mm intervals at a resolution of 512 pixels by 512 pixels with each pixel made up of 12 bits of grey tone. The approximately 7.5 megabyte axial anatomical images are 2048 pixels by 1216 pixels, with each pixel defined by 24 bits of color. The anatomical cross-sections are at 1 mm intervals to coincide with the CT axial images. There are 1871 cross-sections for both CT and anatomy. The complete male data set, 15 gigabytes in size, was made publicly available in November, 1994.

The Visible Human Female data set, released in November, 1995, has the same characteristics as the The Visible Human Male with one exception, the axial anatomical images were obtained at 0.33 mm intervals. This resulted in 5,189 anatomical images, and a data set of about 40 gigabytes. Spacing in the "Z" direction was reduced to 0.33mm in order to match the 0.33mm pixel sizing in the "X-Y" plane, thus enabling developers interested in three-dimensional reconstructions to work with cubic voxels."

(and let us remember that in 1995 personal computers were running at 200Mhz, with 16MB of RAM and 1 GB hard drives. Now the visible woman dataset fits on an iPod)

Here are some small jpeg images of a very few of the slices of the visible woman.

and here is ParaView viewing the 75MB version of the Visible Woman dataset. This version of the dataset is made up of 577 slices, 1 slide every 3mm, where each slice is 256 x 256 16-bit values. Once the data is loaded in we can set up two contours - one for the skin and one for the bones.

In paraview 3.4.0 you can read in the visible woman data as raw data then set:

and then create 2 contours - one transparent at 500 for skin, and one opaque at 1200 for bone, and you will see something similar to this.



Discrete nature of data (Chap 5 vtk)

(possibly) continuous data represented by discrete sampling

Interpolation

A familiar example is a weather map showing the current temperature across the state or country, but the data is only sampled at certain scattered stations which is then interpolated. You can click on the map to gain access to the data files and to see how the data is interpolated across the state.

 http://www.sws.uiuc.edu/warm/icnstationmap.asp

Here is another nice example of interpolating winds from the San Francisco Bay area

http://sfports.wr.usgs.gov/wind

In particular, click on the 'Observed Wind over S.F. Bay' link to see the observed data, then go back to the modelled data. Also click on the streakline version to see the modelled data in motion.


Structured or Unstructured Data


Dimension (number of independent variables)


Abstract Dataset



Cells specify topology while points specify geometry

Types of Datasets (each of these has their own class in vtk)


Cell

Linear Cells - linear or constant interpolation functions

Nonlinear Cells

more accurate rate interpolation functions
model curved geometry better

linear easily converted to linear graphics primitives. nonlinear (except maybe for NURBS) must first be converted (tesselated) into linear form


Attribute Data - each Cell has 0 or more pieces of attribute data associated with it.


Some More examples with ParaView

canyon_elev.raw (which can be found at ftp.evl.uic.edu in pub/INcoming/andy) contains a height map of the grand canyon as a 1024x512 greyscale image.

ParaView can load this image by setting:
data type to 'unsigned char'
File Dimensionality to 2,
extents as 0-1023, 0-511

This will bring up a colour image. You can use the information tab to bring up information on the dataset. In this case that the values in the image range from 68 to 242.

 then you can use the Contour filter to define a series of contours. As the scalar values in the file range from 68 to 242 you could set up a et of separate contours at 125, 150, and 175 for example. These contours would initially all be in the same plane, but you can also translate them in Z.



You can also take the data and extract a surface from it. Once you have the surface you can warp it onto 3D. With paraview 3 need to first tetrahedralize the data and then apply the warp (scalar).

A dataset that comes with the vtk cdrom in VTKData/Data is ironProt.vtk. Since it is a .vtk file the header of this file contains the information that vtk needs to properly load the data in. Like the visible woman dataset we can use the contour tool to generate contours. In the image below there is a contour at 50 shown as wireframe, another contour at 200 shown as a surface, and a slice showing the data values in a plane.




Coming Next Time

Fundamental Algorithms (1 of 2)


last revision 1/22/09