CMSC 15100 - Summer 2005 - Lab 1

In this lab, we'll get acquainted with DrScheme and get some practice with the structures we learned about in class.

Part 1 DrScheme has lots of useful features for helping you program effectively. We'll talk about:

Part 2 Let's put these to work by finishing the function we started in class, framing a face found inside a larger image.

2A First, it will be helpful if we give names to the two images we'll be using (the whole image and the face inside it). Define these two images:

(define mars )
(define face )

(To get them into DrScheme, save them to the Desktop with your web browser, then in DrScheme go to Special | Insert Image ... and select the appropriate file.)

2B find-image, which we talked about in class, is provided by the image.ss teachpack. Use it to find the face on Mars (you can look up find-image in the Help Desk if you don't remember how it works).

2C Now we need to actually draw a frame around the face. We'll do that by drawing a green outlined rectangle — (rectangle [width] [height] 'outline 'green) — on top of the larger image with the same width and height as the face we want to box, and placed on top of the center of the face (which is coincidentally the posn that find-image gives us).

Making a box of the right size is not too difficult, but how do we place it in the right place? To do that, we can't use overlay because overlay will stack everything in the middle, and there's no way to tell it to put the green box over the face. Instead, look up overlay/xy in the Help Desk and try to figure out how it works.

2D Once you've done that, you can write write a helper function draw-box-on-image that takes an image, a width and a height for a box to draw, and a posn for the box's center. It produces the given image with a green outlined box of the given width and height centered on the given posn.

2E With that helper function we can finally write frame-image. Use find-image and draw-box-on-image to write a function that takes an image and a subimage, and produces a copy of the larger image with a green box drawn around the subimage.

2F Use the stepper to step through the evaluation of (frame-image mars face). See if it does what you expected at every step along the way.


Jacob Matthews
jacobm at cs.uchicago.edu
Hinds 026