# counts the different colors in an image # cmc, 11/17/09 from cImage import * filename = input("\nenter filename, including .gif suffix: ") im = FileImage(filename) w = im.getWidth() h = im.getHeight() colors = [] for row in range(h): for col in range(w): p = im.getPixel(col, row) rgb = (p.getRed(), p.getGreen(), p.getBlue()) if rgb not in colors: colors.append(rgb) print("number of different colors:", len(colors))