SciVis 2013 Project 1 Tips


Basic program structure

Summary of the basic structure of the program you write for the univariate colormapping:
  1. Read in the (16-bit) gray-scale data image
  2. Read in the colormap (a text file)
  3. Create an array for the output (8-bit) RGB image
  4. For each pixel of input image:
     
    1. Get the input data value
    2. Determine where that value falls in the sequence of colormap control points (one per line)
    3. Perform a linearly interpolation between the control points to find the output RGB color
    4. Set the color in the corresponding pixel of the output RGB image.
  5. Save the output RGB image as an 8-bit PNG
The program structure for the bivariate case is similar, but

Example code

Here are some simple Python/Numpy programs that may contain elements of functionality that you'll need for the project. Feel free to use the scivis-2013 mailing list to share information about what it took for you to get these programs working in your environment. As we learn more, we'll post updates here.

Linear Interpolation of RGB control points

The assignment asks you to create and apply univariate colormaps that are saved as text files, and to map values through RGB colors by linear interpolation between control points. Here's an illustration of linearly interpolating an output value from y0 to y1 as in input value changes from x0 to x1:
For example, consider the example colormap from the assignment:
0      0   0   0
21845  255 0   0
43690  255 255 0
65535  255 255 255
Interpolating colors between the second control point at x0=21845 and the third control point at x1=43690 will be needed for any input data values between 21845 and 43690. Between these two control points, the green channel is varying, so in the formula above, y0=0 and y1=255.

Univariate map demo

Here is the data/synth/ramp16.png dataset from the scivis-2013 repository:
The foo-map.txt colormap is:
0 0 0 0
10000 255 0 0
30000 0 255 0
50000 0 0 255
65535  255 255 255
This colormap, by the way, is not going to be useful for any of the tasks in Project 1.
Here is the result of applying that colormap to the ramp image:
Your program should produce the same result.

Bivariate map demo

The two 16-bit grayscale source images bivarA.png and bivarB.png
Think of bivarA.png and bivarB.png as stand-ins for the Democratic D-logden.png and Republican R-logden.png voting density images, respectively (in scivis-2013/data/vote). The structure of these image is much simpler; you may want to make and apply univariate maps to these images to make sure you see what's happening inside these images.

A simple bivariate colormap is maggrn-map.png:

Like the bivariate maps you will create and use, this is an 8-bit RGB image. Make sure you see (either by eye or by a program) that the red and blue channels are increasing linearly to the right, and the green channel is increasing linearly to the bottom.

The result of applying the bivariate map to the two images, maggrn-out.png:

The lower right circular patch is only gray (despite a possible afterimage illusion). Make sure you see this, and understand why. Your program should produce the same result.

Second bivariate map demo

This uses the same bivarA.png and bivarB.png source images as above. The bivariate map phnx-map.png
produces the phnx-out.png image:
This is a mostly silly example, since you won't be putting pictures inside your colormap, but it may be useful for debugging. The source of the yellow background also deserves consideration.