CSC 151.01, Class 14: Pause for breath
Overview
- Preliminaries
- Notes and news
- Upcoming work
- Extra credit
- Questions
- A bit more on testing
- Representing images
- Reminder: types
- Lab
News / Etc.
- Continue partners.
- Happy valentine’s day! I brought you treats.
- We start a new model of images today. Yay!
- Don’t ask about new extra credit events ten minutes before they start.
Reminders
- Use our tutors! We have tutors available Sunday through Thursday evening from 7-10 p.m. in Science 3813/15.
- Ask questions via email! I’m always happy to (try to) answer questions via email. There is no need to apologize when sending me questions. If I take too long to answer, send another email (or even text, if it’s a reasonable hour).
- Visit me in my office! I’m always happy to see students during my office hours. I prefer that you book me at https://rebelsky.youcanbook.me, but you can also just show up during office hours and hope that I’m not busy.
- Visit mentor sessions! We 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.
- Visit review sessions! I run review sessions on Thursdays at 9am in this room.
- We have individual tutors!
We have individual tutors available for those who take advantage of the above and find that it’s not enough. - Visit our store! We have office supplies in the commons. Price is free will donation.
- Get news! Feel free to ask me to sign you up for the department mailing list.
- Suggest extra credit! Send me extra credit ideas and opportunities.
Upcoming Work
- Exam 1 due TONIGHT at 10:30 p.m.
- If you’ve been using images in your directory for experiments,
note that those paths make your exam identifiable. Make sure to
change the image path to
"/home/rebelsky/Desktop/kitten.jpg"or"/home/rebelsky/Desktop/kington.jpg".
- If you’ve been using images in your directory for experiments,
note that those paths make your exam identifiable. Make sure to
change the image path to
- Epilogue due Wednesday at 10:30 p.m. (but do it immediately after the exam anyway)
- Lab writeup, problem ?, due Friday before class.
- Reading: Making and manipulating homogeneous lists due tomorrow.
Extra credit (Academic/Artistic)
- CS Table, Tuesday at noon, 14 Feb 2017. On Technology, Slots, and Whales. Reading packets should be available outside Curtsinger’s office or Orsera’s office.
- Thursday extras, Thursday, 16 Feb 2017, 4:15 p.m., Science 3821: 4-1 joint BA/MSC program with UIowa.
Extra credit (Peer)
- Friday-Saturday-Sunday, 17th-19th, Swimming and diving conference championships. (You can only get credit for two of the three days; staying for an hour counts.)
- Saturday the 18th, Symphony Concert. 2-4 p.m. Sound painting and more! In Sebring-Lewis.
- NEW Art house print making and cookie decorating event. Saturday February 18th, 1-3PM on JRC 227. Gluten-free options!
Good things to do
- Women’s basketball (Senior day) next Saturday at 1pm.
- Men’s basketball (Senior day) next Saturday at 3pm.
- NEW Slavic coffee house, Saturday, 5:30-7:00 p.m. Bucksbaum Rotunda.
Questions
- If mediascript does not show under Gimp, what do I do?
- Email Sam with the name of the computer.
- Try another computer.
- Why do I see
#<procedure:>>? - Because you have
>somewhere in the definitions pane. - How should I show examples?
- Put them in the 000000.rkt file, commented out with semicolons.
- Do not comment out with boxes.
- What about when we’re manipulating images?
- ; (image-show (image-increase-contrast (image-load “/home/rebelsky/Desktop/mentor.jpg” 22))
- ; 5
- ; ; Yup, looks good to me.
- What do you preferred questions look like?
- Sam, I’m trying to do this. Here’s what I’ve come up with. Here’s what I understand to be the problem. Here’s a case it doesn’t work. Help!
- How much is enough whitespace?
- So that it’s readable. It takes some practice to get it right. But make sure that the reader can mostly see what procedures are being applied to what parameters.
- How late can we email you?
- As let as you want. I may stop responding at 5:30.
A bit more on testing
In yesterday’s class, we wrote the following documentation. (I’ve changed the name of the procedure and added a stub implementation.)
;;; Procedure:
;;; irgb-brighter
;;; Parameters:
;;; color, an integer-encoded RGB color
;;; Purpose:
;;; Compute a lighter version of that color
;;; Produces:
;;; brighter, an integer-encoded RGB color
;;; Preconditions:
;;; [No additional]
;;; Postconditions:
;;; The components are larger than in the original color,
;;; unless they were already 255.
;;; (irgb-red brighter) > (irgb-red original)
;;; (irgb-green brighter) > (irgb-green original)
;;; (irgb-blue brighter) > (irgb-blue original)
(define irgb-brighter
(lambda (color)
color))
Are there alternative postconditions you might write?
- Maybe make more specific.
- Advantages of general vs. specific?
- If it’s clear that only a few cases are acceptable, specific makes sense
- If it’s hard to write all of the conditions, specific may be a pain in the neck
- Sometimes you can’t know specific things, so general postconditions are helpful
- Sometimes you don’t want to limit the implementation, so general postconditions can be good.
- Perhaps we can decrease some and increase the others. E.g.,
(irgb 20 100 20)to(irgb 15 200 15). - We might say that
brighteris brighter thanoriginalif the sum of the components inbrighteris greater than the sum of the components inoriginal. - If the luma of
brighteris greater than the luma oforiginal.
What are some tests you would write?
- Make sure the red component of the result is bigger than the red component of original.
- Make sure the green component of the result is bigger than the green component of original.
- Make sure the blue component of the result is bigger than the blue component of original.
(check > (irgb-red (irgb-brighter color)) (irgb-red color)))(check > (irgb-red (irgb-brighter (irgb 10 10 10))) (irgb-red (irgb 10 10 10))))- One with a dark component, a bright component, and an intermediate component
(check > (irgb-red (irgb-brighter (irgb 5 254 128))) (irgb-red (irgb 5 254 128))))- Check all 0’s. Edge cases are important.
(check > (irgb-red (irgb-brighter (irgb 0 0 0))) (irgb-red (irgb 0 0 0))))
Morals
- You need to use actual data for tests, you can’t just say “the result is …”
- You need to think about a variety of cases.
- Keep your tests DRY (don’t repeat yourself), if possible. Write a general procedure that you can then apply to specific values.
#lang racket
(require gigls/unsafe)
(require rackunit)
(require rackunit/text-ui)
;> (irgb->string (irgb-darker (irgb 12 123 5000)))
;"0/107/239"
;;; Procedure:
;;; irgb-brighter
;;; Parameters:
;;; color, an integer-encoded RGB color
;;; Purpose:
;;; Compute a lighter version of that color
;;; Produces:
;;; brighter, an integer-encoded RGB color
;;; Preconditions:
;;; [No additional]
;;; Postconditions:
;;; The components are larger than in the original color,
;;; unless they were already 255.
;;; (irgb-red brighter) > (irgb-red original)
;;; (irgb-green brighter) > (irgb-green original)
;;; (irgb-blue brighter) > (irgb-blue original)
(define irgb-brighter
(lambda (color)
(irgb (* 1.5 (irgb-red color))
(* 1.5 (irgb-green color))
(* 1.5 (irgb-blue color)))))
(define check-brighter
(lambda (color)
(check > (irgb-red (irgb-brighter color)) (irgb-red color)
(irgb->string color))
(check > (irgb-green (irgb-brighter color)) (irgb-green color)
(irgb->string color))
(check > (irgb-blue (irgb-brighter color)) (irgb-blue color)
(irgb->string color))))
;(check >
; (irgb-red (irgb-brighter (irgb 10 10 10)))
; (irgb-red (irgb 10 10 10)))
(check-brighter (irgb 10 10 10))
(check-brighter (irgb 5 254 128))
(check-brighter (irgb 0 0 0))
Representing images
- Throughout the semester, we will look at different models of describing images.
- So far: Grid of pixels that we can transform.
- Today (through Friday): Manipulating some very basic shapes (circles and squares).
- Near future: Describe images through gimp instructions
- Additional: Back to pixels, but how to compute each pixel from scratch
- (Simulated) robotic turtles
Reminder: types
We have a new type: The shape (aka “drawing as values”)
- What can I do with these values? What’s the purpose of having this type?
- Make simplistic pictures.
- How do we express these values?
drawing-unit-circledrawing-unit-square- Apply operations to those
- What operations are available to us?
(drawing-scale drawing amt)-> Creates a scaled version of the drawing(image-show (drawing->image drawing width height))
- How does Scheme represent these values?
Example
> (image-show (drawing->image (drawing-scale drawing-unit-circle 100)
200 200))
2
We see a picture of a radius 50 circle, centered at (0,0).
Lab
We will do this on Wednesday.