Held: Friday, 4 September 2015
Back to Outline 04 - Computing with Symbols and Numbers.
On to Outline 06 - Transforming Colors.
Summary
We consider the basic use of colors in image making and explore one of
the common digital representations of colors.
Related Pages
Overview
- Color palettes.
- RGB colors.
- Representing RGB colors as integers.
Administrivia
- No attendance today (the quizzes suffice).
- Notes from the Thursday 10am review sessions get posted to the eboards,
provided someone shows up for the review sessions.
- Note: If I haven't responded to an email within 24 hours, I've probably
lost it in my inbox. Try resending (I will not take offense).
Before today's lab (and perhaps before every lab you do for the next
week or so), please type the following command in the terminal window.
/home/rebelsky/bin/csc151-update
Friday PSA.
Upcoming Work
- One reading for Monday:
Transforming RGB Colors
- Assignment 2 due Tuesday. Your
assignment partner is the person (or people) at the same computer
as you.
- I will take questions on the assignment at the start of class
today and Monday.
- Lab writeup (due before class Tuesday)
Extra Credit Opportunities
Academic
- Tuesday, noon, CS Table, JRC 224C. Topic TBD.
Peer Support
- Pals of PALS, pals@grinnell.edu, normally Saturday at 1:30
and Mondays at 4:45. Requires sign up in advance.
- Pun Club, Saturdays, 4pm, Way over Younker
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-new to create these colors.
- We use
rgb-red, rgb-green, and
rgb-blue to 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