CSC151 2007S, Class 39: Manipulating Images with Script-Fu Admin: * If you got at least a B on the exam (and are enjoying the subject matter), you should think about going on to the wonders of CSC152 in the fall. * If you'd like to go on and got less than a B, talk to me. * If you needed the "There's more to CS" fix, consider getting a Tutor or setting up a regular appointment with me. * No office hours today (similar reason to Monday); I should be here in the afternoon, though. * Are there questions on Homework 12? * Visit or email or ... Overview: * Primary image-manipulation procedures. * Color transformations. * Lab. /In order to modify images, we need .../ * Determine the color at a point (get-color-at image x y) * Choose a new color, perhaps based on that color (rgb redpart greenpart bluepart) (red color) (green color) (blue color) * Set the color at a point in the image (set-color-at! image x y newcolor) * Why is there an exclamation point in set-color-at! Because it changes the underlying image. * Once we know how to modify one point, we can modify the entire image by applying the same procedure at every point in the image (modify-image! colorfun image) /How do we modify colors?/ * Easy way: Anonymously (lambda (color) (rgb (do-something-to color) (do-something-else-to color) (do-something-else-else-to color))) * But this is verbose, so we might write helpers (define redder (lambda (amt color) (rgb (+ amt (red color)) (green color) (blue color)))) * But we can't use this in modify-image!. We need to fill in only the first parameter to get a color transformer. * Strategy one: (left-section redder 32) * Strategy two: Rewrite redder using a different structure (define redder (lambda (amt) (lambda (color) (rgb (+ amt (red color)) (green color) (blue color)))))a (redder 32) => procedure of one parameter that adds 32 to the red component * If you choose good definitions, youc an write interesting transformations with fewer words.