Complete the setup to install the cImage
module and read some key differences based on the latest updates to the module.
Create a file called mouse.py
and save it to your cs100/ch6
folder. Save the following images to the same location with the name: lutherbell.gif and mickey.jpg.
from image import *
# get image
img = FileImage("lutherbell.gif")
width = img.getWidth()
height = img.getHeight()
# create window
myWin = ImageWin(width, height, "Awesome Image")
# display image on window
img.draw(myWin)
# print out RGB values of pixel based on where mouse clicks
x,y = myWin.getMouse()
p = img.getPixel(x,y)
print("Pixel values: ", p.getRed(), p.getGreen(), p.getBlue())
# exit window when user clicks on any part of it
myWin.exitOnClick()
Modify the script to display the Mickey Mouse picture.
negative(p)
that receives a pixel and returns its corresponding negative pixel. Then use this function to create the negative picture of your Mickey Mouse. It will look like the following when this step is complete:x
as the red, green, and blue values, where x
is an average of the original RGB values.It will look like the following when this step is complete:Modify the script to display Mickey with a purple shirt instead of a red one.
Work on your final project with your group.
Submit your working mouse.py
to Moodle AND INCLUDE THE IMAGE YOU USED.