This lab exercise un-assessed. You are suggested to complete Q1 and Q2 in Week 2, and Q3 in Week 3

The URL of this document is http://www.cs.ucl.ac.uk/staff/J.Kautz/teaching/2011/LW2011/
You should refer to the web page for the links to code and other documents.

Submission Process:

Don't submit it - it is unassessed. You can get feedback in lab sessions from the demonstrator.


Q1. A Gentle Introduction
Read through the first sections of the Java2D Tutorial Trail: Overview of the Java2D API and Getting Started with Graphics.

Copy the ShapesDemo2D applet from the Stroking and Filling Graphics Primitives section, compile and run it. Then modify this applet to display a set of 10 different shapes in a variety of different strokes and fills.


Q2. Colour Layers
Write an applet that loads a colour image from a file, and gives the user the option of selecting which of the colour channels to enable.

For example if you started with the following image:

your applet should look something like the following:

You can use any image you like, but make sure it isn't too big or you will wait a long time for you program to run (see note at end of this sheet about loading your own picture).

Hint1: The code Flip.java shows how to set up radio buttons and plot pixels within an image. Flip.html is the associated page with the relevant applet tags. You should download both, compile Flip.java and then run "appletviewer Flip.html". You also need the Mona Lisa image, which you need to put into the same directory.
Hint2: We used the function getRGB to retrieve a 24 bit integer from an image. Within those 24 bits, you can the 8 bit component for Red, Green and Blue, in the highest to lowest bytes respectively. You can just mask out the bits you don't want when making a new colour.


Q3. Gray Scale
Convert the image to a gray scale image, by taking the average of each red, green and blue pixels.



Jan Kautz, January 2012.