from PIL import Image def BW(infile): #infile = 'proj3.jpg' myImage = Image.open(infile) myImage.show() #Convert your opened image into RGB format myImage = myImage.convert('RGB') width, height = myImage.size #Process the image into black and write for x in range(width): for y in range(height): r,g,b = myImage.getpixel((x,y)) greylevel = int(round(r/3+g/3+b/3)) myImage.putpixel((x,y), (greylevel, greylevel, greylevel)) # Save the modified image and display outfile = infile[:-4] outfile = outfile + "_bw.jpg" myImage.save(outfile) myImage.show() BW("proj3.jpg")