python
CS01104.21 Lab #2 Homework Assignment September 24, 2019
Name___________________________________________
You are going to write functions that will create grayscale copies of pictures.
Exercise #1. Use the JES functions pickAFile and makePicture to create a picture.
Exercise #2. Write a function RGB2YLinear. This function takes a JES color as input and creates a
luminance 𝑌 = 0.2126 ⋅ 𝑅 + 0.7152 ⋅ 𝐺 + 0.0722 ⋅ 𝐵 from it. This luminance is then
used to create and return a grayscale color with the JES function Color(Y,Y,Y).
Then write a function picture2GrayscaleLinear which takes a picture object as
input, creates a copy of it, and changes the colors of all pixels of the copy to grayscale.
Then your function will return the grayscale copy of the picture you created in Exercise
1.
Exercise #3. Write a function RGB2YNonlinear. This function takes a JES color as input and
creates a luminance 𝑌 = 0.299 ⋅ 𝑅 + 0.587 ⋅ 𝐺 + 0.114 ⋅ 𝐵 from it. This luminance is
then used to create and return a grayscale color with the JES function Color(Y,Y,Y).
Then write a function picture2GrayscaleNonlinear which takes a picture
object as input, creates a copy of it, and changes the colors of all pixels to grayscale.
Then your function will return the grayscale copy of the picture you created in Exercise
1.
Exercise #4. Discuss differences, if any, in the resulting pictures you created. Technical details are not
necessary, but can be found at
https://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale .