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. For example, given a pixel with old values R’, G’, and B’, the negated pixel will have values:
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:
Submit your working mouse.py
to Moodle AND INCLUDE THE IMAGE YOU USED.