1.What are the domain and range of quantize(n, k)?
2. Repeat Exercise 2.228 for quantize(n, k). You should ensure that quantize(n, 5) yields the function from Figure 2.59. (Hint: first determine how big a range of colors should be mapped to a particular quantum, rounding the size up. Then figure out which quantum the given input n corresponds to.)
Exercise 2.228
In Example 2.56, we introduced a function quantize for compressing a grayscale image to use only five different shades of gray. (See Figure 2.59 for a reminder of the function.) Using basic arithmetic notation (including ⌊ ⌋ and/or ⌈ ⌉ if appropriate), redefine quantize without using cases.
Figure 2.59
Figure 2.59: The function from Example 2.5
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here