Warning! You are being recorded (and transcribed) (provided the technology is working correctly).
Please follow the traditional start-of-class approach.
Approximate overview
#(fun value %1) notation is new this semester, so the evening
tutors may be a bit confused by it.Scholarly
Artistic/Cultural
Multicultural
Peer
Musical, theatric, sporting, academic, and similar events involving this section’s students are welcome.
Wellness
Misc
These do not earn tokens, but are worth your consideration.
I won’t be here on Friday. Can I take the quiz on Thursday?
Sure. You can take it during office hours.
Why doesn’t solid-polygon work?
I’m not sure. I’m doing some experiments and then asking PM to fix it.
Can I turn in work at 1:00 a.m. rather than 10:30 p.m.?
Yes, but it will cost you a token.
And you should be in bed at 1:00 a.m.
Will you fix the sample LA?
Yes.
Will MP2 be ready soon?
Tonight, I hope. Otherwise, tomorrow night.
Will you give us candy if we ask questions?
Perhaps. Lolipops and gummi-bears.
Do we get feedback on our mini-projects?
A bit. Set up a meeting if you’d like more.
When will we get our mini-projects back?
Monday.
How often will we get updates on grades and tokens?
With each mini-project return.
In Monday’s lab, I asked you to try a variety of experiments with
rgb-darker, rgb-complement, etc., in which you predicted output
for multiple inputs and then checked the output.
Why might I have structured the lab like that? (TPS)
To encourage us to learn about these procedures through exploration, rather than just reading.
The ordering may have been carefully structured because darker and lighter modify all three components in the same way, but redder, greener, and bluer modify the components in different ways
Model: “Don’t just type stuff in, think about it.” You will likely learn the functions better if you try them thoughtfully (hypothesize then run) rather than just running them. [+2]
Practicing with moderately simple Scheme expressions better prepares you for the more complex things we’ll soon get to.
UM - Use math
Permitted us to think in a bit more detail about the likely processes.
Also encouraged us to think about the relationship between the RGB values and the colors we see on the screen.
We learn the vocabulary well enough to use the functions in the future. (Hint: They should be in your notes and/or on your cheat sheets and/or flash cards.)
Knowing the functions early helped us better understand composition and octothorpe-percent cutting.
#(rgb-average (rgb 255 255 255) %1)
Side note:
#hashtagis a hashtag,#is a hash (or mesh, or pound, or number sign, or octothorpe)
As in every lab, it’s an opportunity to put what you’ve read about in practice. (Part of the theory of the course: You learn better by doing than (just) reading or listening to lecture.)
Model: Trying different different colors gave us a deeper understanding of what the functions did. Generally: When you’re exploring a new procedure, you should try it on more than one or two inputs, and you should think about “difficult” inputs. For example, what happens when we make white or black lighter?
Reminds us that there are a lot of functions.
Learned about manipulating colors and images.
Learned about making functions in different ways.
Identified patterns in output. Identifying patterns is one of the important skills in computational thinking.
Four important functions for converting decimal (real) numbers to integers.
round, floor, ceiling, truncate.
What do they do?
round- takes a real number and returns the closest integer. At .5, it will return the larger of the two equally close integers.
floor- take a real number and returns the closest integer that is less than or equal to that number. (rounds down)
ceiling- opposite of floor: returns the closest integer that’s larger or equal to than it
truncate- removes everything after the decimal point
What is the difference between truncate and floor? Is there a number,
x, for which (truncate x) and (floor x) are different?
Yes, negative numbers.
(define transform-image-4a
(lambda (img)
(pixel-map (lambda (c)
(rgb (rgb-red c) 0 (rgb-blue c)))
img)))
Why are there two lambdas in this function? (TPS)
transform-imageis supposed to take an image as input. Thelambda (img)is our normal starting point for things that take an image as input.
The
(lambda (c) (rgb ...))transforms a color by removing the green.
transform-imageneeds a function that converts a color to another color (more precisely, and RGB to another RGB), and we build functions withlambda.
The color transformation is “anonymous” (unknown) not named
(define transform-image-4b
(lambda (img)
(pixel-map (o rgb-bluer rgb-redder) img)))
This is a procedure that takes image as input and makes each pixel redder and then bluer.
Does it matter whether we do (o rgb-bluer rgb-redder) or
(o rgb-redder rgb-bluer)?
Most of the time, no, but if the red or blue component was large or small, there would be a small difference (which we might or might not see).
(define transform-image-4c
(lambda (img)
(pixel-map (o rgb-pseudo-complement rgb-greener rgb-pseudo-complement) img)))
What does this do?
transform-image-4ctakes an image as input and for each pixel, computes the pseudo-complement, makes it greener, and computes the pseudocomplement again.
Because we’re complementing it twice, this makes it less green / more purple.
(define transform-image-4d
(lambda (img)
(pixel-map #(rgb-subtract %1 (rgb 100 0 100)) img)))
(define transform-image-4e
(lambda (img)
(pixel-map #(rgb-subtract (rgb 255 255 255) %1) img)))
4dtakes an image as input and subtracts 100 from the red compoent of each pixel and 100 from the blue component of each pixel
This will make it appear more green.
4etakes an image as input and subtracts each component from 255
This computes the pseudo complement
(define transform-image-4f
(lambda (img)
(pixel-map #(rgb-subtract %1 (rgb 255 255 255)) img)))
This subtracts 255 from each component, making all the components 0,
(rgb 0 0 0)is black.
Not everyone likes the new #% syntax, so we’re also providing an alternative for the most common uses: Filling in one parameter of a two parameter function.
(l-s FUN LEFT) is the same as #(FUN LEFT %1)
(r-s FUN RIGHT) is the same as #(FUN %1 RIGHT)
(define transform-image-5a
(lambda (img)
(pixel-map (r-s rgb-subtract (rgb 100 0 100)) img)))
A different way to write “take an image and subtract 100 from the red and blue components of each pixel”
(define transform-image-5b
(lambda (img)
(pixel-map (l-s rgb-subtract (rgb 255 255 255)) img)))
A different wa to write
image-pseudo-complement