In this lab you will become more familiar with using Python
to manipulate colors in a picture.
reduceRedfunctions are so similar, that we might ask why there are two different functions at all. Create a new function (for example, by copying and pasting either one of them) that takes an additional parameter representing the multiplier to use when modifying the amount of red in a picture.
Design Questions: What would be a clear, meaningful name for your new function? What would be a clear, meaningful name for the new parameter?Use the parameter rather than a constant multiplier value in the body of the function.
makeSunsetfunction from the previous mini-lab so that instead of looping through all the pixels and changing their green and blue values, it just calls your new, generalized functions. These new functions will take care of the looping and color changing. Test your modified function by loading and running it.
Debugging Tips: Remember that your new functions will return a new picture with the colors modified. So, after you change the green values in the picture, you need to make sure you pass the result you got from that function into the function to change the blue values. You will then return the picture that gets returned from the function that changes the blue values.
Analysis Questions: Is it necessary to create a new picture that is a duplicate of the original picture in the beginning of the
makeSunsetfunction anymore? Why or why not? If it is not necessary, remove that code from your function.
makeSunsetfunction with a number of different pictures. Choose one that you particularly like. We are going to save it using the JES
writePictureTofunction. For example, suppose my picture was captured in the variable
myPict. To save this picture as a JPEG image on a PC, I would type
When the file selector window opens, I would navigate to the folder where I want to save the image. I would then type in a name for the image, such as
sunsetPic.jpg. Be sure to include the
.jpgfile extension so that it gets saved as an image file.
To save this picture as a JPEG on a MAC, I would type
sunsetPic.jpgis whatever you want to name the image file. When the folder selector window opens, I would navigate to the folder where I want to save the image.
weightedGrayscalefunctions from the Pictures and Loops notes. For each function, create and save a modified picture.
redSkyEffect. Add a comment at the top of the function to describe what it does. Save a picture you created using your new function.
people.kzoo.edu. (You may want to review the instructions in Lab 1 if you've forgotten how to do this.)