Class 6: Transforming RGB Colors
Held: Sunday, 31 January 2016
We explore common ways in which to transform colors.
Preliminaries
Overview
- {“Review”=>”Color basics”}
- Integer-encoded RGB colors
- Computing new colors from old
- An example
Related Pages
-
Reading: Transforming RGB Colors
Updates
News / Etc.
- Continue partners!
- I still have some HW1s left to grade (and two quizzes). Apologies.
- I hope to get through preliminaries quickly so that you have most of class for lab.
- You should have received a message from Stacy Turley requesting note-taking for this class. It looks like many of you are taking very nice notes (better than I do). I hope that you will respond to the request.
Reminders
- We have tutors available Sunday through Thursday evening from 7-10 p.m. in Science 3813/15.
- Starting this week, we will have mentor sessions on Wednesday and Thursday evenings from 8:00-9:00 p.m. in the CS Commons. Wednesdays will be more Q&A, Thursdays will include sample quizzes.
- I run review sessions on Thursdays at 9am in this room.
Upcoming Work
- Assignment 2. Due Tonight!
- Reading: Transforming Images.
- Lab writeup: Exercise 6. Due Friday before class.
Extra credit (Academic/Artistic)
- CS Table, Tuesday, TODAY, noon, middle PDR: Planning for the semester.
- Women-in-CS discussion of Hidden Figures, TODAY, 7pm, CS Commons.
- Thursday extras, Thursday, 4:15 p.m., Science 3821: LaTeX.
Extra credit (Misc)
- Any one of the activities relating to last Friday’s executive order.
Extra credit (Peer)
- Swimming and Diving meet 1pm on Saturday.
- 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.
- More of the activities relating to last Friday’s executive order.
- Women’s BBall tonight at 5:30 p.m.
Review: RGB Colors
- A standard way to represent transmissive colors.
- Think of it as a combination of three colored lights of varying intensities
- Red
- Green
- Blue
- Why these colors? It just works that way.
- How do we measure intensities?
- Some people like a 0-1 scale
- Computers like a 0-255 scale (powers of two rock!)
- Important procedures:
(irgb-new *red* *green* *blue*)- create a new color(image-set-pixel! *image col row color*)- set the color of a pixel(image-get-pixel *image col row*)- get the color of a pixela(irgb-red *color*)- get the red component(irgb-green *color*)- get the green component(irgb-blue *color*)- get the blue component(color->rgb-list *color*)- get a list of the three components(color->irgb *color*)- convert some representations to the RGB representation.
Transforming Colors
- Today we are exploring ways to transform colors.
- Why?
- Deepens our understanding of colors.
- We can apply a color transformation to a pixel in the image.
- We can apply a color transformation to each pixel in an image.
(More on that tomorrow.)
- MediaScript comes with a variety of built-in color transformations.
Building New Transformations
- How do we build our own transformation?
- We’ll learn a variety of techniques over the next few classes.
- Right now, our first technique is composition.
An Old Example
This example comes from when we covered procedure definitions before covering colors.
- We can also define our own (yay!).
- The normal framework for a color transformation is
(define color-transform
(lambda (color)
(irgb-new ___ ; computation of red component
___ ; computation of green component
___ ; computation of blue component
)))
- Let’s consider a simple one: We’ll keep only the blue component of an image.
- How would we write this?
(define only-blue
(lambda (color)
(irgb-new ___
___
___)))
- Some tests
- While we’ll spend today using this idea with pixels, for this example, we’ll explore the effect on a sample image.