# Class 12: Raster Graphics and RGB Colors

Back to Spot Lists, Continued. On to Documenting Programs and Procedures.

This outline is also available in PDF.

Held: Monday, 11 February 2008

Summary: We consider the basics of raster graphics, a common technique for describing and representing images. We also consider RGB colors, one of the most common mechanisms for representing colors digitally.

Related Pages:

Notes:

• Quiz 2 returned. It's clear that many of you had difficulty with `mod`, so we'll talk about it a bit more.
• Are there questions on Exam 1?
• EC for attending this Thursday's Thursday Extra. 4:30 in Science 3821. Cable Thompson is speaking about his summer work.

Overview:

• Representing images, revisited.
• Pixels and colors: The basics.
• RGB colors.

Raster Grapics

• Yet another model of images.
• This one corresponds closely to how computers actually represent images.
• The image is a grid of colors.
• Rows and columns numbered starting at 0
• Rows numbered from top to bottom
• Columns number from left to right
• It's painful to have to set individual pixels, but it can be useful.

Colors

• Many ways to represent colors, too.
• Goals: Unambiguous, fast to process, compact
• The color names we've been using 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.

Back to Spot Lists, Continued. On to Documenting Programs and Procedures.

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Tue Apr 15 23:11:35 2008.
The source to the document was last modified on Thu Jan 17 16:44:18 2008.
This document may be found at `http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2008S/Outlines/outline.12.html`.

You may wish to validate this document's HTML ; ;

Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright © 2007-8 Janet Davis, Matthew Kluber, and Samuel A. Rebelsky. (Selected materials copyright by John David Stone and Henry Walker and used by permission.) This material is based upon work partially supported by the National Science Foundation under Grant No. CCLI-0633090. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation. This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License. To view a copy of this license, visit `http://creativecommons.org/licenses/by-nc/2.5/` or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.