1. 程式人生 > >李巨集毅老師機器學習作業hw0

李巨集毅老師機器學習作業hw0


content=open("words.txt").read()
array=content.split(" ")
orderindex=0
for i in range(len(array)):
    if array.index(array[i])==i:
        print("%s %s %s"%(array[i],orderindex,array.count(array[i])))
        orderindex=orderindex+1


from PIL import Image
import matplotlib.pyplot as plt

img = Image.open('westbrook.jpg'
) pix = img.load() width = img.size[0] print(width) height = img.size[1] print(height) for x in range(width): for y in range(height): r,g,b=pix[x, y] pix[x,y]=int(r/2),int(g/2),int(b/2) plt.figure("westbrook") plt.imshow(img, cmap='gray') plt.axis('off') plt.show()