RGB Images

Images are 2D grids of pixel values. A pixel is a value that maps to a single display element on the output device (typically a monitor). Pixels values are color intensities. In this course, we will often assign values as a triplet of color components. This is similar to how our eyes function, with three different types of receptors attuned for different wavelenghts of light, so three color components can represent much of the color spectrum we can perceive.

RGB triplets are an easy way to represent colors using three values: a red intensity, a green intensity, and a blue intensity. RGB triplets are often stored as a triplet of bytes, so the red, green, and blue values can each range from [0, 255]. A value of 0 for the component means no intensity; all three components set to 0 will produce black. What do you think happens if all three components are set to 255?

R
G
B

<? if($online) quizText('What are the RGB values for light pink?',5); ?>

RGB values don't have to be stored as bytes. If each component is represented with a float type, the RGB values can have a very large range. In this course, you will use both byte and float types to store RGB values. Often float RGB values are clamped to the range [0.0, 1.0].

In the next assignment, you will create an image using RGB values. You will need to use the C++ vector class to do this. Vectors in C++ are growable arrays with generic types. A vector can only contain one type, which is set using templates when declaring the vector. For example, a vector<int> can contain ints and a vector<Object> can contain Objects. You can quickly insert at the end of a vector with the push_back() method. You can access elements with the at() method. You can get the vector's size with the size() method. There are many other useful methods, so check an API guide when using vectors.

Check your course repo. You should have a new Image assignment. In this assignment, you will create an RGB image that is saved as a PNG. Be prepared to manipulate C++ classes in the assignment!