# Class 07: Drawings as Values

This outline is also available in PDF.

Held: Wednesday, February 3, 2010

Summary: We consider another way to think about images. In particular, we consider what we call the drawings as values model, in which we describe images by transforming and composing simple pictures.

Related Pages:

Notes:

• Readings for Friday: Writing Your Own Procedures and How Scheme Evaluates Expressions (version 2).
• Sorry for the delay in posting the readings for today. It will happen again.
• Due: Assignment 2.
• Nora noted some confusion about the relationship of selections and lines, which we'll discuss.
• Don't forget: Keep your lab partners from yesterday.
• EC: CS Table Friday at noon. Information distributed via email.
• EC: CS Extras Thursday at 4:30 in 3821 (Talk on summer opportunities in CS).
• EC: Booth family fundraiser Friday night.

Overview:

• Representing images.
• Thinking about drawings through composition/decomposition.
• Pure approaches vs impure approaches.
• Lab.

## Representing Images

• As you may recall, one of the initial themes of this course is that there is more than one way to represent an image.
• Early on, we considered multiple ways to draw smiley faces.
• In this course, we will also consider multiple computational ways to think about images.
• You've seen one: We can describe images by the GIMP commands necessary to create them.
• More precisely, we can describe images computationally by a series of calls to the MediaScript GIMP Tools procedures.
• We're about to explore another.

## Drawings

• The drawing representation takes a very different perspective.
• We start with a few basic values (the unit square and the unit circle).
• We add a few operations
• Scaling
• Shifting
• Recoloring
• Grouping
• We see what benefits (and obstacles) this new approach gives us.
• Once we've described a drawing, we can create an image from it using `drawing->image`.
• 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.

## Purity

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

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

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 May 11 09:03:07 2010.
The source to the document was last modified on Thu Jan 21 13:05:10 2010.
This document may be found at `http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2010S/Outlines/outline.07.html`.

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

Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright © 2007-10 Janet Davis, Matthew Kluber, Samuel A. Rebelsky, and Jerod Weinman. (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.