# -*- coding: utf-8 -*- """ Created on Wed Nov 17 15:46:47 2021 @author: Studente Write a function that gets a filename as input with a png image , and returns a dictionary where for each color of the image there is a key with value the number of pixel of that color. {(204,204,255):17898, (0,0,0):902} """ import images def count_colors(pngfile): im = images.load(pngfile) colord = {} for row in im: for pixel in row: colord[pixel] = colord.get(pixel, 0) + 1 # if pixel in colord: # colord[pixel] += 1 # else: # colrod[pixel] = 1 return colord