Due: 11 a.m., Tuesday, September 18
No extensions!
Summary: In this assignment, you will build on the lab on writing anonymous filter procedures.
Purposes: To practice writing anonymous procedures. To gain experience with some well-known color transformation algorithms.
Expected Time: One to two hours.
Collaboration: I would prefer that you work in a group of size two or
three. However, you may work alone. You may discuss this assignment and possible solutions with
anyone you wish. If you discuss this assignment with people other than
group members, make sure to include a citation (e.g., I consulted this person, who helped me do this
).
Submitting: Email me your answer. More details below. Each group need submit only one answer.
Warning: So that this exercise is a learning assignment for everyone, I may spend class time publicly critiquing your work.
Contents:
You now have some experience in writing anonymous functions to filter images. But, practice is essential. In this homework, you will gain further experience by implementing some well-known filters.
Load a moderate-sized image (no more than about 250x250)
and name
the loaded image source.
Complete Exercise 6 (formerly Exercise 5) from the lab on writing anonymous procedures.
Complete Exercise 3 from the lab on writing anonymous procedures.
To
produce a sepia-tone image, start with a grayscale image you created
with the code from Part B. Then, write a new instruction to transform
the grayscale image so that black becomes sepia (a very dark brown),
while white remains white.
How can we accomplish this? We
want to adjust the colors in the image so that every pixel has a
red component that is at least as large as the red component of
sepia. But, so that we don't lose distinctions between bright
pixels in the image, the red component should not be 255 (the maximum)
unless it was 255 in the original image. Numbers in between
should be scaled appropriately. Similarly for the green and blue
components.
There is not a color named "sepia" in the color name list, but (define sepia (cname->rgb "bakers chocolate")) gives a pretty good approximation.
If you write your instructions well, you should be able to replace sepia with another dark color (and thus get a green-scale or blue-scale image, for example).
The last part specified that "white remains white." What if we transformed white into a light color, in addition to transforming black to a dark color?
Define dark to be a dark color of your choice and light
to be a light color of your choice. Write a Scheme instruction to
transform the grayscale image such that black is transformed to dark, white is transformed to light, and the colors in between are scaled appropriately. Your instruction from Part C should be a helpful starting place.
I will primarily look at whether your instructions are correct, automatic, and general. I will also look at the formatting and readability of your code.
Please submit this work via email. The email should be titled CSC151 HW6 and should contain the instructions you wrote in the definitions window. Please send your Scheme work as the body of an email message, along with your answer to Part E. Please attach your source image and one image you created.
Janet Davis (davisjan@cs.grinnell.edu)
Created September 13, 2007