Sheet 0: Color Conversion
General
Please note that you must upload the exercises before the submission deadline on Moodle. Exercises that are not submitted on time will be graded with 0 points. Submissions that do not compile also receive 0 points. Sample inputs and outputs are often available, which you can use to test your programs. Submissions that do not process these samples correctly will receive only few points. Please do not add additional output to your program unless explicitly requested. Submit your solution as a single zip file named using the following scheme: a1_Firstname_Lastname.zip.
Compress all files you have modified into one archive. If the exercises include theoretical parts, please also include a text file, scan, or photo with your answers.
For example: A complete first assignment consists of a zip file containing only the main.cpp file.
Setting Up the Development Environment
To set up your environment for the exercises, please follow these instructions:
For Windows users:
Download the latest Visual Studio IDE (not Visual Studio Code).
Select "Desktop development with C++" during installation.
For Mac users:
Install Xcode and additionally install GLEW and GLFW.
For Linux users:
Install the required tools using:
sudo apt install build-essential libglew-dev libglfw3-dev
Download the Framework and Exercise Code
The code framework to start the exercises is provided via a GitHub repository at github. On Linux or macOS systems, you can open a terminal window and type:
git clone https://github.com/JensDerKrueger/CGM
You can read the documentation of the framework here.
Exercise: HSV to RGB Conversion (15 points)
Familiarize yourself with the methods init and mouseMove.
The overridden init method iterates over a pixel image with a given width and height.
The pixels of the image are colored using the function convertPosFromHSVToRGB.
The method image.setNormalizedValue expects RGB values in the range [0, 1].
Currently, a color value is returned where the red value corresponds to the x-coordinate,
the green value to the y-coordinate, and blue = 1. See the image below for reference.
Initial display.
While the program is running, the mouseMove method prints a debug message to the console
that displays both the HSV value and the RGB value of the pixel currently under the mouse pointer.
The debug output uses the function convertPosFromHSVToRGB to compute the RGB value based on the expected HSV color.
For the HSV output, it is expected that the horizontal mouse position corresponds to the hue (H) * 360
and the vertical position corresponds to the saturation (S). This is not correctly implemented yet.
Solution
Your task: Complete the code in convertPosFromHSVToRGB so that the given x and y position parameters are interpreted as hue (H) and saturation (S).
Use 1.0 as the value (V). Then convert the color from HSV to RGB color space and return it as a Vec3.
Refer to the image above to verify correctness.
Exercise: Uses of HSV (2 points)
What is the advantage of using HSV or HSL representations instead of RGB? And in what typical applications are these color models used?