Skip to main content

Class 15: Drawings as Values

Held: Wednesday, 15 February 2017

We explore a special kind of values, values that can be used to represent images. We call this the “drawings as values” model, and describe images by transforming and composing very simple shapes.

Preliminaries

Overview

  • Representing images
  • Thinking about drawings through composition and decomposition
  • The underlying representation
  • Pure vs. impure approaches

Updates

News / Etc.

  • New partners!
  • Please turn in your exam cover sheets to the mentors.
  • Sorry for the confusion on writeup 10 (?). If the grader said something like “Where is irgb-average?”, and had no other concerns, don’t worry, you got credit for the writeup.
  • The grader has returned HW2 (but forgot to cc me).
  • In the interests of keeping Friday’s class efficient, I will not take questions before the quiz.

Friday’s quiz topics

  • Drawings as values (today’s topic)
  • Documentation
  • Testing
  • (Past topics, as appropriate)

Reminders

  • 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.

Upcoming Work

Extra credit (Academic/Artistic)

  • Thursday extras, Thursday, 16 Feb 2017, 4:15 p.m., Science 3821: 4-1 joint BA/MSC program with UIowa.
  • NEW CS Table, Tuesday at noon, 21 Feb 2017. Net neutrality. Reading packets should be available outside Curtsinger’s office or Orsera’s office.

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.
  • Art house print making and cookie decorating event. Saturday February 18th, 1-3PM on JRC 227.

Good things to do

  • Women’s basketball (Senior day) next Saturday at 1pm.
  • Men’s basketball (Senior day) next Saturday at 3pm.
  • Slavic coffee house, Saturday, 5:30-7:00 p.m. Bucksbaum Rotunda.
  • NEW Grinnell Equestrian Club Drill Team bake sale, 20 February 2017, 11am-2pm and 4pm-9pm.
    • Am I the only one who reads “Club Drill Team” and thinks of the Flintstones?
  • NEW Ready to Run: Campaign Training for Women, Friday, 9am-noon, Harris. (You will need to take the quiz on Thursday, but I will excuse you from class.)

Representing Images

  • One of the themes of this course is that there is more than one way to represent an image.
  • In this course, we will also consider multiple computational ways to think about images.
  • Today we explore our first one, based on simple shapes. We call this model drawings as values.

Drawings

  • Your questions about a new type should be
    • What kinds of values do I have?
    • How do I represent those values?
    • What operations do I have?
  • We start with a few basic values (the unit square and the unit circle).
    • We represent these as drawing-unit-square and drawing-unit-circle
    • These are values, not procedures.
  • We add a few operations (procedures)
    • Scaling
      • If d is a drawing, (scale-drawing amt d) is a drawing
    • Shifting
      • If d is a drawing, (hshift-drawing amt d) is a drawing
    • Recoloring
      • If d is a drawing, (recolor-drawing color d) is a drawing
    • Grouping
      • If d1 and d2 are drawings, so is (drawing-group d1 d2)
  • Once we’ve described a drawing, we can view it with (image-show (drawing->image d width height))
  • We will explore what benefits (and obstacles) this approach gives us.
  • This model of images models one of the ways we sometimes think about images: Every image can be thought of as a composition of simpler components.
    • We just take that idea to the extreme.

Representing Drawings

  • There is an underlying representation.
  • You shouldn’t need to know it.
  • But it can be helpful to look.

Lab

  • Do The lab.
  • Be prepared to reflect.

Purity (Optional)

  • Note that the definition of drawings uses induction, in much the same way that the definition of whole numbers uses induction.
  • For whole numbers:
    • 0 is a whole number
    • If w is a whole number, 1+w is a whole number
  • For drawings
    • The unit circle is a drawing.
    • The unit square is a drawing.
    • If d is a drawing, then a shifted version of d is a drawing.
    • If d is a drawing, then a scaled version of d is a drawing.
    • If d1 and d2 are drawings, the grouping of d1 and d2 is a drawing.
  • When we build a new whole number from a previous whole number (by adding 1), we don’t affect the previous whole number.
  • Similarly, when we build a new drawing from a previous drawing, we don’t affect the previous drawing.
  • Contrast this with the GIMP tools, in which each command changes (sometimes irrevocably) the underlying image.
  • When operations do not affect the underlying data structure, we call them pure operations.