Computer Laboratory

Computer Graphics and Image Processing (Michaelmas 2016)

The supervision work for this course consists of a mixture of written and practical exercises.
Please make sure that you attempt the practical exercise first, and feel free to let me know if you get stuck somehwere.

Please hand in your work by 17:00 on the day before the supervision!

These exercises are heavily based on the official course material, the new IA practical classes by Rafal Mantiuk and supervision exercises set by Erroll Wood.

Supervision 1

Practical exercise

This exercise invites you to write a simple ray tracer capable of handling sphere objects and Phong reflection.
The new IA practical classes provide an excellent starting point

Alternatively, if you feel more ambitious, you are encouraged to implement your own raytracer from scratch.

Warmup questions

  1. Suppose you are designing a user interface for someone who is colour blind. Describe how some user interface of your choice should be suitably modified.
  2. Why is it better to look at faint stars and comets slightly off-centre rather than looking directly at them?
  3. In a CAD system using blue lines on a black background would be a poor choice for the interface colours for designing an object. Why is this?
  4. In New Zealand, warning road signs are black on yellow, it being alleged that this is easier to see than black on white. Why might this be true?
  5. What are the ray parameters of the intersection points between ray (1,1,1) + t(−1,−1,−1) and the sphere centered at the origin with radius 1? [FCG p89]

Longer questions

  1. Calculate the ultimate monitor resolution (i.e. colour pixels/inch) beyond which better resolution will be unnecessary.
  2. Explain what BRDF is, and what simplifications we make when calculating shading.
  3. What information would you need to store to define a ray-tracing viewing volume (hint: clipping planes?)?

Supervision 2

Practical exercise

This exerciese invites you to extend the simple ray tracer to handle planes, multiple lights, shadows and reflections.
As before, you are welcome to use the IA practical class material, or implement your own code from scratch

Warmup questions

  1. Explain why we use homogeneous co-ordinates.
  2. Briefly describe the Phong reflection model.
  3. We use a lot of triangles to approximate stuff in computer graphics. Why are they good? Why are they bad? Can you think of any alternatives?
  4. What is OpenGL? Why is it an API?

Longer questions

  1. 2010 Paper 4 Question 4
  2. What is an OpenGL shader? Which types of shaders are the most common?
  3. What are the OpenGL Model, View, and Projection matrices?
  4. Put the the following stages of the OpenGL rendering pipeline in the correct order. Very briefly explain what each stage does.
    • Rasterization
    • Vertex shader
    • Fragment shader
    • Primitive setup
    • Clipping

Supervision 3

Practical exercise

In this exercise you will render a 3D terrain with OpenGL using a height map.
Unless you have some experience with OpenGL, I highly recommend the IA ticks as a starting point.

Warmup Questions

  1. Briefly describe the two line drawing algorithms from the lectures
  2. Explain the Midpoint circle algorithm

Longer Questions

  1. Derive the conditions necessary for two Bézier curves to join with
    • just C0-continuity;
    • C1-continuity
    • C2-continuity
  2. Draw and explain two different scenes which have the same projection as seen by the viewer. What other cues can you give so that the viewer can distinguish the depth information?
  3. 2008 Paper6 Question 5
  4. For a cylinder of radius 2, with endpoints (1,2,3) and (2,4,5), show how to calculate:
    • an axis-aligned bound box (AABB)
    • a bounding sphere
  5. Define and then compare and contrast the following methods of specifying rotation in 3D. (You will need to look these up )
    • Euler Angles
    • Quaternions

Supervision 4

Practical exercise

Write a Java program which is able to apply the following filters and dithers to an image on disk

  • At least three from Basic, Gaussian 3x3 and 5x5 Blur, Prewitt and Sobel filters, Roberts filters
  • Median filter
  • At least one from: Halftone 3x3 and 4x4 (i.e. convert a colour image to black and white), Ordered Dither 4x4
  • Floyd Steinberg error diffusion

For Example: bash$ java -jar crsid.jar Gaussian3x3 input.png output.png should apply the Gaussian 3x3 blur filter to the input image and write the result into the output image. Running the program with no arguments should print a usage statement and a list of supported filters and dithers.

Manipulating pixel values in the BufferedImage is perfectly acceptable, however, if you feel more ambitious, you are encouraged to write the Image Processing code as GLSL fragment shaders. To do so, you will need to look up glActiveTexture, glBindTexture and glUniform1i, then render a textured rectangle on screen with the appropriate fragment shader.


  • 2009 Paper4 Question 6
  • 2008 Paper3 Question 4
  • Explain the use of each of the following colour spaces:
    • RGB
    • XYZ
    • HLS
    • Luv
  • Explain the difference between additive colour (RGB) and subtractive colour (CMY). Where is each used and why is it used there?