 |  |

 |
 |  |  |
 | Welcome to CS1315. Click on the python to add comments.
|  |
 |  |  |
|
This page removed for FERPA compliance
|
        |
Purple rinse
#Test program works if you set media path to be the mediasources folder
#It writes the changed picture to "barbara2.jpg"
def testPurpleRinse():
barbFile = getMediaPath("barbara.jpg")
barbPic = makePicture(barbFile)
show(barbPic)
barbsHairColor = makeColor(80,30, 30) # These numbers are obtained by probing pixels using openPictureTool(getMediaPath("barbara.jpg"))
purpleRinse(barbPic, barbsHairColor)
repaint(barbPic)
writePictureTo(barbPic, getMediaPath("barbara2.jpg"))
# Take a person's picture whose hair color has been defined
# and give them a virtual purple rinse
def purpleRinse(portrait, hairColor):
threshold = 40 # This is determined by trial and error. REMOVEDe it to 20 or 100 to see the effects
for pixel in getPixels(portrait):
if distance(getColor(pixel), hairColor) < threshold:
setBlue(pixel, 2*getBlue(pixel)) # For a REMOVED dramatic effect, multiply by 4.
Link to this Page