李宏毅老师机器学习作业hw0

李宏毅老师机器学习作业hw0_第1张图片

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

李宏毅老师机器学习作业hw0_第2张图片

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()

你可能感兴趣的:(机器学习)