70 likes | 234 Views
Algorithm. http://www.ted.com/talks/kevin_slavin_how_algorithms_shape_our_world. B/W picture. When red, green, and blue color values are identical Appears to be B/W How to determine the intensity of B/W ? bw = (red value + green value + blue value)/3. Repeat in JES. How to automate it ?.
E N D
Algorithm • http://www.ted.com/talks/kevin_slavin_how_algorithms_shape_our_world
B/W picture • When red, green, and blue color values are identical • Appears to be B/W • How to determine the intensity of B/W ? • bw = (red value + green value + blue value)/3
How to automate it ? • Write a function to carry out changes to bw • What does the function bwRow() do ? • How to run (execute) it ?
How to automate it for the entire picture ? def greyScale(pic): wid = pic.getWidth() hgt = pic.getHeight() for row in range(0,hgt): for col in range(0, wid): myPix = pic.getPixel(col, row) bw = (myPix.getRed()+myPix.getGreen()+myPix.getBlue())/3 gray = makeColor(bw,bw,bw) setColor(myPix,gray) return pic
LAB • Write a Python function to create a negative of a picture • How to create a negative pixel ? • Given red, green, blue colors of a pixel, • negColor=makeColor( 255-red, 255-green, 255-blue) • Set the color of the pixel to negColor • Repeat it for the entire picture • Open a new MS Word document, copy/paste a screen shot with the function and the result, and send MS Word to kim@cs.uml.edu.