CMSC 23710/33710, Scientific Visualization, Autumn 2010, Project 2

Due: Monday Oct. 18 at 8:00pm

  • See Help page
  • The text in the Fast and Slow axes in PNG section of the Project 2 help page had a potentially confusing error, which is now fixed. The picture is correct.
  • The elev-myst.png is oriented with respect to the compass directions the same as the elev-mich.png Michigan image: north is upward, east is rightward.
  • For conversions from RGB to HSL or HSV, you can read the rather lengthy wikipedia page; you can also look at functions dyeHSLtoRGB and dyeRGBtoHSL from Teem's convertDye.c. Its C code, but you should be able to figure out what is going on. AIR_MAX and AIR_MIN are just max() and min() functions.
  • Another way to find RGB values for particular colors of interest is to use the color picker that may come with your operating system. On a Mac, Shift-Command-C will open the color picker in standard apps like Preview and Mail (thought not Finder)
  • The Gamma FAQ and Color FAQ are long but informative. Note that the Color FAQ uses "lightness" differently than what we've discussed in class.
  • For this assignment, I want you to write your own code to perform the colormapping. Even if you find other tools that help you test your colormap, you should be able to create a new RGB image array, fill it colors values computed from functions you write, and then save it out as a PNG. I'll be looking for code that does this when grading.
  • You can add the colorbar to the image by adding a margin on one side of the image that includes a linear ramp through the range of values. Or just make the colorbar as a separate image, and then put them together in your writeup.
  • If you have your own computer to use and want to use Python, you may want to try the Enthought Python Distribution (academic version). Its a large piece of software, since its a self-contained python distribution with a lot of additional packages (including Python Image Library).
  • When, for 1(d) and 1(e), you create new images with 1:1 aspect ratio from elev-myst.png and ct-feet.png, I ask that you write your own simple function for this, rather than using a pre-existing image resampler. The simplest way to do this is to upsample (add more samples) along the axis that has smaller spacing, using nearest-neighbor interpolation.
  • The linux computers in the Regenstein "MacLab" are one place that you can work on this assignment. They include these hosts:
    altair, ankaa, antares, arcturus, avior, bellatrix, betelgeuse, canopus, capella, deneb dubhe, hadar, mimosa, naos, polaris procyon, rastaban, saiph, sirius, ursa
    which you can reach by ssh <CNetID>@<host>.cs.uchicago.edu. These hosts have versions of Python, Numpy, and PIL that are compatible with the example python code provided.

The goal of this project is to develop univariate and bivariate colormaps for real data, and to understand specifications of the layout of 2D raster data.

The data input and colormap output of your programs will be images in PNG format, so there is no required interactive display element for this project. You should use whatever image viewer you're most comfortable with for looking at the PNG images, and you should use whatever language you're most comfortable with for implementing this project.

You will need to prepare a write-up that integrates text and images, so that you can present images and then describe what you did to create them. Submit this as a PDF file, or as a .tgz or .zip file of a self-contained web page (not requiring any files online). Use whatever helps you be efficient: LaTeX, Word, Pages, OpenOffice, etc.

Note: The programs you write have to be included in your write-up, either by including their source in your description, or as an appendix. I need to see your code to verify that its capable of doing what you claim.

Your grade will be based on the design of your implementation, the quality of the visualizations it creates, and the apparent level of understanding of the required readings. Note that there are some extra things to be completed by students in CMSC 33710.

Input Datasets

The input datasets are 16-bit gray-scale images. Unless otherwise stated, the aspect ratio of the samples in the images is 1-to-1. Please download all the datasets: data.tgz. Note that for each image, there is a downsampled version ("...-sml.png") that you can use for faster testing/debugging.

Colormaps you create

The univariate colormaps you create should be in the form of text files that list a sequence of control points between which RGB colors are interpolated linearly. Each line of the colormap text file specifies one control point and should be of the form: "val R G B". That is, "val" increases monotonically with each line, and identifies the 16-bit image value to receive color R G B. For example:
0      0   0   0
32767  255 0   0
43690  255 255 0
65535  255 255 255
The bivariate colormaps you create will be 256x256 8-bit RGB images that maps the first ("A") data value to the faster (non-color) axis, and the second ("B") data value the slower axis. On each axis, the image value is divided by 256 to get the colormap index.

You will have to write functions (in the language of your choice) that read in the image (or two images for the bivariate case), reads in the colormap, applies it to the image(s), and saves out the resulting 8-bit RGB image in PNG format.

What to do and write up

1) Defining how pixels are drawn on screen, and getting images to 1:1 aspect ratio

