Class 5: RGB Colors
Held: Monday, 30 January 2017
We consider the basic use of colors in image making and explore one of the common digital representations of colors.
Preliminaries
Overview
- Color palettes
- RGB colors
- Representing RGB colors as integers
Related Pages
-
Reading: Design and Color
-
Reading: RGB Colors
-
Lab: RGB Colors
Updates
News / Etc.
- Quiz 1 returned (by mentors).
- HW 1 returned (via email).
- New partners! Grab a card, find a computer, introduce yourself.
- I apologize for the confusion on the self-checks for colors.
Reminders
- The CS department maintains a mailing list of events and opportunities (and other things of potential interest).
- Starting this week, we will have mentor sessions on Wednesday and Thursday evenings from 8:00-9:00 p.m. Wednesdays will be more Q&A, Thursdays will include sample quizzes.
- We have tutors available Sunday through Thursday evening from 7-10 p.m. in Science 3813/15.
Upcoming Work
- Assignment 2. Due Tuesday!
- Reading: Transforming RGB Colors.
- Lab writeup: Exercise 7. Due Wednesday before class.
Extra credit (Academic/Artistic)
- CS Table, Tuesday, noon, middle PDR: Planning for the semester.
- Thursday extras, Thursday, 4:15 p.m., Science 3821: LaTeX
Extra credit (Peer)
- Swim meet this coming weekend.
- Ritalin Test Squad Improv Troupe is looking for new members and will be holding try outs this weekend. Auditions will be on Saturday Feb 4th, 1-3 pm in The Wall (Bucksbaum 152).
Good things to do
- Care for the people around you.
Colors
- Many ways to represent colors.
- Goals: Unambiguous, fast to process, compact
- Color names are
- Ambiguous
- Slow to process
- Long
- Whoops!
RGB Colors
- The most common internal representation of colors on computers.
- We think of a color as the combination of three
primaries: red, green, and blue.
- These are the primaries for the so-called additive colors
- You are probably used to the primaries being red, yellow, and blue, but those are the subtractive colors
- On computers, we represent each component as a number between 0 and 255, inclusive.
- It turns out that you can shove four numbers, each between 0 and 255,
into the internal representation of an integer.
- So, the red, green, and blue components are three of those numbers.
- What’s the forth? In multi-layer images, it’s the alpha channel.
- We use
rgb-newto create these colors. - We use
rgb-red,rgb-green, andrgb-blueto extract the corresponding components.
Those Weird Color Numbers
- We’re representing colors as three integers, each in the range [0..255].
- Yet when we ask MediaScript for a color, we tend to get a single integer which is rarely in that range?
- What’s going on?
- Well, most computers have different techniques for representing really
small integers (particularly integers in the range 0 to 255, inclusive) and
standard-length integers. We’re using the smaller representation,
but shoving three of those into a standard-length integer.
- We use that representation because it makes everything faster.
- Even those of us who designed and implemented that representation can’t read the values presented in that representation.
- The formula for computing those numbers:
- 256256red + 256*green + blue