Skip to content
Snippets Groups Projects
Select Git revision
  • main default protected
  • master
2 results

README.md

Blame
  • Assignment 3: Scattered Data / Colormaps

    In this assignment, we will look at one further technique to visualize scattered data. Furthermore, we will start to work with colormaps, one basic technique to visualize scalarfields. You should have finished the Data & Representation video by now and should have watched the first part of the Scalarfields video.

    Task 1: Reading image data and working with colormaps (1P)

    Another file type that we want to take a look at is image data. Image data represents a geometric structure that is a topological and geometrical regular array of points (e.g. voxel data and pixelmaps). In this exercise, we want to visualize the elevation of the world with a useful colormap. To get started, open the file ReadImageData.py and run it. You should see a flat plane with the landmass colored in in a single color

    .

    The important part of the code that you need to modify is the lookup table part:

        lut = vtk.vtkLookupTable()
        lut.SetNumberOfColors(2)
        lut.SetTableValue(0, (1, 0, 0, 1))
        lut.SetTableValue(1, (1, 1, 1, 1))

    As you can see, at the moment it is very basic and the elevation can not be represented accurately.

    Summary of Tasks: Implement a new transfer function that visualizes the elevation of the world map in a meaningful way. Save your submission code as task1.py.

    Task 2: Pre- and Post-Classification (1P)

    In this task we are looking at the differences of Pre- and Post-Classification. Open the file task2.py and check the code. It creates a lookup table / colormap that cycles through all colors of the visible spectrum, the rainbow colormap (note: this colormap is often used to quickly illustrate something and because many people have become used to it. However, there are many reasons why this colormap is problematic, many of which are explained in the lecture). Execute the code and take a look at your colormap and you will notice that not all colors in the colormap are present in the image:

    .

    This is a consequence of the fact that colors are interpolated, instead of actual scalar values.

    Making this slightly more precise, consider a function I(v1, v2, v3) that interpolates three values v1, v2, v3 at the vertices of a triangle to determine the color of a specific pixel. If C(v) is the colormap, then what you see on the screen ist the output of

    Cpixel = I(C(v1), C(v2), C(v3)).

    In other words, colors are mapped first, and are then interpolated. This is called pre-classification. A different approach - post-classification - first interpolates the scalar values and then maps them, i.e.

    Cpixel = C(I(v1, v2, v3)),

    to more accurately represent the interpolated dataset values:

    .

    This behavior can easily be switched on or off in VTK. Look through the code and find the part that switches between Pre- and Post-Classification. Additionally, for better seeing the differences, we want to switch between the two modes seamlessly.

    Summary of tasks: Find out which method is responsible for the different classification types. Additionally, implement a switch that cycles between Pre- and Post-Classification by pressing a button on your keyboard. Save your submission code as task2.py.

    Task 3: Scattered Data (2P)

    In this task we will have a look at the Delaunay triangulation. Therefore you have to implement a complete vtk pipeline which computes the Delaunay triangulation on the given dataset scattered.vtk by your own.

    The Delaunay triangulation is, as described in the lecture a method to trianulate a given set of points P in a plane, such that no point of P is inside the circumcircle of any triangle of the triangulation. Therefore, the Delaunay triangulation prevents sharp angles inside of the triangulation. This is a desirable property, especially in computer graphics and scientific visualization, because of rounding errors which can happen otherwise.

    Moreover, the Delaunay triangulation is deeply connected to the voronoi diagram. The triangulation is the dual graph of a voronoi diagram. The dual graph is the connection of the cell middle points with the middle points of their neighboring cells. In the same way, you can get the voronoi cells from the triangulating lines. An example can be seen here:

    .

    To complete this task successfully, you can have a look at the scripts of the old exercises and follow these hints:

    • start the pipeline with a reader
    • add the delaunay filter to your pipeline
    • render the output of the delaunay filter as wireframe tubes (add maper and actor)
    • add an additional mapper and actor to create the points
    • complete your pipeline with a renderer, a renderwindow and lastly an interactor

    Your result should look like this:

    .

    Summary of Tasks: Create a complete pipeline which renders the Delaunay Triangulation of the given dataset. Save your code as task3.py.