Let B = {x, y} be a basis for the X-Y space of the 2-D computer screen, aligned according to the convention from high-school geometry class: with unit-length x pointing to the right, and unit-length y pointing upwards. Disregard translation within the screen. Consider the raster image data accessed as a 2-D array via v[i,j] where i is index into the faster axis, and j is the index into the slower axis. Let p(i,j) be the location, on the 2-D computer screen, where pixel v[i,j] is drawn, following the conventions of image display in a web browser (i.e. in the same way elev-mich.png is displayed here).

Note: Your chosen language may not order indices [faster,slower]. Also, if you use an environment like Matlab or Numpy for doing this work, you may have to write a display routine to mimic the behavior of a web browser for displaying images (and this may involve flips or tranposes). In any case, though, that's irrelevant for what you write up here.

  1. For an image where the spacing on screen along both axes is 1.0, find matrix M in
    When specifying M in text use the ordering: "{{M11, M12}, {M21, M22}}".
  2. Find an M that will layout the ct-feet.png image with the correct aspect ratio.
  3. Find an M that will layout the elev-myst.png image with the correct aspect ratio (this will involve comparing to a world map, don't worry about finding more than two significant digits). You may want to finish part 2(c) first.
  4. How would you transform ct-feet.png to make a new image (with different array shape) so that its M was the same as in the first part? Choose a simple way to apply this transform to the image, and use the transformed image for the colormap experiments below.
  5. Repeat #4 (above) for the elev-myst.png data (you'll lose points if the images in your write-up don't have the right aspect ratio)

2) Univariate elevation data

For this part and the next part (Univariate CT data) you'll create colormaps, and document them in four ways:
  1. Show (with correct aspect ratio) the results of applying the colormap to the image data
  2. Include a color legend strip alongside (or underneath) your colormapped data, to document what the colormap is
  3. List the text file colormap itself
  4. Describe how you arrived at this colormap, and why this is a good colormap, according to the principles described in the readings.

For the univariate elevation data elev-mich.png and your version of elev-myst.png with 1:1 aspect ratio, you should create and document three colormaps:

  1. A colormap that manages to both show the over-all form of the data (both elevation datasets), and to assist accurately reading off values at particular locations.
  2. A "double-ended" colormap that emphasizes the value (you'll have to find it) for the elevation of the fresh water level for elev-mich.png, so that the coast-line shape is clearly recognizable, and which shows the elevations patterns above and below that level, while making the difference between land and water obvious.
  3. Another "double-ended" colormap that emphasizes the value (you'll have to find it) for the elevation of sea-level in elev-myst.png, and which achieves the same goals as the one above.

3) Univariate CT data

From the version of ct-feet.png you created to have 1:1 aspect ratio, create and document (as above) two colormaps:
  1. Try to display the various structures apparent at different brightness levels with a smoothly varying map, making sure not to overlook the ambiguous structures at the lowest image levels.
  2. Try to "segment" the image, so that different materials or tissues are indicated with uniform areas of mutually distinct colors (this will require sharp transitions in your colormap). At very least you should visually distinguish background, soft tissue, and bone, but if you look carefully you can find more material distinctions. Also, answer this: were you able to find a map that emphasized all the bones uniformly? Why or why not?
Extra part for students in 33710:
  1. Compute and plot a histogram (of at least 256 bins) of the values in the image, in such a way so that the peaks in the histogram don't prevent seeing the shape of distribution away from the peaks. Describe (in one sentence) how you did this.
  2. Describe how you might use (or did use) such a histogram to guide the design of your answer to 3(b).

4) Bivariate MRI data

To document your colormaps for the bivariate data stored in mri-A.png ("A") and mri-B.png ("B"):
  1. Show the results of applying the colormap to the image data
  2. Show the colormap itself as a square color image (remember note above about how the map is specified)
  3. Describe in detail how you designed at this colormap, and why this is a good colormap, according to the principles described in the readings. For the bivariate maps this can be tricky.
Don't worry about learning neuroanatomy to answer this part; just describe the shapes you see thanks to your colormaps.

Design three colormaps, one each for the following goals:

  1. Emphasize the anatomy visible in image A, and slightly indicate the extra information given by B.
  2. The reverse: emphasize the anatomy visible in B, and slightly indicate the extra information given by A.
  3. Show two things simultaneously and with equal visual clarity: where A and B agree with each other, and what structures are highlighed by the difference between A and B.
Extra part for students in 33710:
  1. Compute a 256x256 square image of a joint histogram of the values in image A and B, and show an image of this histogram in your write up. You'll need to either annotate the image, or describe in text, which axis is for A vs B, and which direction are for increasing values of each.
  2. Show the colormap you used to display the bin values in the joint histogram, that allowed you to see its internal structure.
  3. Based on the guidance from this joint histogram image, create a bivariate colormap that, like the foot image in part 3(b), attempts to segment the image into distinct materials, uniformly colored. Document this colormap in the same way you documented 4(a), 4(b) and 4(c).