#---------------------------------------------------------------------- # Simple image transform program # Un-comment the section that you want to test # # Copyright (C) February 23, 2018 -- Dr. William T. Verts #---------------------------------------------------------------------- Filename = pickAFile() Canvas = makePicture(Filename) show(Canvas) for Y in range(getHeight(Canvas)): for X in range(getWidth(Canvas)): PX = getPixel(Canvas,X,Y) R = getRed(PX) G = getGreen(PX) B = getBlue(PX) # Brighten the image #R = R + 20 #G = G + 20 #B = B + 20 # Darken the image #R = R - 20 #G = G - 20 #B = B - 20 # Negate the image #R = 255 - R #G = 255 - G #B = 255 - B # Gray-Scale the image #Average = (R + G + B) / 3 #R = Average #G = Average #B = Average # Change the image to B&W #Average = (R + G + B) / 3 #if Average > 128: # Change the number to set the threshold between B and W # R = 255 # G = 255 # B = 255 #else: # R = 0 # G = 0 # B = 0 setRed(PX,R) setGreen(PX,G) setBlue(PX,B) repaint(Canvas)