Today I had a 4-hour lab period in which I was expected to write a program that takes an image and makes it grayscale. We work in a watered-down Python environment running in Java (WHY?!).
Obviously it took about 5 minutes to boot the computer, setup the environment and write a paragraph, then submit it:
This was four steps beyond what was expected, and done in 1/48th of the alotted time. Hopefully the course won't stay so mundane throughout, or I'm in for a very dull semester.
Obviously it took about 5 minutes to boot the computer, setup the environment and write a paragraph, then submit it:
Code:
def grayScale(redWeight,greenWeight,blueWeight):
pic=makePicture(pickAFile())
show(pic)
for p in getPixels(pic):
r = getRed(p)*redWeight #0.299
g = getGreen(p)*greenWeight #0.587
b = getBlue(p)*blueWeight #0.114
lum = r+g+b
setColor(p,makeColor(lum,lum,lum))
repaint(pic)