Functional Problem Solving (CSC 151 2015F) : Outlines

Outline 22: Images as Functions from Position to Colors


Held: Monday, 5 October 2015

Back to Outline 21 - Anonymous Procedures, Revisited. On to Outline 23 - Revisiting Lists.

Summary

We consider a simple approach to working with images - looping over the positions in an image and computing a new color based on positional information. We then explore some applications of this approach.

Related Pages

Overview

Administrivia

Upcoming Work

Extra Credit Opportunities

Academic

Peer Support

Other Good Things

Quiz 5

You are now at the point that you should be able to notate lists correctly. Please do so in the future.

The last problem caused trouble for many of you. It asked you to identify whether the parameter was a non-zero, even, integer.

Here's one solution

 (define non-zero-even?
   (lambda (num)
     (cond
       [(not (integer? num))
        #f]
       [(not (even? num))
        #f]
       [(zero? num)
        #f]
       [else
        #t])))

However, as ZS says, "If you find yourself explicitly writing #t and #f, you can probably simplify it."

 (define non-zero-even?
   (lambda (num)
     (and (integer? num) (even? num) (not (zero? num)))))

Models of images

The image-compute model

Examples