Due: Tuesday, Nov 9, end of your lab session

Lab 7: Fun with Millard Fillmore

This week you will build your foundational skills by writing functions that manipulate images. The primary technique will be to transform an image into a list of colors, fiddle with that list, and convert the transformed list into a transformed image. The examples below use this picture of Millard Fillmore, our thirteenth president:
(The image is in the public domain and was retrieved from Wikipedia's Millard Fillmore page.)

Preliminaries

Set the Language level to Intermediate Student and add the image.ss teachpack.

You will write three functions:

;; squeeze : img -> img
;; smash : img -> img
;; quarter : img -> img
These functions will produce the following results, respectively: The results of applying these functions to Millard Fillmore are as follows:


Part 1

A conceptual overview of the implementations of these three functions will be given at the beginning of lab.

Remember: it is important now, as always, to document and test each individual function on various cases. Otherwise you cannot be sure that, as you assemble more complicated combinations of computations, your building blocks are made of good, solid stuff.

Write the two helper functions for function squeeze. The foundations of squeeze are the following operations:

These two functions in themselves do most of the work required by squeeze.

[Note: Functions mean-color and mean-pairs should be finished by the end of the lab session. To receive full credit, you should also get started on Part 2. Turn in all your work at the end of the lab session according to these submission instructions.]


Part 2

[Note: To receive full credit, you should have a good start on Part 2. As usual, this part will also be part of this week's homework.]

Now write function squeeze. Then, write smash. You will need to use mean-color. I will leave it to you to design an approach to this function; hints are available on request.

Having written squeeze and smash, write quarter, which is merely the composition of its two predecessors.


Hand in your work

To receive full credit, you should complete Part 1 (functions mean-color and mean-pairs) and have made a good start on Part 2. This week's homework will include Part 2 of this lab.
Save all your files and submit all your work according to the submission instructions.


Material designed by Adam Shaw.